/**
  * Get document
  *
  * @see Pronamic_Gateways_IDealAdvancedV3_XML_RequestMessage::get_document()
  */
 public function get_document()
 {
     $document = parent::get_document();
     // Root
     $root = $document->documentElement;
     // Merchant
     $merchant = $this->merchant;
     $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'merchant');
     Pronamic_WP_Pay_XML_Util::add_elements($document, $element, array('account' => $merchant->account, 'site_id' => $merchant->site_id, 'site_secure_code' => $merchant->site_secure_code, 'notification_url' => $merchant->notification_url, 'redirect_url' => $merchant->redirect_url, 'cancel_url' => $merchant->cancel_url, 'close_window' => $merchant->close_window));
     // Customer
     $customer = $this->customer;
     $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'customer');
     Pronamic_WP_Pay_XML_Util::add_elements($document, $element, array('locale' => $customer->locale, 'ipaddress' => $customer->ip_address, 'forwardedip' => $customer->forwarded_ip, 'firstname' => $customer->first_name, 'lastname' => $customer->last_name, 'address1' => $customer->address_1, 'address2' => $customer->address_2, 'housenumber' => $customer->house_number, 'zipcode' => $customer->zip_code, 'city' => $customer->city, 'country' => $customer->country, 'phone' => $customer->phone, 'email' => $customer->email));
     // Transaction
     $transaction = $this->transaction;
     $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'transaction');
     Pronamic_WP_Pay_XML_Util::add_elements($document, $element, array('id' => $transaction->id, 'currency' => $transaction->currency, 'amount' => Pronamic_WP_Pay_Util::amount_to_cents($transaction->amount), 'description' => $transaction->description, 'var1' => $transaction->var1, 'var2' => $transaction->var2, 'var3' => $transaction->var3, 'items' => $transaction->items, 'manual' => $transaction->manual, 'gateway' => $transaction->gateway, 'daysactive' => $transaction->days_active));
     // Gateway info
     if ($this->gateway_info) {
         $gateway_info = $this->gateway_info;
         $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'gatewayinfo');
         Pronamic_WP_Pay_XML_Util::add_elements($document, $element, array('issuerid' => $gateway_info->issuer_id));
     }
     // Signature
     $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'signature', $this->signature);
     return $document;
 }
 /**
  * Constructs and initialize an MultiSafepay Connect merchant object
  */
 public static function generate($amount, $currency, $account, $site_id, $transaction_id)
 {
     $values = array(Pronamic_WP_Pay_Util::amount_to_cents($amount), $currency, $account, $site_id, $transaction_id);
     $string = implode('', $values);
     $signature = md5($string);
     return $signature;
 }
Exemple #3
0
 /**
  * Start an transaction
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_PaymentDataInterface $data, Pronamic_Pay_Payment $payment, $payment_method = null)
 {
     try {
         $locale = $data->get_language_and_country();
         $language = substr($locale, 0, 2);
         $country = 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($data->get_amount()))->setCountry($country)->setLanguage($language)->setReference($data->get_order_id())->setDescription($data->get_description())->setCurrency($data->get_currency())->setIssuer($data->get_issuer_id())->setOrderID($payment->get_id());
         // Payment method
         // @since 1.2.0
         $icepay_method = null;
         switch ($payment_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::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);
     }
 }
 public function get_array()
 {
     $array = array('amount' => Pronamic_WP_Pay_Util::amount_to_cents($this->amount), 'currency' => $this->currency, 'description' => $this->description, 'return_url' => $this->return_url, 'transactions' => array());
     // Array filter will remove values NULL, FALSE and empty strings ('')
     $array = array_filter($array);
     // Add payment method
     $payment_method = array('payment_method' => $this->method);
     // Add payment method details
     switch ($this->method) {
         case Pronamic_WP_Pay_Gateways_ING_KassaCompleet_PaymentMethods::IDEAL:
             $payment_method['payment_method_details'] = array('issuer_id' => $this->issuer);
             break;
     }
     $array['transactions'] = array($payment_method);
     return $array;
 }
 /**
  * Set amount
  *
  * @param float $amount
  * @return Pronamic_WP_Pay_Gateways_Ogone_DataGeneralHelper
  */
 public function set_amount($amount)
 {
     return $this->set_field('AMOUNT', Pronamic_WP_Pay_Util::amount_to_cents($amount));
 }
