예제 #1
0
 /**
  * Start 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());
     $ogone_data = $this->client->get_data();
     // General
     $ogone_data_general = new Pronamic_WP_Pay_Gateways_Ogone_DataGeneralHelper($ogone_data);
     $ogone_data_general->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());
     // URL's
     $ogone_url_helper = new Pronamic_WP_Pay_Gateways_Ogone_DataUrlHelper($ogone_data);
     $ogone_url_helper->set_accept_url(add_query_arg('status', Pronamic_WP_Pay_Statuses::SUCCESS, $payment->get_return_url()))->set_cancel_url(add_query_arg('status', Pronamic_WP_Pay_Statuses::CANCELLED, $payment->get_return_url()))->set_decline_url(add_query_arg('status', Pronamic_WP_Pay_Statuses::FAILURE, $payment->get_return_url()))->set_exception_url(add_query_arg('status', Pronamic_WP_Pay_Statuses::FAILURE, $payment->get_return_url()))->set_back_url(home_url('/'))->set_home_url(home_url('/'));
 }
예제 #2
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('/')));
         }
     }
 }
예제 #3
0
 /**
  * Start
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     $payment->set_action_url($this->client->get_payment_server_url());
     $ogone_data = $this->client->get_data();
     // General
     $ogone_data_general = new Pronamic_WP_Pay_Gateways_Ogone_DataGeneralHelper($ogone_data);
     $ogone_data_general->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());
     // Payment method
     // @see https://github.com/wp-pay-gateways/ogone/wiki/Brands
     switch ($payment->get_method()) {
         case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
             /*
              * Set credit card payment method.
              * @since 1.2.3
              */
             $ogone_data_general->set_payment_method(Pronamic_WP_Pay_Gateways_Ogone_PaymentMethods::CREDIT_CARD);
             break;
         case Pronamic_WP_Pay_PaymentMethods::IDEAL:
             /*
              * Set iDEAL payment method.
              * @since 1.2.3
              */
             $ogone_data_general->set_brand(Pronamic_WP_Pay_Gateways_Ogone_Brands::IDEAL)->set_payment_method(Pronamic_WP_Pay_Gateways_Ogone_PaymentMethods::IDEAL);
             break;
         case Pronamic_WP_Pay_PaymentMethods::BANCONTACT:
         case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
             $ogone_data_general->set_brand(Pronamic_WP_Pay_Gateways_Ogone_Brands::BCMC)->set_payment_method(Pronamic_WP_Pay_Gateways_Ogone_PaymentMethods::CREDIT_CARD);
             break;
     }
     // Parameter Variable
     $param_var = Pronamic_WP_Pay_Gateways_Ogone_Util::get_param_var($this->config->param_var);
     if (!empty($param_var)) {
         $ogone_data->set_field('PARAMVAR', $param_var);
     }
     // Template Page
     $template_page = $this->config->param_var;
     if (!empty($template_page)) {
         $ogone_data->set_field('TP', $template_page);
     }
     // URL's
     $ogone_url_helper = new Pronamic_WP_Pay_Gateways_Ogone_DataUrlHelper($ogone_data);
     $ogone_url_helper->set_accept_url(add_query_arg('status', 'accept', $payment->get_return_url()))->set_cancel_url(add_query_arg('status', 'cancel', $payment->get_return_url()))->set_decline_url(add_query_arg('status', 'decline', $payment->get_return_url()))->set_exception_url(add_query_arg('status', 'exception', $payment->get_return_url()));
 }
예제 #4
0
 /**
  * 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()));
 }
 /**
  * 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();
     }
 }
예제 #6
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();
     }
 }
예제 #8
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);
     }
 }
예제 #9
0
 /**
  * Status update
  */
 public function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     // Membership record transaction
     // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
     $this->pronamic_record_transaction($user_id, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $member = new M_Membership($user_id);
             if ($member) {
                 $member->create_subscription($sub_id, $this->gateway);
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }
예제 #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());
 }
예제 #11
0
 /**
  * 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());
 }
예제 #12
0
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $invoice_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', true);
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     if (Pronamic_WP_Pay_Class::method_exists('MS_Factory', 'load') && class_exists('MS_Model_Invoice')) {
         $invoice = MS_Factory::load('MS_Model_Invoice', $invoice_id);
         $gateway_id = $invoice->gateway_id;
     } else {
         // Versions prior to Membership 2 only supported the iDEAL gateway.
         $gateway_id = 'pronamic_ideal';
     }
     if (isset(self::$gateways[$gateway_id])) {
         $gateway_class = self::$gateways[$gateway_id];
         if (class_exists($gateway_class)) {
             $gateway = new $gateway_class();
         }
         // Membership record transaction
         // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
         $gateway->pronamic_record_transaction($user_id, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     }
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/class-ms-factory.php#L116-L184
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-invoice.php
             if (isset($gateway, $invoice) && !$invoice->is_paid()) {
                 $invoice->pay_it($gateway->gateway, $payment->get_id());
             }
             if (class_exists('M_Membership')) {
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->create_subscription($sub_id, $gateway->gateway);
                 }
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }