Exemplo n.º 1
0
 /**
  * Start
  *
  * @param Pronamic_Pay_PaymentDataInterface $data
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_PaymentDataInterface $data, Pronamic_Pay_Payment $payment, $payment_method = null)
 {
     $payment->set_transaction_id(md5(time() . $data->get_order_id()));
     $payment->set_action_url($this->client->get_payment_server_url());
     $this->client->set_merchant_reference($data->get_order_id());
     $this->client->set_payment_amount($data->get_amount());
     $this->client->set_currency_code($data->get_currency());
     $this->client->set_ship_before_date(new DateTime('+5 days'));
     $this->client->set_shopper_locale($data->get_language_and_country());
     $this->client->set_order_data($data->get_description());
     $this->client->set_session_validity(new DateTime('+1 hour'));
     $this->client->set_shopper_reference($data->get_email());
     $this->client->set_shopper_email($data->get_email());
 }
Exemplo n.º 2
0
 public function start(Pronamic_Pay_PaymentDataInterface $data, Pronamic_Pay_Payment $payment, $payment_method = null)
 {
     $url = add_query_arg('payment', $payment->get_id(), home_url('/'));
     $transaction_description = $data->get_description();
     if (empty($transaction_description)) {
         $transaction_description = $payment->get_id();
     }
     $merchant = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Merchant();
     $merchant->account = $this->config->account_id;
     $merchant->site_id = $this->config->site_id;
     $merchant->site_secure_code = $this->config->site_code;
     $merchant->notification_url = $url;
     $merchant->redirect_url = $url;
     $merchant->cancel_url = $url;
     $merchant->close_window = 'false';
     $customer = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Customer();
     $customer->locale = $data->get_language_and_country();
     $customer->ip_address = Pronamic_WP_Pay_Server::get('REMOTE_ADDR', FILTER_VALIDATE_IP);
     $customer->forwarded_ip = Pronamic_WP_Pay_Server::get('HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP);
     $customer->first_name = $data->getCustomerName();
     $customer->email = $data->get_email();
     $transaction = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Transaction();
     $transaction->id = uniqid();
     $transaction->currency = $data->get_currency();
     $transaction->amount = $data->get_amount();
     $transaction->description = $transaction_description;
     switch ($payment_method) {
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $gateway_info = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_GatewayInfo();
             $gateway_info->issuer_id = $data->get_issuer_id();
             $transaction->gateway = Pronamic_WP_Pay_Gateways_MultiSafepay_Gateways::IDEAL;
             $message = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_XML_DirectTransactionRequestMessage($merchant, $customer, $transaction, $gateway_info);
             break;
         case Pronamic_WP_Pay_PaymentMethods::BANK_TRANSFER:
             $transaction->gateway = Pronamic_WP_Pay_Gateways_MultiSafepay_Gateways::BANK_TRANSFER;
             $message = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_XML_RedirectTransactionRequestMessage($merchant, $customer, $transaction);
             break;
         default:
             $message = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_XML_RedirectTransactionRequestMessage($merchant, $customer, $transaction);
     }
     $signature = Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Signature::generate($transaction->amount, $transaction->currency, $merchant->account, $merchant->site_id, $transaction->id);
     $message->signature = $signature;
     $response = $this->client->start_transaction($message);
     if ($response) {
         $transaction = $response->transaction;
         $payment->set_transaction_id($transaction->id);
         if ($transaction->payment_url) {
             $payment->set_action_url($transaction->payment_url);
         }
         if ($response->gateway_info && $response->gateway_info->redirect_url) {
             $payment->set_action_url($response->gateway_info->redirect_url);
         }
     } else {
         $this->error = $this->client->get_error();
     }
 }