示例#1
0
 /**
  * Start
  *
  * @param Pronamic_Pay_PaymentDataInterface $data
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_PaymentDataInterface $data, Pronamic_Pay_Payment $payment, $payment_method = null)
 {
     $result = $this->client->create_payment($data->get_issuer_id(), Pronamic_WP_Util::amount_to_cents($data->get_amount()), $data->get_description(), add_query_arg('payment', $payment->get_id(), home_url('/')), add_query_arg('payment', $payment->get_id(), home_url('/')));
     if (false !== $result) {
         $payment->set_transaction_id($result->transaction_id);
         $payment->set_action_url($result->url);
     } else {
         $this->error = $this->client->get_error();
     }
 }
示例#2
0
 public static function listen()
 {
     // Also check for typo 'xml_notifaction', as this has been used in the past.
     if (filter_has_var(INPUT_GET, 'xml_notification') || filter_has_var(INPUT_GET, 'xml_notifaction')) {
         $data = file_get_contents('php://input');
         $xml = Pronamic_WP_Util::simplexml_load_string($data);
         if (!is_wp_error($xml)) {
             $notification = Pronamic_WP_Pay_Gateways_IDealBasic_XML_NotificationParser::parse($xml);
             $purchase_id = $notification->get_purchase_id();
             $payment = get_pronamic_payment_by_meta('_pronamic_payment_purchase_id', $purchase_id);
             if ($payment) {
                 $payment->set_transaction_id($notification->get_transaction_id());
                 $payment->set_status($notification->get_status());
                 Pronamic_WP_Pay_Plugin::update_payment($payment);
             }
         }
     }
 }
 public static function parse(SimpleXMLElement $xml)
 {
     $transaction = new Pronamic_WP_Pay_Gateways_Sisow_Transaction();
     // Transaction request
     if (isset($xml->trxid)) {
         $transaction->id = Pronamic_WP_Pay_XML_Security::filter($xml->trxid);
     }
     if (isset($xml->issuerurl)) {
         $transaction->issuer_url = urldecode(Pronamic_WP_Pay_XML_Security::filter($xml->issuerurl));
     }
     // Status response
     if (isset($xml->status)) {
         $transaction->status = Pronamic_WP_Pay_XML_Security::filter($xml->status);
     }
     if (isset($xml->amount)) {
         $transaction->amount = Pronamic_WP_Util::cents_to_amount(Pronamic_WP_Pay_XML_Security::filter($xml->amount));
     }
     if (isset($xml->purchaseid)) {
         $transaction->purchase_id = Pronamic_WP_Pay_XML_Security::filter($xml->purchaseid);
     }
     if (isset($xml->description)) {
         $transaction->description = Pronamic_WP_Pay_XML_Security::filter($xml->description);
     }
     if (isset($xml->entrancecode)) {
         $transaction->entrance_code = Pronamic_WP_Pay_XML_Security::filter($xml->entrancecode);
     }
     if (isset($xml->issuerid)) {
         $transaction->issuer_id = Pronamic_WP_Pay_XML_Security::filter($xml->issuerid);
     }
     if (isset($xml->timestamp)) {
         $transaction->timestamp = new DateTime(Pronamic_WP_Pay_XML_Security::filter($xml->timestamp));
     }
     if (isset($xml->consumername)) {
         $transaction->consumer_name = Pronamic_WP_Pay_XML_Security::filter($xml->consumername);
     }
     if (isset($xml->consumeraccount)) {
         $transaction->consumer_account = Pronamic_WP_Pay_XML_Security::filter($xml->consumeraccount);
     }
     if (isset($xml->consumercity)) {
         $transaction->consumer_city = Pronamic_WP_Pay_XML_Security::filter($xml->consumercity);
     }
     return $transaction;
 }
 /**
  * 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_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));
     // Signature
     $element = Pronamic_WP_Pay_XML_Util::add_element($document, $document->documentElement, 'signature', $this->signature);
     return $document;
 }
示例#5
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;
 }
示例#6
0
 /**
  * Transaction start
  *
  * @param float $amount
  * @param string $ip_address
  * @param string $finish_url
  * @return stdClass
  *
  * @see https://admin.pay.nl/docpanel/api/Transaction/start/4
  */
 public function transaction_start($amount, $ip_address, $finish_url)
 {
     $result = null;
     // URL
     $url = $this->get_url('v4', 'Transaction', 'start', 'json', array('token' => $this->token, 'serviceId' => $this->service_id, 'amount' => Pronamic_WP_Util::amount_to_cents($amount), 'ipAddress' => $ip_address, 'finishUrl' => $finish_url));
     // Request
     $response = wp_remote_get($url);
     if (200 == wp_remote_retrieve_response_code($response)) {
         $body = wp_remote_retrieve_body($response);
         $data = json_decode($body);
         $result = $this->parse_response($data);
     }
     // Return
     return $result;
 }
