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); } } } }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
/** * 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; }