1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay\XML; |
4
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Core\XML\Security; |
6
|
|
|
use SimpleXMLElement; |
7
|
|
|
use stdClass; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Title: MultiSafepay Connect XML status response message |
11
|
|
|
* Description: |
12
|
|
|
* Copyright: 2005-2021 Pronamic |
13
|
|
|
* Company: Pronamic |
14
|
|
|
* |
15
|
|
|
* @author Remco Tolsma |
16
|
|
|
* @version 2.0.2 |
17
|
|
|
* @since 1.0.0 |
18
|
|
|
*/ |
19
|
|
|
class StatusResponseMessage { |
20
|
|
|
/** |
21
|
|
|
* Result |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $result; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* E-wallet |
29
|
|
|
* |
30
|
|
|
* @var object |
31
|
|
|
*/ |
32
|
|
|
public $ewallet; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Customer |
36
|
|
|
* |
37
|
|
|
* @var object |
38
|
|
|
*/ |
39
|
|
|
public $customer; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Transaction |
43
|
|
|
* |
44
|
|
|
* @var object |
45
|
|
|
*/ |
46
|
|
|
public $transaction; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Payment details. |
50
|
|
|
* |
51
|
|
|
* @var object |
52
|
|
|
*/ |
53
|
|
|
public $payment_details; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Parse the specified XML element into an iDEAL transaction object |
57
|
|
|
* |
58
|
|
|
* @param SimpleXMLElement $xml |
59
|
|
|
* |
60
|
|
|
* @return StatusResponseMessage |
61
|
|
|
*/ |
62
|
1 |
|
public static function parse( SimpleXMLElement $xml ) { |
63
|
1 |
|
$message = new StatusResponseMessage(); |
64
|
|
|
|
65
|
1 |
|
$message->result = Security::filter( $xml['result'] ); |
66
|
|
|
|
67
|
|
|
// E-wallet |
68
|
1 |
|
if ( $xml->ewallet ) { |
69
|
1 |
|
$ewallet = new stdClass(); |
70
|
|
|
|
71
|
1 |
|
$ewallet->id = Security::filter( $xml->ewallet->id ); |
72
|
1 |
|
$ewallet->status = Security::filter( $xml->ewallet->status ); |
73
|
1 |
|
$ewallet->created = Security::filter( $xml->ewallet->created ); |
74
|
1 |
|
$ewallet->modified = Security::filter( $xml->ewallet->modified ); |
75
|
1 |
|
$ewallet->reason_code = Security::filter( $xml->ewallet->reasoncode ); |
76
|
1 |
|
$ewallet->reason = Security::filter( $xml->ewallet->reason ); |
77
|
|
|
|
78
|
1 |
|
$message->ewallet = $ewallet; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Customer |
82
|
1 |
|
if ( $xml->customer ) { |
83
|
1 |
|
$customer = new stdClass(); |
84
|
|
|
|
85
|
1 |
|
$customer->currency = Security::filter( $xml->customer->currency ); |
86
|
1 |
|
$customer->amount = Security::filter( $xml->customer->amount ); |
87
|
1 |
|
$customer->exchange_rate = Security::filter( $xml->customer->exchange_rate ); |
88
|
1 |
|
$customer->first_name = Security::filter( $xml->customer->firstname ); |
89
|
1 |
|
$customer->last_name = Security::filter( $xml->customer->lastname ); |
90
|
1 |
|
$customer->last_name = Security::filter( $xml->customer->lastname ); |
91
|
1 |
|
$customer->city = Security::filter( $xml->customer->city ); |
92
|
1 |
|
$customer->state = Security::filter( $xml->customer->state ); |
93
|
1 |
|
$customer->country = Security::filter( $xml->customer->country ); |
94
|
|
|
|
95
|
1 |
|
$message->customer = $customer; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
// Transaction |
99
|
1 |
|
if ( $xml->transaction ) { |
100
|
1 |
|
$transaction = new stdClass(); |
101
|
|
|
|
102
|
1 |
|
$transaction->id = Security::filter( $xml->transaction->id ); |
103
|
1 |
|
$transaction->currency = Security::filter( $xml->transaction->currency ); |
104
|
1 |
|
$transaction->amount = Security::filter( $xml->transaction->amount ); |
105
|
1 |
|
$transaction->description = Security::filter( $xml->transaction->description ); |
106
|
1 |
|
$transaction->var1 = Security::filter( $xml->transaction->var1 ); |
107
|
1 |
|
$transaction->var2 = Security::filter( $xml->transaction->var2 ); |
108
|
1 |
|
$transaction->var3 = Security::filter( $xml->transaction->var3 ); |
109
|
1 |
|
$transaction->items = Security::filter( $xml->transaction->items ); |
110
|
|
|
|
111
|
1 |
|
$message->transaction = $transaction; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
// Payment details |
115
|
1 |
|
if ( $xml->paymentdetails ) { |
116
|
1 |
|
$payment_details = new stdClass(); |
117
|
|
|
|
118
|
1 |
|
$payment_details->type = Security::filter( $xml->paymentdetails->type ); |
119
|
1 |
|
$payment_details->account_iban = Security::filter( $xml->paymentdetails->accountiban ); |
120
|
1 |
|
$payment_details->account_bic = Security::filter( $xml->paymentdetails->accountbic ); |
121
|
1 |
|
$payment_details->account_id = Security::filter( $xml->paymentdetails->accountid ); |
122
|
1 |
|
$payment_details->account_holder_name = Security::filter( $xml->paymentdetails->accountholdername ); |
123
|
1 |
|
$payment_details->external_transaction_id = Security::filter( $xml->paymentdetails->externaltransactionid ); |
124
|
|
|
|
125
|
1 |
|
$message->payment_details = $payment_details; |
126
|
|
|
} |
127
|
|
|
|
128
|
1 |
|
return $message; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|