示例#7
0
 public function get_payment_status($reference)
 {
     $result = null;
     $merchant = new Pronamic_WP_Pay_Gateways_PayDutch_Merchant($this->username, $this->password);
     $merchant->reference = $reference;
     $merchant->test = $this->test;
     $message = new Pronamic_WP_Pay_Gateways_PayDutch_XML_QueryRequestMessage($merchant);
     $result = $this->request($message);
     if (is_wp_error($result)) {
         $this->error = $result;
     } else {
         $xml = Pronamic_WP_Util::simplexml_load_string($result);
         if (is_wp_error($xml)) {
             $this->error = $xml;
         } else {
             $result = Pronamic_WP_Pay_Gateways_PayDutch_XML_PaymentInfoParser::parse($xml->paymentinfo);
         }
     }
     return $result;
 }
示例#8
0
 /**
  * Create transaction.
  *
  * @since 1.0.0
  * @version 1.0.5
  */
 public function create_transaction($amount, $currency, $bank_id, $description, $return_url)
 {
     $result = false;
     $parameters = array('Amount' => number_format($amount, 2, '.', ''), 'Currency' => $currency, 'Bank' => $bank_id, 'Description' => substr($description, 0, 30), 'Return' => $return_url);
     $document = $this->get_document(Pronamic_WP_Pay_Gateways_Qantani_Actions::IDEAL_EXECUTE, $parameters);
     $response = $this->send_request($document->saveXML());
     if (is_wp_error($response)) {
         $this->error = $response;
     } else {
         $xml = Pronamic_WP_Util::simplexml_load_string($response);
         if (is_wp_error($xml)) {
             $this->error = $xml;
         } else {
             if (Pronamic_WP_Pay_Gateways_Qantani_ResponseStatuses::OK === Pronamic_WP_Pay_XML_Security::filter($xml->Status)) {
                 $xml_response = $xml->Response;
                 $result = new stdClass();
                 $result->transaction_id = Pronamic_WP_Pay_XML_Security::filter($xml_response->TransactionID);
                 $result->code = Pronamic_WP_Pay_XML_Security::filter($xml_response->Code);
                 $result->bank_url = Pronamic_WP_Pay_XML_Security::filter($xml_response->BankURL);
                 $result->acquirer = Pronamic_WP_Pay_XML_Security::filter($xml_response->Acquirer);
             } else {
                 $error_id = Pronamic_WP_Pay_XML_Security::filter($xml->Error->ID);
                 $error_description = Pronamic_WP_Pay_XML_Security::filter($xml->Error->Description);
                 $error = new Pronamic_WP_Pay_Gateways_Qantani_Error($error_id, $error_description);
                 $this->error = new WP_Error('qantani_error', (string) $error, $error);
             }
         }
     }
     return $result;
 }
示例#9
0
 /**
  * Check payment with the specified transaction ID
  *
  * @param string $transaction_id
  * @return stdClass
  */
 public function check_payment($transaction_id)
 {
     $result = false;
     $parameters = array('transaction_id' => $transaction_id);
     $result = $this->send_request(Pronamic_WP_Pay_Gateways_Mollie_IDeal_Actions::CHECK, $parameters);
     if (false !== $result) {
         $xml = Pronamic_WP_Util::simplexml_load_string($result);
         if (is_wp_error($xml)) {
             $this->error = $xml;
         } else {
             $order = new stdClass();
             $order->transaction_id = Pronamic_WP_Pay_XML_Security::filter($xml->order->transaction_id);
             $order->amount = Pronamic_WP_Pay_XML_Security::filter($xml->order->amount);
             $order->currency = Pronamic_WP_Pay_XML_Security::filter($xml->order->currency);
             $order->payed = Pronamic_WP_Pay_XML_Security::filter($xml->order->payed, FILTER_VALIDATE_BOOLEAN);
             $order->status = Pronamic_WP_Pay_XML_Security::filter($xml->order->status);
             $order->consumer = new stdClass();
             $order->consumer->name = Pronamic_WP_Pay_XML_Security::filter($xml->order->consumer->consumerName);
             $order->consumer->account = Pronamic_WP_Pay_XML_Security::filter($xml->order->consumer->consumerAccount);
             $order->consumer->city = Pronamic_WP_Pay_XML_Security::filter($xml->order->consumer->consumerCity);
             $result = $order;
         }
     }
     return $result;
 }