Exemple #6
0
 /**
  * Get the iDEAL HTML
  *
  * @since 1.1.1
  * @return array
  */
 public function get_fields()
 {
     $fields = array();
     $fields['merchantID'] = $this->get_merchant_id();
     $fields['subID'] = $this->get_sub_id();
     $fields['amount'] = Pronamic_WP_Pay_Util::amount_to_cents($this->get_amount());
     $fields['purchaseID'] = $this->get_purchase_id();
     $fields['language'] = $this->get_language();
     $fields['currency'] = $this->get_currency();
     $fields['description'] = $this->get_description();
     $fields['hash'] = $this->create_hash();
     $fields['paymentType'] = $this->get_payment_type();
     $fields['validUntil'] = $this->get_expire_date()->format($this->get_expire_date_format());
     $serial_number = 1;
     foreach ($this->get_items() as $item) {
         $fields['itemNumber' . $serial_number] = $item->get_number();
         $fields['itemDescription' . $serial_number] = $item->get_description();
         $fields['itemQuantity' . $serial_number] = $item->get_quantity();
         $fields['itemPrice' . $serial_number] = Pronamic_WP_Util::amount_to_cents($item->get_price());
         $serial_number++;
     }
     $fields['urlCancel'] = $this->get_cancel_url();
     $fields['urlSuccess'] = $this->get_success_url();
     $fields['urlError'] = $this->get_error_url();
     return $fields;
 }
Exemple #7
0
 /**
  * Get formmated amount
  *
  * @return int
  */
 public function get_formatted_amount()
 {
     return Pronamic_WP_Pay_Util::amount_to_cents($this->amount);
 }
 /**
  * Get parameters
  *
  * @return array
  */
 public function get_parameters($merchant_key)
 {
     return array('shopid' => $this->shop_id, 'merchantid' => $this->merchant_id, 'payment' => $this->payment, 'purchaseid' => $this->purchase_id, 'amount' => Pronamic_WP_Pay_Util::amount_to_cents($this->amount), 'issuerid' => $this->issuer_id, 'testmode' => Pronamic_WP_Pay_Util::to_string_boolean($this->test_mode), 'entrancecode' => $this->entrance_code, 'description' => $this->description, 'returnurl' => $this->return_url, 'cancelurl' => $this->cancel_url, 'callbackurl' => $this->callback_url, 'notifyurl' => $this->notify_url, 'sha1' => $this->get_sha1($merchant_key));
 }
 /**
  * Get array
  *
  * @rerturn array
  */
 public function get_array()
 {
     return array('rtlo' => $this->rtlo, 'description' => $this->description, 'amount' => Pronamic_WP_Pay_Util::amount_to_cents($this->amount), 'country' => $this->country, 'lang' => $this->language, 'returnurl' => $this->return_url, 'reporturl' => $this->report_url);
 }
 /**
  * When the post is saved, saves our custom data.
  *
  * @param int $post_id The ID of the post being saved.
  */
 public function save_post($post_id)
 {
     // Check if our nonce is set.
     if (!filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         return $post_id;
     }
     $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'pronamic_pay_save_form_options')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* OK, its safe for us to save the data now. */
     $definition = array('_pronamic_payment_form_config_id' => FILTER_SANITIZE_NUMBER_INT, '_pronamic_payment_form_button_text' => FILTER_SANITIZE_STRING, '_pronamic_payment_form_amount_method' => FILTER_SANITIZE_STRING, '_pronamic_payment_form_amount_choices' => array('flags' => FILTER_REQUIRE_ARRAY));
     $data = filter_input_array(INPUT_POST, $definition);
     // Convert amount choices to cents
     if (isset($data['_pronamic_payment_form_amount_choices'])) {
         foreach ($data['_pronamic_payment_form_amount_choices'] as $i => $amount) {
             $amount = Pronamic_WP_Pay_Util::string_to_amount($amount);
             $data['_pronamic_payment_form_amount_choices'][$i] = Pronamic_WP_Pay_Util::amount_to_cents($amount);
         }
         // Remove empty choices
         $data['_pronamic_payment_form_amount_choices'] = array_filter($data['_pronamic_payment_form_amount_choices']);
     }
     // Update post meta data
     pronamic_pay_update_post_meta_data($post_id, $data);
 }