Failed Conditions
Push — develop ( 9cc0c5...5590ec )
by Reüel
03:35
created

src/XML/OrderResponseParser.php (1 issue)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Ingenico\XML;
4
5
use Pronamic\WordPress\Pay\Core\XML\Security;
6
use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink\OrderResponse;
7
use Pronamic\WordPress\Pay\Gateways\Ingenico\Parameters;
8
use SimpleXMLElement;
9
10
/**
11
 * Title: Ingenico DirectLink order response XML parser
12
 * Description:
13
 * Copyright: 2005-2019 Pronamic
14
 * Company: Pronamic
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.0.0
18
 */
19
class OrderResponseParser {
20
	/**
21
	 * Parse the specified XML element into an iDEAL transaction object
22
	 *
23
	 * @param SimpleXMLElement $xml
24
	 * @param OrderResponse    $order_response
25
	 *
26
	 * @return null|OrderResponse
27
	 */
28 3
	public static function parse( SimpleXMLElement $xml, $order_response = null ) {
29 3
		if ( ! $order_response instanceof OrderResponse ) {
30 3
			$order_response = new OrderResponse();
31
		}
32
33 3
		$order_response->order_id      = Security::filter( $xml['orderID'] );
34 3
		$order_response->pay_id        = Security::filter( $xml['PAYID'] );
35 3
		$order_response->nc_status     = Security::filter( $xml[ Parameters::NC_STATUS ] );
36 3
		$order_response->nc_error      = Security::filter( $xml[ Parameters::NC_ERROR ] );
37 3
		$order_response->nc_error_plus = Security::filter( $xml[ Parameters::NC_ERROR_PLUS ] );
38 3
		$order_response->acceptance    = Security::filter( $xml['ACCEPTANCE'] );
39 3
		$order_response->status        = Security::filter( $xml[ Parameters::STATUS ] );
40 3
		$order_response->eci           = Security::filter( $xml['ECI'] );
41 3
		$order_response->amount        = Security::filter( $xml[ Parameters::AMOUNT ] );
42 3
		$order_response->currency      = Security::filter( $xml[ Parameters::CURRENCY ] );
43 3
		$order_response->pm            = Security::filter( $xml['PM'] );
44 3
		$order_response->brand         = Security::filter( $xml['BRAND'] );
45
46 3
		if ( $xml->HTML_ANSWER ) {
47 1
			$order_response->html_answer = base64_decode( Security::filter( $xml->HTML_ANSWER ) );
0 ignored issues
show
The property html_answer does not seem to exist on Pronamic\WordPress\Pay\G...irectLink\OrderResponse.
Loading history...
48
		}
49
50 3
		return $order_response;
51
	}
52
}
53