示例#1
0
 /**
  * Start
  *
  * @param Pronamic_Pay_PaymentDataInterface $data
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $request = array('enduser' => array('lastName' => $payment->get_customer_name(), 'emailAddress' => $payment->get_email()));
     switch ($payment->get_method()) {
         case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
         case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
             $request['paymentOptionId'] = Pronamic_WP_Pay_Gateways_PayNL_PaymentMethods::MISTERCASH;
             break;
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $request['paymentOptionId'] = Pronamic_WP_Pay_Gateways_PayNL_PaymentMethods::IDEAL;
             $request['paymentOptionSubId'] = $payment->get_issuer();
             break;
     }
     $result = $this->client->transaction_start($payment->get_amount(), Pronamic_WP_Pay_Gateways_PayNL_Util::get_ip_address(), rawurlencode($payment->get_return_url()), $request);
     if (!$result) {
         $this->error = $this->client->get_error();
         return;
     }
     $payment->set_transaction_id($result->transaction->transactionId);
     $payment->set_action_url($result->transaction->paymentURL);
 }
示例#2
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $request = new Pronamic_WP_Pay_Gateways_Mollie_PaymentRequest();
     $payment_method = $payment->get_method();
     $request->amount = $payment->get_amount();
     $request->description = $payment->get_description();
     $request->redirect_url = $payment->get_return_url();
     $request->webhook_url = $this->get_webhook_url();
     $request->locale = Pronamic_WP_Pay_Mollie_LocaleHelper::transform($payment->get_language());
     $request->method = Pronamic_WP_Pay_Mollie_Methods::transform($payment_method);
     if (empty($request->method) && !empty($payment_method)) {
         // Leap of faith if the WordPress payment method could not transform to a Mollie method?
         $request->method = $payment_method;
     }
     // Customer ID
     $user_id = $payment->post->post_author;
     $customer_id = $this->get_customer_id_by_wp_user_id($user_id);
     if (empty($customer_id)) {
         $customer_id = $this->client->create_customer($payment->get_email(), $payment->get_customer_name());
         if ($customer_id) {
             $this->update_wp_user_customer_id($user_id, $customer_id);
         }
     }
     $payment->set_meta('mollie_customer_id', $customer_id);
     // Subscriptions
     $subscription = $payment->get_subscription();
     $subscription_methods = array(Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD, Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT_IDEAL);
     if ($subscription && in_array($payment_method, $subscription_methods, true)) {
         if (is_object($this->client->get_error())) {
             // Set error if customer could not be created
             $this->error = $this->client->get_error();
             // Prevent subscription payment from being created without customer
             return;
         }
         $request->recurring_type = Pronamic_WP_Pay_Mollie_Recurring::RECURRING;
         $request->method = Pronamic_WP_Pay_Mollie_Methods::transform($payment_method);
         if (Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT_IDEAL === $payment_method) {
             // Use direct debit for recurring payments with payment method `Direct Debit (mandate via iDEAL)`.
             $request->method = Pronamic_WP_Pay_Mollie_Methods::DIRECT_DEBIT;
         }
         if ($subscription->has_valid_payment() && !$customer_id) {
             // Get customer ID from first payment
             $first = $subscription->get_first_payment();
             $customer_id = $first->get_meta('mollie_customer_id');
             $payment->set_meta('mollie_customer_id', $customer_id);
         }
         $can_user_interact = in_array($payment->get_source(), array('gravityformsideal'), true);
         // Mandate payment method to check for.
         $mandate_method = $payment_method;
         if (Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT_IDEAL === $mandate_method) {
             $mandate_method = Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT;
         }
         if (!$this->client->has_valid_mandate($customer_id, $mandate_method) && (!$subscription->has_valid_payment() || $can_user_interact)) {
             // First payment or if user interaction is possible and no valid mandates are found
             $request->recurring_type = Pronamic_WP_Pay_Mollie_Recurring::FIRST;
             if (Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT_IDEAL === $payment_method) {
                 // Use iDEAL for first payments with payment method `Direct Debit (mandate via iDEAL)`.
                 $request->method = Pronamic_WP_Pay_Mollie_Methods::IDEAL;
             }
         }
         if (Pronamic_WP_Pay_Mollie_Recurring::RECURRING === $request->recurring_type) {
             // Recurring payment
             $payment->set_action_url($payment->get_return_url());
             if ($subscription->has_valid_payment()) {
                 // Use subscription amount if this is not the initial payment.
                 $payment->amount = $subscription->get_amount();
             }
         }
     }
     if (Pronamic_WP_Pay_PaymentMethods::IDEAL === $payment_method) {
         // If payment method is iDEAL we set the user chosen issuer ID.
         $request->issuer = $payment->get_issuer();
     }
     $request->customer_id = $customer_id;
     $result = $this->client->create_payment($request);
     if (!$result) {
         $this->error = $this->client->get_error();
         return;
     }
     if ($subscription && Pronamic_WP_Pay_Mollie_Recurring::RECURRING === $request->recurring_type) {
         $subscription->set_status(Pronamic_WP_Pay_Mollie_Statuses::transform($result->status));
     }
     $payment->set_transaction_id($result->id);
     if ('' === $payment->get_action_url()) {
         $payment->set_action_url($result->links->paymentUrl);
     }
 }
 /**
  * Start payment.
  *
  * @param Pronamic_Pay_Payment $payment payment object
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $transaction_description = $payment->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 = $payment->get_return_url();
     $merchant->redirect_url = $payment->get_return_url();
     $merchant->cancel_url = $payment->get_return_url();
     $merchant->close_window = 'false';
     $customer = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Customer();
     $customer->locale = $payment->get_locale();
     $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 = $payment->get_customer_name();
     $customer->email = $payment->get_email();
     $transaction = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_Transaction();
     $transaction->id = uniqid();
     $transaction->currency = $payment->get_currency();
     $transaction->amount = $payment->get_amount();
     $transaction->description = $transaction_description;
     switch ($payment->get_method()) {
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $gateway_info = new Pronamic_WP_Pay_Gateways_MultiSafepay_Connect_GatewayInfo();
             $gateway_info->issuer_id = $payment->get_issuer();
             $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();
     }
 }
示例#4
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $parameters = new Pronamic_WP_Pay_Gateways_TargetPay_IDealStartParameters();
     $parameters->rtlo = $this->config->layoutcode;
     $parameters->bank = $payment->get_issuer();
     $parameters->description = $payment->get_description();
     $parameters->amount = $payment->get_amount();
     $parameters->return_url = $payment->get_return_url();
     $parameters->report_url = $payment->get_return_url();
     $parameters->cinfo_in_callback = 1;
     $result = $this->client->start_transaction($parameters);
     if ($result) {
         $payment->set_action_url($result->url);
         $payment->set_transaction_id($result->transaction_id);
     } else {
         $this->set_error($this->client->get_error());
     }
 }
示例#5
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $result = $this->client->create_transaction($payment->get_amount(), $payment->get_currency(), $payment->get_issuer(), $payment->get_description(), $payment->get_return_url());
     if (false !== $result) {
         $payment->set_transaction_id($result->transaction_id);
         $payment->set_action_url($result->bank_url);
     } else {
         $this->error = $this->client->get_error();
     }
 }
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $request = new Pronamic_WP_Pay_Gateways_ING_KassaCompleet_OrderRequest();
     $request->currency = $payment->get_currency();
     $request->amount = $payment->get_amount();
     $request->merchant_order_id = $payment->get_order_id();
     $request->description = $payment->get_description();
     $request->return_url = $payment->get_return_url();
     // To make the 'Test' meta box work, set payment method to iDEAL if an issuer_id has been set.
     $issuer = $payment->get_issuer();
     $payment_method = $payment->get_method();
     if (!empty($issuer)) {
         $payment_method = Pronamic_WP_Pay_PaymentMethods::IDEAL;
         $request->issuer = $issuer;
     }
     $request->method = Pronamic_WP_Pay_Gateways_ING_KassaCompleet_PaymentMethods::transform($payment_method);
     $order = $this->client->create_order($request);
     if ($order) {
         $payment->set_transaction_id($order->id);
         $payment->set_action_url($order->transactions[0]->payment_url);
     } else {
         $this->error = $this->client->get_error();
     }
 }
示例#7
0
 /**
  * Start an transaction
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     try {
         $locale = $payment->get_locale();
         $language = strtoupper(substr($locale, 0, 2));
         $country = strtoupper(substr($locale, 3, 2));
         /*
          * Order ID
          * Your unique order number.
          * This can be auto incremental number from your payments table
          *
          * Data type  = String
          * Max length = 10
          * Required   = Yes
          */
         // Payment object
         $payment_object = new Icepay_PaymentObject();
         $payment_object->setAmount(Pronamic_WP_Pay_Util::amount_to_cents($payment->get_amount()))->setCountry($country)->setLanguage($language)->setReference($payment->get_order_id())->setDescription($payment->get_description())->setCurrency($payment->get_currency())->setIssuer($payment->get_issuer())->setOrderID($payment->get_id());
         /*
          * Payment method
          * @since 1.2.0
          */
         $icepay_method = null;
         switch ($payment->get_method()) {
             case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/creditcard.php
                 $icepay_method = new Icepay_Paymentmethod_Creditcard();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ddebit.php
                 $icepay_method = new Icepay_Paymentmethod_Ddebit();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::IDEAL:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ideal.php
                 $icepay_method = new Icepay_Paymentmethod_Ideal();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
             case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/mistercash.php
                 $icepay_method = new Icepay_Paymentmethod_Mistercash();
                 break;
         }
         if (isset($icepay_method)) {
             // @see https://github.com/icepay/icepay/blob/2.4.0/api/icepay_api_base.php#L342-L353
             $payment_object->setPaymentMethod($icepay_method->getCode());
         }
         // Protocol
         $protocol = is_ssl() ? 'https' : 'http';
         // Basic mode
         $basicmode = Icepay_Basicmode::getInstance();
         $basicmode->setMerchantID($this->config->merchant_id)->setSecretCode($this->config->secret_code)->setProtocol($protocol)->validatePayment($payment_object);
         // Payment
         $payment->set_action_url($basicmode->getURL());
     } catch (Exception $exception) {
         $this->error = new WP_Error('icepay_error', $exception->getMessage(), $exception);
     }
 }
