/**
  * Start an transaction with the specified data
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $payment->set_action_url($this->client->get_payment_server_url());
     // Purchase ID
     $purchase_id = $payment->format_string($this->config->purchase_id);
     $payment->set_meta('purchase_id', $purchase_id);
     // General
     $this->client->set_language($payment->get_language());
     $this->client->set_currency($payment->get_currency());
     $this->client->set_purchase_id($purchase_id);
     $this->client->set_description($payment->get_description());
     // Items
     $items = new Pronamic_WP_Pay_Gateways_IDealBasic_Items();
     $items->add_item(new Pronamic_WP_Pay_Gateways_IDealBasic_Item(1, $payment->get_description(), 1, $payment->get_amount()));
     $this->client->set_items($items);
     // URLs
     $this->client->set_cancel_url(add_query_arg('status', Pronamic_WP_Pay_Gateways_IDeal_Statuses::CANCELLED, $payment->get_return_url()));
     $this->client->set_success_url(add_query_arg('status', Pronamic_WP_Pay_Gateways_IDeal_Statuses::SUCCESS, $payment->get_return_url()));
     $this->client->set_error_url(add_query_arg('status', Pronamic_WP_Pay_Gateways_IDeal_Statuses::FAILURE, $payment->get_return_url()));
 }
Beispiel #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);
     }
 }
Beispiel #3
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  * @param Pronamic_Pay_Payment $payment
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $ogone_data = new Pronamic_WP_Pay_Gateways_Ogone_Data();
     // General
     $ogone_data_general = new Pronamic_WP_Pay_Gateways_Ogone_DataGeneralHelper($ogone_data);
     $ogone_data_general->set_psp_id($this->client->psp_id)->set_order_id($payment->format_string($this->config->order_id))->set_order_description($payment->get_description())->set_param_plus('payment_id=' . $payment->get_id())->set_currency($payment->get_currency())->set_amount($payment->get_amount())->set_language($payment->get_locale());
     // Customer
     $ogone_data_customer = new Pronamic_WP_Pay_Gateways_Ogone_DataCustomerHelper($ogone_data);
     $ogone_data_customer->set_name($payment->get_customer_name())->set_email($payment->get_email())->set_address($payment->get_address())->set_zip($payment->get_zip())->set_town($payment->get_city())->set_country($payment->get_country())->set_telephone_number($payment->get_telephone_number());
     // DirectLink
     $ogone_data_directlink = new Pronamic_WP_Pay_Gateways_Ogone_DirectLink_DataHelper($ogone_data);
     $ogone_data_directlink->set_user_id($this->client->user_id)->set_password($this->client->password);
     // Credit card
     $ogone_data_credit_card = new Pronamic_WP_Pay_Gateways_Ogone_DataCreditCardHelper($ogone_data);
     $credit_card = $payment->get_credit_card();
     $ogone_data_credit_card->set_number($credit_card->get_number())->set_expiration_date($credit_card->get_expiration_date())->set_security_code($credit_card->get_security_code());
     $ogone_data->set_field('OPERATION', 'SAL');
     // 3-D Secure
     if ($this->config->enabled_3d_secure) {
         $secure_data_helper = new Pronamic_WP_Pay_Gateways_Ogone_3DSecure_DataHelper($ogone_data);
         $secure_data_helper->set_3d_secure_flag(true)->set_http_accept(Pronamic_WP_Pay_Server::get('HTTP_ACCEPT'))->set_http_user_agent(Pronamic_WP_Pay_Server::get('HTTP_USER_AGENT'))->set_window('MAINW');
         $ogone_data->set_field('ACCEPTURL', $payment->get_return_url());
         $ogone_data->set_field('DECLINEURL', $payment->get_return_url());
         $ogone_data->set_field('EXCEPTIONURL', $payment->get_return_url());
         $ogone_data->set_field('COMPLUS', '');
     }
     // Signature
     $calculation_fields = Pronamic_WP_Pay_Gateways_Ogone_Security::get_calculations_parameters_in();
     $fields = Pronamic_WP_Pay_Gateways_Ogone_Security::get_calculation_fields($calculation_fields, $ogone_data->get_fields());
     $signature = Pronamic_WP_Pay_Gateways_Ogone_Security::get_signature($fields, $this->config->sha_in_pass_phrase, $this->config->hash_algorithm);
     $ogone_data->set_field('SHASIGN', $signature);
     // Order
     $result = $this->client->order_direct($ogone_data->get_fields());
     $error = $this->client->get_error();
     if (is_wp_error($error)) {
         $this->error = $error;
     } else {
         $payment->set_transaction_id($result->pay_id);
         $payment->set_action_url($payment->get_return_url());
         $payment->set_status(Pronamic_WP_Pay_Gateways_Ogone_Statuses::transform($result->status));
         if (!empty($result->html_answer)) {
             $payment->set_meta('ogone_directlink_html_answer', $result->html_answer);
             $payment->set_action_url(add_query_arg('payment_redirect', $payment->get_id(), home_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());
 }
Beispiel #5
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  * @param Pronamic_Pay_PaymentDataInterface $data
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $transaction_reference = $payment->get_meta('omnikassa_transaction_reference');
     if (empty($transaction_reference)) {
         $transaction_reference = md5(uniqid('', true));
         $payment->set_meta('omnikassa_transaction_reference', $transaction_reference);
     }
     $payment->set_action_url($this->client->get_action_url());
     $this->client->set_customer_language(Pronamic_WP_Pay_Gateways_OmniKassa_LocaleHelper::transform($payment->get_language()));
     $this->client->set_currency_numeric_code($payment->get_currency_numeric_code());
     $this->client->set_order_id($payment->format_string($this->config->order_id));
     $this->client->set_normal_return_url(home_url('/'));
     $this->client->set_automatic_response_url(home_url('/'));
     $this->client->set_amount($payment->get_amount());
     $this->client->set_transaction_reference($transaction_reference);
     switch ($payment->get_method()) {
         /*
          * If this field is not supplied in the payment request, then
          * by default the customer will be redirected to the Rabo
          * OmniKassa payment page. On the payment page, the
          * customer can choose from the payment methods
          * offered by the Rabo OmniKassa. These are the payment
          * methods: IDEAL, VISA, MASTERCARD,
          * MAESTRO, V PAY and BCMC.
          *
          * Exception: the register services INCASSO (direct debit),
          * ACCEPTGIRO (giro collection form) and REMBOURS
          * (cash on delivery) are not displayed on the Rabo
          * OmniKassa payment page by default.
          * If you wish to offer these register services to the
          * customer on the payment page, then you need to
          * always populate the paymentMeanBrandList field with
          * all the payment methods you wish to offer (provided
          * these have been requested and activated): IDEAL,
          * VISA, MASTERCARD, MAESTRO, VPAY, BCMC,
          * INCASSO, ACCEPTGIRO, REMBOURS.
          *
          * If you let the customer choose the payment method
          * while still in your webshop, then you must populate
          * this field of the payment request with only the selected
          * payment method. Populating this field with only one
          * payment method will instruct the Rabo OmniKassa to
          * redirect the customer directly to the payment page for
          * this payment method.
          */
         case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
         case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::BCMC);
             break;
         case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::MAESTRO);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::MASTERCARD);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::VISA);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::VPAY);
             break;
         case Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::INCASSO);
             break;
         case Pronamic_WP_Pay_PaymentMethods::MAESTRO:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::MAESTRO);
             break;
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::IDEAL);
             break;
         default:
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::IDEAL);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::VISA);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::MASTERCARD);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::MAESTRO);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::VPAY);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::BCMC);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::INCASSO);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::ACCEPTGIRO);
             $this->client->add_payment_mean_brand(Pronamic_WP_Pay_Gateways_OmniKassa_PaymentMethods::REMBOURS);
             break;
     }
 }