コード例 #1
0
 /**
  * Get order ID.
  *
  * @param string                            $order_id
  * @param Pronamic_Pay_PaymentDataInterface $data
  * @param Pronamic_Pay_Payment              $payment
  */
 public static function get_order_id($order_id, Pronamic_Pay_Payment $payment)
 {
     // Replacements definition
     $replacements = array('{order_id}' => $payment->get_order_id(), '{payment_id}' => $payment->get_id());
     // Find and replace
     $order_id = str_replace(array_keys($replacements), array_values($replacements), $order_id, $count);
     // Make sure there is an dynamic part in the order ID
     if (0 === $count) {
         $order_id .= $payment->get_order_id();
     }
     return $order_id;
 }
コード例 #2
0
ファイル: Gateway.php プロジェクト: wp-pay-gateways/sisow
 /**
  * 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();
     }
 }
コード例 #3
0
 /**
  * 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();
     }
 }
コード例 #4
0
ファイル: Gateway.php プロジェクト: wp-pay-gateways/icepay
 /**
  * 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);
     }
 }