Test Failed
Push — develop ( 7cb291...9cc0c5 )
by Reüel
03:00
created

src/XML/OrderResponseParser.php (1 issue)

Labels
Severity
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
	public static function parse( SimpleXMLElement $xml, $order_response = null ) {
29
		if ( ! $order_response instanceof OrderResponse ) {
30
			$order_response = new OrderResponse();
31
		}
32
33
		$order_response->order_id      = Security::filter( $xml['orderID'] );
34
		$order_response->pay_id        = Security::filter( $xml['PAYID'] );
35
		$order_response->nc_status     = Security::filter( $xml[ Parameters::NC_STATUS ] );
36
		$order_response->nc_error      = Security::filter( $xml[ Parameters::NC_ERROR ] );
37
		$order_response->nc_error_plus = Security::filter( $xml[ Parameters::NC_ERROR_PLUS ] );
38
		$order_response->acceptance    = Security::filter( $xml['ACCEPTANCE'] );
39
		$order_response->status        = Security::filter( $xml[ Parameters::STATUS ] );
40
		$order_response->eci           = Security::filter( $xml['ECI'] );
41
		$order_response->amount        = Security::filter( $xml[ Parameters::AMOUNT ] );
42
		$order_response->currency      = Security::filter( $xml[ Parameters::CURRENCY ] );
43
		$order_response->pm            = Security::filter( $xml['PM'] );
44
		$order_response->brand         = Security::filter( $xml['BRAND'] );
45
46
		if ( $xml->HTML_ANSWER ) {
47
			$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
		return $order_response;
51
	}
52
}
53