|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Payment request |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2020 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\Adyen |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Adyen; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Payment request |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v40/payments |
|
17
|
|
|
* |
|
18
|
|
|
* @author Reüel van der Steege |
|
19
|
|
|
* @version 1.0.0 |
|
20
|
|
|
* @since 1.0.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
class PaymentRequest extends AbstractPaymentRequest { |
|
23
|
|
|
/** |
|
24
|
|
|
* The shopper's browser information. |
|
25
|
|
|
* For 3D Secure 2 transactions, `browserInfo` is required for `channel` web (or `deviceChannel` browser). |
|
26
|
|
|
* |
|
27
|
|
|
* @var BrowserInformation|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private $browser_info; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The collection that contains the type of the payment method and its |
|
33
|
|
|
* specific information (e.g. idealIssuer). |
|
34
|
|
|
* |
|
35
|
|
|
* @var PaymentMethod |
|
36
|
|
|
*/ |
|
37
|
|
|
private $payment_method; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Construct a payment request object. |
|
41
|
|
|
* |
|
42
|
|
|
* @param Amount $amount The amount information for the transaction. |
|
43
|
|
|
* @param string $merchant_account The merchant account identifier, with which you want to process the transaction. |
|
44
|
|
|
* @param string $reference The reference to uniquely identify a payment. |
|
45
|
|
|
* @param string $return_url The URL to return to. |
|
46
|
|
|
* @param PaymentMethod $payment_method The collection that contains the type of the payment method and its specific information (e.g. idealIssuer). |
|
47
|
|
|
*/ |
|
48
|
3 |
|
public function __construct( Amount $amount, $merchant_account, $reference, $return_url, PaymentMethod $payment_method ) { |
|
49
|
3 |
|
parent::__construct( $amount, $merchant_account, $reference, $return_url ); |
|
50
|
|
|
|
|
51
|
3 |
|
$this->payment_method = $payment_method; |
|
52
|
3 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get payment method. |
|
56
|
|
|
* |
|
57
|
|
|
* @return PaymentMethod |
|
58
|
|
|
*/ |
|
59
|
2 |
|
public function get_payment_method() { |
|
60
|
2 |
|
return $this->payment_method; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get browser info. |
|
65
|
|
|
* |
|
66
|
|
|
* @return BrowserInformation|null |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function get_browser_info() { |
|
69
|
2 |
|
return $this->browser_info; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Set browser info. |
|
74
|
|
|
* |
|
75
|
|
|
* @param BrowserInformation|null $browser_info Browser info. |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
public function set_browser_info( $browser_info ) { |
|
79
|
|
|
$this->browser_info = $browser_info; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get JSON. |
|
84
|
|
|
* |
|
85
|
|
|
* @return object |
|
86
|
|
|
*/ |
|
87
|
2 |
|
public function get_json() { |
|
88
|
2 |
|
$object = parent::get_json(); |
|
89
|
|
|
|
|
90
|
2 |
|
$properties = (array) $object; |
|
91
|
|
|
|
|
92
|
|
|
// Browser information. |
|
93
|
2 |
|
$browser_info = $this->get_browser_info(); |
|
94
|
|
|
|
|
95
|
2 |
|
if ( null !== $browser_info ) { |
|
96
|
|
|
$properties['browserInfo'] = $browser_info->get_json(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
// Payment method. |
|
100
|
2 |
|
$properties['paymentMethod'] = $this->get_payment_method()->get_json(); |
|
101
|
|
|
|
|
102
|
|
|
// Return object. |
|
103
|
2 |
|
$object = (object) $properties; |
|
104
|
|
|
|
|
105
|
2 |
|
return $object; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|