1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mollie payment request. |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2019 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Title: Mollie payment request |
15
|
|
|
* Description: |
16
|
|
|
* Copyright: 2005-2019 Pronamic |
17
|
|
|
* Company: Pronamic |
18
|
|
|
* |
19
|
|
|
* @author Remco Tolsma |
20
|
|
|
* @version 2.0.9 |
21
|
|
|
* @since 1.0.0 |
22
|
|
|
*/ |
23
|
|
|
class PaymentRequest { |
24
|
|
|
/** |
25
|
|
|
* The amount in EURO that you want to charge, e.g. `{"currency":"EUR", "value":"100.00"}` |
26
|
|
|
* if you would want to charge € 100,00. |
27
|
|
|
* |
28
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
29
|
|
|
* @var Amount |
30
|
|
|
*/ |
31
|
|
|
public $amount; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The description of the payment you're creating. This will be shown to the consumer on their |
35
|
|
|
* card or bank statement when possible. |
36
|
|
|
* |
37
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $description; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The URL the consumer will be redirected to after the payment process. It could make sense |
44
|
|
|
* for the redirectURL to contain a unique identifier – like your order ID – so you can show |
45
|
|
|
* the right page referencing the order when the consumer returns. |
46
|
|
|
* |
47
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $redirect_url; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Use this parameter to set a wehook URL for this payment only. Mollie will ignore any webhook |
54
|
|
|
* set in your website profile for this payment. |
55
|
|
|
* |
56
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
57
|
|
|
* @var string|null |
58
|
|
|
*/ |
59
|
|
|
public $webhook_url; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Normally, a payment method selection screen is shown. However, when using this parameter, |
63
|
|
|
* your customer will skip the selection screen and will be sent directly to the chosen payment |
64
|
|
|
* method. The parameter enables you to fully integrate the payment method selection into your |
65
|
|
|
* website, however note Mollie's country based conversion optimization is lost. |
66
|
|
|
* |
67
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
68
|
|
|
* @var string|null |
69
|
|
|
*/ |
70
|
|
|
public $method; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Provide any data you like in JSON notation, and we will save the data alongside the payment. |
74
|
|
|
* Whenever you fetch the payment with our API, we'll also include the metadata. You can use up |
75
|
|
|
* to 1kB of JSON. |
76
|
|
|
* |
77
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
78
|
|
|
* @var mixed|null |
79
|
|
|
*/ |
80
|
|
|
public $meta_data; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Allow you to preset the language to be used in the payment screens shown to the consumer. |
84
|
|
|
* When this parameter is not provided, the browser language will be used instead (which is |
85
|
|
|
* usually more accurate). |
86
|
|
|
* |
87
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
88
|
|
|
* @var string|null |
89
|
|
|
*/ |
90
|
|
|
public $locale; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Payment method specific parameters |
94
|
|
|
*/ |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* An iDEAL issuer ID, for example ideal_INGNL2A. The returned payment URL will deep-link into |
98
|
|
|
* the specific banking website (ING Bank, in this example). For a list of issuers, refer to the |
99
|
|
|
* Issuers API. |
100
|
|
|
* |
101
|
|
|
* @link https://www.mollie.com/nl/docs/reference/payments/create |
102
|
|
|
* @var string|null |
103
|
|
|
*/ |
104
|
|
|
public $issuer; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* The date the payment should expire, in YYYY-MM-DD format. Please note: the minimum date |
108
|
|
|
* is tomorrow and the maximum date is 100 days after tomorrow. |
109
|
|
|
* |
110
|
|
|
* @link https://docs.mollie.com/reference/v2/payments-api/create-payment |
111
|
|
|
* @var null|\DateTimeInterface |
112
|
|
|
*/ |
113
|
|
|
private $due_date; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Customer ID for Mollie checkout. |
117
|
|
|
* |
118
|
|
|
* @link https://www.mollie.com/nl/docs/checkout |
119
|
|
|
* @var string |
120
|
|
|
*/ |
121
|
|
|
public $customer_id; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Sequence type for Mollie Recurring. |
125
|
|
|
* |
126
|
|
|
* @link https://www.mollie.com/nl/docs/recurring |
127
|
|
|
* @since 1.1.9 |
128
|
|
|
* @var string |
129
|
|
|
*/ |
130
|
|
|
public $sequence_type; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Get due date. |
134
|
|
|
* |
135
|
|
|
* @return null|\DateTimeInterface |
136
|
|
|
*/ |
137
|
2 |
|
public function get_due_date() { |
138
|
2 |
|
return $this->due_date; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Set due date. |
143
|
|
|
* |
144
|
|
|
* @param null|\DateTimeInterface $due_date Due date. |
145
|
|
|
*/ |
146
|
1 |
|
public function set_due_date( $due_date ) { |
147
|
1 |
|
$this->due_date = $due_date; |
148
|
1 |
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get array of this Mollie payment request object. |
152
|
|
|
* |
153
|
|
|
* @return array |
154
|
|
|
*/ |
155
|
2 |
|
public function get_array() { |
156
|
|
|
// Due date. |
157
|
2 |
|
$due_date = $this->get_due_date(); |
158
|
|
|
|
159
|
2 |
|
if ( null !== $due_date ) { |
160
|
1 |
|
$due_date = $due_date->format( 'Y-m-d' ); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
$array = array( |
164
|
2 |
|
'amount' => $this->amount->get_json(), |
165
|
2 |
|
'description' => $this->description, |
166
|
2 |
|
'method' => $this->method, |
167
|
2 |
|
'redirectUrl' => $this->redirect_url, |
168
|
2 |
|
'metadata' => $this->meta_data, |
169
|
2 |
|
'locale' => $this->locale, |
170
|
2 |
|
'webhookUrl' => $this->webhook_url, |
171
|
2 |
|
'issuer' => $this->issuer, |
172
|
2 |
|
'dueDate' => $due_date, |
173
|
2 |
|
'sequenceType' => $this->sequence_type, |
174
|
2 |
|
'customerId' => $this->customer_id, |
175
|
|
|
); |
176
|
|
|
|
177
|
|
|
/* |
178
|
|
|
* Array filter will remove values NULL, FALSE and empty strings ('') |
179
|
|
|
*/ |
180
|
2 |
|
$array = array_filter( $array ); |
181
|
|
|
|
182
|
2 |
|
return $array; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|