示例#10
0
 /**
  * Get HTML fields
  *
  * @return string
  */
 public function get_html_fields()
 {
     return Pronamic_IDeal_IDeal::htmlHiddenFields(array(Pronamic_Gateways_Adyen_Parameters::MERCHANT_REFERENCE => $this->get_merchant_reference(), Pronamic_Gateways_Adyen_Parameters::PAYMENT_AMOUNT => Pronamic_WP_Util::amount_to_cents($this->get_payment_amount()), Pronamic_Gateways_Adyen_Parameters::CURRENCY_CODE => $this->get_currency_code(), Pronamic_Gateways_Adyen_Parameters::SHIP_BEFORE_DATE => Pronamic_WP_Util::format_date('Y-m-d', $this->get_ship_before_date()), Pronamic_Gateways_Adyen_Parameters::SKIN_CODE => $this->get_skin_code(), Pronamic_Gateways_Adyen_Parameters::MERCHANT_ACCOUNT => $this->get_merchant_account(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_LOCALE => $this->get_shopper_locale(), Pronamic_Gateways_Adyen_Parameters::ORDER_DATA => base64_encode(gzencode($this->get_order_data())), Pronamic_Gateways_Adyen_Parameters::SESSION_VALIDITY => Pronamic_WP_Util::format_date(DATE_ATOM, $this->get_session_validity()), Pronamic_Gateways_Adyen_Parameters::MERCHANT_SIGNATURE => $this->get_signature(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_EMAIL => $this->get_shopper_email(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_REFERENCE => $this->get_shopper_reference()));
 }
示例#11
0
 /**
  * Start transaction
  *
  * @param Pronamic_WP_Pay_Gateways_TargetPay_Sofort_StartParameters $parameters
  */
 public function start_transaction(Pronamic_WP_Pay_Gateways_TargetPay_SofortStartParameters $parameters)
 {
     $url = Pronamic_WP_Util::build_url(self::URL_START_TRANSACTION, (array) $parameters);
     $data = self::remote_get($url);
     // @todo need work
 }
 /**
  * Get the sign values for this transaction request message
  *
  * @return array
  */
 public function getSignValues()
 {
     return array($this->getCreateDate()->format(Pronamic_IDeal_IDeal::DATE_FORMAT), $this->issuer->getId(), $this->getMerchant()->id, $this->getMerchant()->subId, $this->getMerchant()->returnUrl, $this->transaction->getPurchaseId(), Pronamic_WP_Util::amount_to_cents($this->transaction->get_amount()), $this->transaction->getCurrency(), $this->transaction->getLanguage(), $this->transaction->get_description(), $this->transaction->getEntranceCode());
 }
示例#13
0
 /**
  * Send an message
  */
 private function send_message($url, $message)
 {
     $result = false;
     // Sign
     $message->sign($this->privateKey, $this->privateKeyPassword);
     // Stringify
     $data = (string) $message;
     // Remote post
     $response = wp_remote_post($url, array('method' => 'POST', 'headers' => array('Content-Type' => 'text/xml; charset=' . Pronamic_WP_Pay_Gateways_IDealAdvanced_XML_Message::XML_ENCODING), 'body' => $data));
     // Handle response
     if (is_wp_error($response)) {
         $this->error = $response;
     } else {
         if (200 === wp_remote_retrieve_response_code($response)) {
             $body = wp_remote_retrieve_body($response);
             $xml = Pronamic_WP_Util::simplexml_load_string($body);
             if (is_wp_error($xml)) {
                 $this->error = $xml;
             } else {
                 $document = self::parse_document($xml);
                 if (is_wp_error($document)) {
                     $this->error = $document;
                 } else {
                     $result = $document;
                 }
             }
         } else {
             $this->error = new WP_Error('wrong_response_code', __('The response code (<code>%s<code>) from the iDEAL provider was incorrect.', 'pronamic_ideal'));
         }
     }
     return $result;
 }
示例#14
0
 public function test_to_string_boolean()
 {
     $boolean = false;
     $result = Pronamic_WP_Util::to_string_boolean($boolean);
     $this->assertEquals('false', $result);
 }
示例#15
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();
     }
 }
示例#16
0
 /**
  * Get issuers
  *
  * @return array
  */
 public function get_issuers()
 {
     $issuers = false;
     $url = self::URL_ISSUERS_XML;
     $data = self::remote_get($url);
     if (false !== $data) {
         $xml = Pronamic_WP_Util::simplexml_load_string($data);
         if (is_wp_error($xml)) {
             $this->error = $xml;
         } else {
             $issuers = array();
             foreach ($xml->issuer as $xml_issuer) {
                 $id = Pronamic_WP_Pay_XML_Security::filter($xml_issuer['id']);
                 $name = Pronamic_WP_Pay_XML_Security::filter($xml_issuer);
                 $issuers[$id] = $name;
             }
         }
     }
     return $issuers;
 }
示例#17
0
 /**
  * Transaction start
  *
  * @param float $amount
  * @param string $ip_address
  * @param string $finish_url
  * @return stdClass
  *
  * @see https://admin.pay.nl/docpanel/api/Transaction/start/4
  */
 public function transaction_start($amount, $ip_address, $finish_url, $request_param = array())
 {
     $parameters = array_merge($request_param, array('token' => $this->token, 'serviceId' => $this->service_id, 'amount' => Pronamic_WP_Util::amount_to_cents($amount), 'ipAddress' => $ip_address, 'finishUrl' => $finish_url));
     // Request
     $result = $this->send_request('v4', 'Transaction', 'start', 'json', $parameters);
     // Return result
     return $result;
 }