1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Methods |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2022 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Payments |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Sisow; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\Core\PaymentMethods; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Title: iDEAL Sisow payment methods |
17
|
|
|
* Description: |
18
|
|
|
* Copyright: 2005-2022 Pronamic |
19
|
|
|
* Company: Pronamic |
20
|
|
|
* |
21
|
|
|
* @author Remco Tolsma |
22
|
|
|
* @version 2.1.0 |
23
|
|
|
* @since 1.0.0 |
24
|
|
|
*/ |
25
|
|
|
class Methods { |
26
|
|
|
/** |
27
|
|
|
* Indicator for 'AfterPay' payment. |
28
|
|
|
* |
29
|
|
|
* Note: this is for AfterPay (afterpay.nl) and not for Afterpay (afterpay.com). |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
* @since 2.1.0 |
33
|
|
|
*/ |
34
|
|
|
const AFTERPAY = 'afterpay'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Indicator for 'Belfius' payment |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
const BELFIUS = 'belfius'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Indicator for 'Billink' payment |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
const BILLINK = 'billink'; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Indicator for 'iDEAL' payment |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
const IDEAL = 'ideal'; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Indicator for 'iDEAL QR' payment |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
const IDEALQR = 'idealqr'; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Indicator for 'bunq' payment |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
* @since unreleased |
69
|
|
|
*/ |
70
|
|
|
const BUNQ = 'bunq'; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Indicator for 'Capayable' payment. |
74
|
|
|
* |
75
|
|
|
* @var string |
76
|
|
|
* @since 2.1.0 |
77
|
|
|
*/ |
78
|
|
|
const CAPAYABLE = 'capayable'; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Indicator for 'Creditcard' payment |
82
|
|
|
* |
83
|
|
|
* @var string |
84
|
|
|
* @since 1.1.2 |
85
|
|
|
*/ |
86
|
|
|
const CREDIT_CARD = 'creditcard'; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Indicator for 'Achteraf betalen' payment |
90
|
|
|
* |
91
|
|
|
* @var string |
92
|
|
|
*/ |
93
|
|
|
const ECARE = 'ecare'; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Indicator for 'Digitale acceptgiro' payment |
97
|
|
|
* |
98
|
|
|
* @var string |
99
|
|
|
*/ |
100
|
|
|
const EBILL = 'ebill'; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Indicator for 'Focum' payment. |
104
|
|
|
* |
105
|
|
|
* @var string |
106
|
|
|
* @since 2.1.0 |
107
|
|
|
*/ |
108
|
|
|
const FOCUM = 'focum'; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Indicator for 'Giropay' payment |
112
|
|
|
* |
113
|
|
|
* @var string |
114
|
|
|
*/ |
115
|
|
|
const GIROPAY = 'giropay'; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Indicator for 'Klarna Factuur' payment. |
119
|
|
|
* |
120
|
|
|
* @var string |
121
|
|
|
* @since 2.1.0 |
122
|
|
|
*/ |
123
|
|
|
const KLARNA = 'klarna'; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Indicator for 'Bank/giro betaling' payment |
127
|
|
|
* |
128
|
|
|
* @var string |
129
|
|
|
*/ |
130
|
|
|
const OVERBOEKING = 'overboeking'; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Indicator for 'SofortBanking/DIRECTebanking' payment |
134
|
|
|
* |
135
|
|
|
* @var string |
136
|
|
|
*/ |
137
|
|
|
const SOFORT = 'sofort'; |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Indicator for 'Bancontact/MisterCash' payment |
141
|
|
|
* |
142
|
|
|
* @var string |
143
|
|
|
*/ |
144
|
|
|
const MISTER_CASH = 'mistercash'; |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Indicator for 'PayPal Express Checkout' payment |
148
|
|
|
* |
149
|
|
|
* @var string |
150
|
|
|
*/ |
151
|
|
|
const PAYPAL_EXPRESS_CHECKOUT = 'paypalec'; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Indicator for 'Webshop Giftcard' payment |
155
|
|
|
* |
156
|
|
|
* @var string |
157
|
|
|
*/ |
158
|
|
|
const WEBSHOP_GIFTCARD = 'webshop'; |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Indicator for 'Fijn Cadeaukaart' payment |
162
|
|
|
* |
163
|
|
|
* @var string |
164
|
|
|
*/ |
165
|
|
|
const FIJNCADEAU = 'fijncadeau'; |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Indicator for 'Podium Cadeaukaart' payment |
169
|
|
|
* |
170
|
|
|
* @var string |
171
|
|
|
*/ |
172
|
|
|
const PODIUM_CADEAUKAART = 'podium'; |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Payments methods map. |
176
|
|
|
* |
177
|
|
|
* @var array<string,string> |
178
|
|
|
*/ |
179
|
|
|
private static $map = array( |
180
|
|
|
PaymentMethods::AFTERPAY_NL => self::AFTERPAY, |
181
|
|
|
PaymentMethods::BANCONTACT => self::MISTER_CASH, |
182
|
|
|
PaymentMethods::BANK_TRANSFER => self::OVERBOEKING, |
183
|
|
|
PaymentMethods::BELFIUS => self::BELFIUS, |
184
|
|
|
PaymentMethods::BILLINK => self::BILLINK, |
185
|
|
|
PaymentMethods::BUNQ => self::BUNQ, |
186
|
|
|
PaymentMethods::IN3 => self::CAPAYABLE, |
187
|
|
|
PaymentMethods::CREDIT_CARD => self::CREDIT_CARD, |
188
|
|
|
PaymentMethods::FOCUM => self::FOCUM, |
189
|
|
|
PaymentMethods::GIROPAY => self::GIROPAY, |
190
|
|
|
PaymentMethods::IDEAL => self::IDEAL, |
191
|
|
|
PaymentMethods::IDEALQR => self::IDEALQR, |
192
|
|
|
PaymentMethods::KLARNA_PAY_LATER => self::KLARNA, |
193
|
|
|
PaymentMethods::MISTER_CASH => self::MISTER_CASH, |
194
|
|
|
PaymentMethods::PAYPAL => self::PAYPAL_EXPRESS_CHECKOUT, |
195
|
|
|
PaymentMethods::SOFORT => self::SOFORT, |
196
|
|
|
); |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Transform WordPress payment method to Sisow method. |
200
|
|
|
* |
201
|
|
|
* @param mixed $payment_method Payment method. |
202
|
|
|
* @param string|null $default Value to return if method could not be transformed. |
203
|
|
|
* @return string|null |
204
|
|
|
*/ |
205
|
|
|
public static function transform( $payment_method, $default = null ) { |
206
|
|
|
if ( ! is_scalar( $payment_method ) ) { |
207
|
|
|
return null; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
if ( isset( self::$map[ $payment_method ] ) ) { |
211
|
|
|
return self::$map[ $payment_method ]; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
return $default; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Transform Sisow method to WordPress payment method. |
219
|
|
|
* |
220
|
|
|
* @since unreleased |
221
|
|
|
* |
222
|
|
|
* @param string $method Sisow method. |
223
|
|
|
* |
224
|
|
|
* @return string|null |
225
|
|
|
*/ |
226
|
|
|
public static function transform_gateway_method( $method ) { |
227
|
|
|
if ( ! is_scalar( $method ) ) { |
228
|
|
|
return null; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$payment_method = array_search( $method, self::$map, true ); |
232
|
|
|
|
233
|
|
|
if ( ! $payment_method ) { |
234
|
|
|
return null; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
return $payment_method; |
238
|
|
|
} |
239
|
|
|
} |
240
|
|
|
|