1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Title: Mollie payment request |
7
|
|
|
* Description: |
8
|
|
|
* Copyright: Copyright (c) 2005 - 2018 |
9
|
|
|
* Company: Pronamic |
10
|
|
|
* |
11
|
|
|
* @author Remco Tolsma |
12
|
|
|
* @version 2.0.0 |
13
|
|
|
* @since 1.0.0 |
14
|
|
|
*/ |
15
|
|
|
class PaymentRequest { |
16
|
|
|
/** |
17
|
|
|
* The amount in EURO that you want to charge, e.g. `100.00` if you would want to charge |
18
|
|
|
* € 100,00. |
19
|
|
|
* |
20
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
21
|
|
|
* @var float |
22
|
|
|
*/ |
23
|
|
|
public $amount; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The description of the payment you're creating. This will be shown to the consumer on their |
27
|
|
|
* card or bank statement when possible. |
28
|
|
|
* |
29
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public $description; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The URL the consumer will be redirected to after the payment process. It could make sense |
36
|
|
|
* for the redirectURL to contain a unique identifier – like your order ID – so you can show |
37
|
|
|
* the right page referencing the order when the consumer returns. |
38
|
|
|
* |
39
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $redirect_url; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Use this parameter to set a wehook URL for this payment only. Mollie will ignore any webhook |
46
|
|
|
* set in your website profile for this payment. |
47
|
|
|
* |
48
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
public $webhook_url; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Normally, a payment method selection screen is shown. However, when using this parameter, |
55
|
|
|
* your customer will skip the selection screen and will be sent directly to the chosen payment |
56
|
|
|
* method. The parameter enables you to fully integrate the payment method selection into your |
57
|
|
|
* website, however note Mollie's country based conversion optimization is lost. |
58
|
|
|
* |
59
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
public $method; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Provide any data you like in JSON notation, and we will save the data alongside the payment. |
66
|
|
|
* Whenever you fetch the payment with our API, we'll also include the metadata. You can use up |
67
|
|
|
* to 1kB of JSON. |
68
|
|
|
* |
69
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
70
|
|
|
* @var mixed |
71
|
|
|
*/ |
72
|
|
|
public $meta_data; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Allow you to preset the language to be used in the payment screens shown to the consumer. |
76
|
|
|
* When this parameter is not provided, the browser language will be used instead (which is |
77
|
|
|
* usually more accurate). |
78
|
|
|
* |
79
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
public $locale; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Payment method specific parameters |
86
|
|
|
*/ |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* An iDEAL issuer ID, for example ideal_INGNL2A. The returned payment URL will deep-link into |
90
|
|
|
* the specific banking website (ING Bank, in this example). For a list of issuers, refer to the |
91
|
|
|
* Issuers API. |
92
|
|
|
* |
93
|
|
|
* @see https://www.mollie.com/nl/docs/reference/payments/create |
94
|
|
|
* @var string |
95
|
|
|
*/ |
96
|
|
|
public $issuer; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Customer ID for Mollie checkout. |
100
|
|
|
* |
101
|
|
|
* @see https://www.mollie.com/nl/docs/checkout |
102
|
|
|
* @var string |
103
|
|
|
*/ |
104
|
|
|
public $customer_id; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Recurring type for Mollie Recurring. |
108
|
|
|
* |
109
|
|
|
* @see https://www.mollie.com/nl/docs/recurring |
110
|
|
|
* @since 1.1.9 |
111
|
|
|
* @var string |
112
|
|
|
*/ |
113
|
|
|
public $recurring_type; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get array of this Mollie payment request object. |
117
|
|
|
* |
118
|
|
|
* @return array |
119
|
|
|
*/ |
120
|
|
|
public function get_array() { |
121
|
|
|
$array = array( |
122
|
|
|
'amount' => number_format( $this->amount, 2, '.', '' ), |
123
|
|
|
'description' => $this->description, |
124
|
|
|
'method' => $this->method, |
125
|
|
|
'redirectUrl' => $this->redirect_url, |
126
|
|
|
'metadata' => $this->meta_data, |
127
|
|
|
'locale' => $this->locale, |
128
|
|
|
'webhookUrl' => $this->webhook_url, |
129
|
|
|
'issuer' => $this->issuer, |
130
|
|
|
'recurringType' => $this->recurring_type, |
131
|
|
|
'customerId' => $this->customer_id, |
132
|
|
|
); |
133
|
|
|
|
134
|
|
|
/* |
135
|
|
|
* Array filter will remove values NULL, FALSE and empty strings ('') |
136
|
|
|
*/ |
137
|
|
|
$array = array_filter( $array ); |
138
|
|
|
|
139
|
|
|
return $array; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|