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