/** * 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; }
/** * Get array * * @rerturn array */ public function get_array() { $array = parent::get_array(); $array['bank'] = $this->bank; $array['cinfo_in_callback'] = Pronamic_WP_Pay_Util::to_numeric_boolean($this->cinfo_in_callback); return $array; }
/** * 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; }
/** * Get items * * @see Pronamic_Pay_PaymentDataInterface::get_items() * @return Pronamic_IDeal_Items */ public function get_items() { // Items $items = new Pronamic_IDeal_Items(); // Amount $amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator()))); // Get correct amount if pronamic_pay_amount is an array if (!$amount && ($amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY))) { // Array filter will remove values NULL, FALSE and empty strings ('') $amount = array_filter($amount); // Make sure the amount has the correct floating value foreach ($amount as $key => $value) { if ('other' !== $key) { $amount[$key] = $value / 100; } } // Get first element of the array $amount = array_shift($amount); } $amount = Pronamic_WP_Pay_Util::string_to_amount($amount); // Item $item = new Pronamic_IDeal_Item(); $item->setNumber($this->get_order_id()); $item->setDescription(sprintf(__('Payment %s', 'pronamic_ideal'), $this->get_order_id())); $item->setPrice($amount); $item->setQuantity(1); $items->addItem($item); return $items; }
/** * Get document * * @see Pronamic_Gateways_IDealAdvanced_XML_RequestMessage::getDocument() */ public function get_document() { $document = parent::get_document(); // Retrieve Bank List $element = self::add_element($document, $document->documentElement, 'retrievebanklist'); self::add_elements($document, $element, array('methodcode' => $this->method_code, 'test' => Pronamic_WP_Pay_Util::to_string_boolean($this->test))); // Return return $document; }
/** * Get document * * @see Pronamic_Gateways_IDealAdvanced_XML_RequestMessage::getDocument() */ public function get_document() { $document = parent::get_document(); // Transaction request $element = self::add_element($document, $document->documentElement, 'merchant'); self::add_elements($document, $element, array('username' => $this->merchant->username, 'password' => $this->merchant->password, 'reference' => $this->merchant->reference, 'test' => Pronamic_WP_Pay_Util::to_string_boolean($this->merchant->test))); // Return return $document; }
/** * Get document * * @see Pronamic_Gateways_IDealAdvanced_XML_RequestMessage::getDocument() */ public function get_document() { $document = parent::get_document(); // Transaction request $element = self::add_element($document, $document->documentElement, 'transactionreq'); self::add_elements($document, $element, array('username' => $this->transaction_request->username, 'password' => $this->transaction_request->password, 'reference' => $this->transaction_request->reference, 'description' => $this->transaction_request->description, 'amount' => Pronamic_WP_Pay_Gateways_PayDutch_Client::format_amount($this->transaction_request->amount), 'methodcode' => $this->transaction_request->method_code, 'issuerid' => $this->transaction_request->issuer_id, 'test' => Pronamic_WP_Pay_Util::to_string_boolean($this->transaction_request->test), 'successurl' => $this->transaction_request->success_url, 'failurl' => $this->transaction_request->fail_url)); // Return return $document; }
/** * 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); } }
private function request($message) { $return = false; $result = Pronamic_WP_Pay_Util::remote_get_body($this->api_url, 200, array('method' => 'POST', 'body' => (string) $message)); if (is_wp_error($result)) { $this->error = $result; } else { $xml = Pronamic_WP_Pay_Util::simplexml_load_string($result); if (is_wp_error($xml)) { $this->error = $xml; } else { $return = $this->parse_xml($xml); } } return $return; }
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; }
private function request($message) { $return = false; $result = Pronamic_WP_Pay_Util::remote_get_body($this->api_url, 200, array('method' => 'POST', 'body' => (string) $message)); if (is_wp_error($result)) { $this->error = $result; return false; } $xml = Pronamic_WP_Pay_Util::simplexml_load_string($result); if (is_wp_error($xml)) { $this->error = $xml; } else { $return = $this->parse_xml($xml); if (is_object($return) && isset($return->result) && 'error' === $return->result) { $this->error = new WP_Error('multisafepay_error', $xml->error->description, $xml->error); $return = false; } } return $return; }
/** * Order direct * * @param array $data */ public function order_direct(array $data = array()) { $order_response = false; $result = Pronamic_WP_Pay_Util::remote_get_body($this->api_url, 200, array('method' => 'POST', 'sslverify' => false, 'body' => $data)); if (is_wp_error($result)) { $this->error = $result; } else { $xml = Pronamic_WP_Pay_Util::simplexml_load_string($result); if (is_wp_error($xml)) { $this->error = $xml; } else { $order_response = Pronamic_WP_Pay_Gateways_Ogone_OrderResponseParser::parse($xml); if (!empty($order_response->nc_error)) { $ogone_error = new Pronamic_WP_Pay_Gateways_Ogone_Error(Pronamic_WP_Pay_XML_Security::filter($order_response->nc_error), Pronamic_WP_Pay_XML_Security::filter($order_response->nc_error_plus)); $this->error = new WP_Error('ogone_error', (string) $ogone_error, $ogone_error); } } } return $order_response; }
/** * Get the input HTML * * This function will convert all input fields to an HTML notation * * @return string */ public function get_input_html() { $fields = $this->get_input_fields(); return Pronamic_WP_Pay_Util::input_fields_html($fields); }
/** * 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)); }
/** * Send an specific request message to an specific URL * * @param string $url * @param Pronamic_WP_Pay_Gateways_IDealAdvancedV3_XML_RequestMessage $message * * @return Pronamic_WP_Pay_Gateways_IDealAdvancedV3_XML_ResponseMessage */ private function send_message($url, Pronamic_WP_Pay_Gateways_IDealAdvancedV3_XML_RequestMessage $message) { $result = false; // Sign $document = $message->get_document(); $document = $this->sign_document($document); if (false !== $document) { // Stringify $data = $document->saveXML(); // Remote post $response = wp_remote_post($url, array('method' => 'POST', 'headers' => array('Content-Type' => 'text/xml; charset=' . Pronamic_WP_Pay_Gateways_IDealAdvancedV3_XML_Message::XML_ENCODING), 'body' => $data)); // Handle response if (!is_wp_error($response)) { if (200 === wp_remote_retrieve_response_code($response)) { $body = wp_remote_retrieve_body($response); $xml = Pronamic_WP_Pay_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')); } } else { $this->error = $response; } } return $result; }
/** * Get order status */ public function get_order_status($order_id) { $return = null; // API user ID and password $user_id = $this->get_user_id(); $password = $this->get_password(); if ('' === $user_id || '' === $password) { return $return; } $result = Pronamic_WP_Pay_Util::remote_get_body($this->get_direct_query_url(), 200, array('method' => 'POST', 'body' => array(Pronamic_WP_Pay_Gateways_Ogone_Parameters::ORDERID => $order_id, Pronamic_WP_Pay_Gateways_Ogone_Parameters::PSPID => $this->data->get_field(Pronamic_WP_Pay_Gateways_Ogone_Parameters::PSPID), Pronamic_WP_Pay_Gateways_Ogone_Parameters::USER_ID => $user_id, Pronamic_WP_Pay_Gateways_Ogone_Parameters::PASSWORD => $password), 'timeout' => 30)); $xml = Pronamic_WP_Pay_Util::simplexml_load_string($result); if (!is_wp_error($xml)) { $order_response = Pronamic_WP_Pay_Gateways_Ogone_OrderResponseParser::parse($xml); $status = Pronamic_WP_Pay_XML_Security::filter($order_response->status); $return = Pronamic_WP_Pay_Gateways_Ogone_Statuses::transform($status); } return $return; }
/** * 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); }
/** * Get the status of the specified transaction ID * * @param string $transaction_id * @return boolean|Pronamic_WP_Pay_Gateways_Sisow_Transaction */ public function get_status($transaction_id) { $status = false; // Parameters $parameters = array('merchantid' => $this->merchant_id, 'trxid' => $transaction_id, 'sha1' => self::create_status_sha1($transaction_id, '', $this->merchant_id, $this->merchant_key)); // Request $result = $this->send_request(Pronamic_WP_Pay_Gateways_Sisow_Methods::STATUS_REQUEST, $parameters); if (is_wp_error($result)) { $this->error = $result; return $status; } // XML $xml = Pronamic_WP_Pay_Util::simplexml_load_string($result); if (is_wp_error($xml)) { $this->error = $xml; return $status; } // Parse if ($xml instanceof SimpleXMLElement) { $status = $this->parse_document($xml); return $status; } // Return return $status; }
/** * 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; }
/** * 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)); }
/** * 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); }