示例#8
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $order_id = $payment->get_order_id();
     $purchase_id = empty($order_id) ? $payment->get_id() : $order_id;
     // Maximum length for purchase ID is 16 characters, otherwise an error will occur:
     // ideal_sisow_error - purchaseid too long (16)
     $purchase_id = substr($purchase_id, 0, 16);
     $transaction_request = new Pronamic_WP_Pay_Gateways_Sisow_TransactionRequest();
     $transaction_request->merchant_id = $this->config->merchant_id;
     $transaction_request->shop_id = $this->config->shop_id;
     $payment_method = $payment->get_method();
     if (is_null($payment_method)) {
         $payment_method = Pronamic_WP_Pay_PaymentMethods::IDEAL;
     }
     $this->set_payment_method($payment_method);
     switch ($payment_method) {
         case Pronamic_WP_Pay_PaymentMethods::BANK_TRANSFER:
             $transaction_request->payment = Pronamic_WP_Pay_Gateways_Sisow_PaymentMethods::OVERBOEKING;
             break;
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $transaction_request->payment = Pronamic_WP_Pay_Gateways_Sisow_PaymentMethods::IDEAL;
             break;
         case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
         case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
             $transaction_request->payment = Pronamic_WP_Pay_Gateways_Sisow_PaymentMethods::MISTER_CASH;
             break;
         case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
             $transaction_request->payment = Pronamic_WP_Pay_Gateways_Sisow_PaymentMethods::CREDIT_CARD;
             break;
     }
     $transaction_request->set_purchase_id($purchase_id);
     $transaction_request->amount = $payment->get_amount();
     $transaction_request->issuer_id = $payment->get_issuer();
     $transaction_request->test_mode = Pronamic_IDeal_IDeal::MODE_TEST === $this->config->mode;
     $transaction_request->set_entrance_code($payment->get_entrance_code());
     $transaction_request->description = $payment->get_description();
     $transaction_request->billing_mail = $payment->get_email();
     $transaction_request->return_url = $payment->get_return_url();
     $transaction_request->cancel_url = $payment->get_return_url();
     $transaction_request->callback_url = $payment->get_return_url();
     $transaction_request->notify_url = $payment->get_return_url();
     $result = $this->client->create_transaction($transaction_request);
     if (false !== $result) {
         $payment->set_transaction_id($result->id);
         $payment->set_action_url($result->issuer_url);
     } else {
         $this->error = $this->client->get_error();
     }
 }
示例#9
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $result = $this->client->create_payment($payment->get_issuer(), Pronamic_WP_Util::amount_to_cents($payment->get_amount()), $payment->get_description(), $payment->get_return_url(), $payment->get_return_url());
     if (false !== $result) {
         $payment->set_transaction_id($result->transaction_id);
         $payment->set_action_url($result->url);
     } else {
         $this->error = $this->client->get_error();
     }
 }
示例#10
0
 /**
  * Start
  *
  * @param Pronamic_Pay_PaymentDataInterface $data
  * @param Pronamic_Pay_Payment              $payment
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $payment->set_action_url($this->client->get_payment_server_url());
     $payment_method = $payment->get_method();
     switch ($payment_method) {
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $this->client->set_payment_method(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::IDEAL);
             $this->client->set_ideal_issuer($payment->get_issuer());
             break;
         case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
             $this->client->add_requested_service(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::AMERICAN_EXPRESS);
             $this->client->add_requested_service(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::MAESTRO);
             $this->client->add_requested_service(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::MASTERCARD);
             $this->client->add_requested_service(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::VISA);
             break;
         case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
         case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
             $this->client->set_payment_method(Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::BANCONTACT_MISTER_CASH);
             break;
         default:
             if ('0' !== $payment_method) {
                 // Leap of faith if the WordPress payment method could not transform to a Buckaroo method?
                 $this->client->set_payment_method($payment_method);
             }
             break;
     }
     // Buckaroo uses 'nl-NL' instead of 'nl_NL'
     $culture = str_replace('_', '-', $payment->get_locale());
     $this->client->set_culture($culture);
     $this->client->set_currency($payment->get_currency());
     $this->client->set_description($payment->get_description());
     $this->client->set_amount($payment->get_amount());
     $this->client->set_invoice_number(Pronamic_WP_Pay_Gateways_Buckaroo_Util::get_invoice_number($this->client->get_invoice_number(), $payment));
     $this->client->set_return_url($payment->get_return_url());
     $this->client->set_return_cancel_url($payment->get_return_url());
     $this->client->set_return_error_url($payment->get_return_url());
     $this->client->set_return_reject_url($payment->get_return_url());
 }
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     // Purchase ID
     $purchase_id = $payment->format_string($this->config->purchase_id);
     $payment->set_meta('purchase_id', $purchase_id);
     // Transaction
     $transaction = new Pronamic_WP_Pay_Gateways_IDealAdvancedV3_Transaction();
     $transaction->set_purchase_id($purchase_id);
     $transaction->set_amount($payment->get_amount());
     $transaction->set_currency($payment->get_currency());
     $transaction->set_expiration_period('PT30M');
     $transaction->set_language($payment->get_language());
     $transaction->set_description($payment->get_description());
     $transaction->set_entrance_code($payment->get_entrance_code());
     $result = $this->client->create_transaction($transaction, $payment->get_return_url(), $payment->get_issuer());
     $error = $this->client->get_error();
     if (is_wp_error($error)) {
         $this->set_error($error);
         return;
     }
     $payment->set_action_url($result->issuer->get_authentication_url());
     $payment->set_transaction_id($result->transaction->get_id());
 }