|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay; |
|
4
|
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Core\PaymentMethods; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Title: MultiSafepay connect payment methods |
|
9
|
|
|
* Description: |
|
10
|
|
|
* Copyright: 2005-2019 Pronamic |
|
11
|
|
|
* Company: Pronamic |
|
12
|
|
|
* |
|
13
|
|
|
* @author Remco Tolsma |
|
14
|
|
|
* @version 2.0.2 |
|
15
|
|
|
* @since 1.2.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class Methods { |
|
18
|
|
|
/** |
|
19
|
|
|
* Gateway Alipay |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
const ALIPAY = 'ALIPAY'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Gateway American Express |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
const AMEX = 'AMEX'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Gateway Bank Transfer |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
const BANK_TRANSFER = 'BANKTRANS'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Gateway Belfius |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
const BELFIUS = 'BELFIUS'; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Gateway Direct Debit |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
const DIRECT_DEBIT = 'DIRDEB'; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Gateway SOFORT Banking |
|
55
|
|
|
* |
|
56
|
|
|
* @var string |
|
57
|
|
|
*/ |
|
58
|
|
|
const SOFORT = 'DIRECTBANK'; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Gateway DotPay |
|
62
|
|
|
* |
|
63
|
|
|
* @var string |
|
64
|
|
|
*/ |
|
65
|
|
|
const DOTPAY = 'DOTPAY'; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Gateway Giropay |
|
69
|
|
|
* |
|
70
|
|
|
* @var string |
|
71
|
|
|
*/ |
|
72
|
|
|
const GIROPAY = 'GIROPAY'; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Gateway iDEAL QR |
|
76
|
|
|
* |
|
77
|
|
|
* @var string |
|
78
|
|
|
*/ |
|
79
|
|
|
const IDEALQR = 'IDEALQR'; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Gateway iDEAL |
|
83
|
|
|
* |
|
84
|
|
|
* @var string |
|
85
|
|
|
*/ |
|
86
|
|
|
const IDEAL = 'IDEAL'; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Gateway ING |
|
90
|
|
|
* |
|
91
|
|
|
* @var string |
|
92
|
|
|
*/ |
|
93
|
|
|
const ING = 'ING'; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Gateway KBC |
|
97
|
|
|
* |
|
98
|
|
|
* @var string |
|
99
|
|
|
*/ |
|
100
|
|
|
const KBC = 'KBC'; |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Gateway Maestro |
|
104
|
|
|
* |
|
105
|
|
|
* @var string |
|
106
|
|
|
*/ |
|
107
|
|
|
const MAESTRO = 'MAESTRO'; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Gateway Mastercard |
|
111
|
|
|
* |
|
112
|
|
|
* @var string |
|
113
|
|
|
*/ |
|
114
|
|
|
const MASTERCARD = 'MASTERCARD'; |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Gateway Bancontact |
|
118
|
|
|
* |
|
119
|
|
|
* @var string |
|
120
|
|
|
*/ |
|
121
|
|
|
const BANCONTACT = 'MISTERCASH'; |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Gateway Pay after delivery |
|
125
|
|
|
* |
|
126
|
|
|
* @var string |
|
127
|
|
|
*/ |
|
128
|
|
|
const PAYAFTER = 'PAYAFTER'; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Gateway PayPal |
|
132
|
|
|
* |
|
133
|
|
|
* @var string |
|
134
|
|
|
*/ |
|
135
|
|
|
const PAYPAL = 'PAYPAL'; |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Gateway Visa |
|
139
|
|
|
* |
|
140
|
|
|
* @var string |
|
141
|
|
|
*/ |
|
142
|
|
|
const VISA = 'VISA'; |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Payments methods map. |
|
146
|
|
|
* |
|
147
|
|
|
* @var array |
|
148
|
|
|
*/ |
|
149
|
|
|
private static $map = array( |
|
150
|
|
|
PaymentMethods::ALIPAY => self::ALIPAY, |
|
151
|
|
|
PaymentMethods::BANCONTACT => self::BANCONTACT, |
|
152
|
|
|
PaymentMethods::BANK_TRANSFER => self::BANK_TRANSFER, |
|
153
|
|
|
PaymentMethods::BELFIUS => self::BELFIUS, |
|
154
|
|
|
PaymentMethods::DIRECT_DEBIT => self::DIRECT_DEBIT, |
|
155
|
|
|
PaymentMethods::GIROPAY => self::GIROPAY, |
|
156
|
|
|
PaymentMethods::IDEAL => self::IDEAL, |
|
157
|
|
|
PaymentMethods::IDEALQR => self::IDEALQR, |
|
158
|
|
|
PaymentMethods::KBC => self::KBC, |
|
159
|
|
|
PaymentMethods::PAYPAL => self::PAYPAL, |
|
160
|
|
|
PaymentMethods::SOFORT => self::SOFORT, |
|
161
|
|
|
); |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Transform WordPress payment method to MultiSafepay method. |
|
165
|
|
|
* |
|
166
|
|
|
* @since unreleased |
|
167
|
|
|
* |
|
168
|
|
|
* @param string $payment_method Payment method. |
|
169
|
|
|
* @param mixed $default Default payment method. |
|
170
|
|
|
* |
|
171
|
|
|
* @return string |
|
172
|
|
|
*/ |
|
173
|
|
|
public static function transform( $payment_method, $default = null ) { |
|
174
|
|
|
if ( ! is_scalar( $payment_method ) ) { |
|
|
|
|
|
|
175
|
|
|
return null; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
if ( isset( self::$map[ $payment_method ] ) ) { |
|
179
|
|
|
return self::$map[ $payment_method ]; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
return $default; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Transform MultiSafepay method to WordPress payment method. |
|
187
|
|
|
* |
|
188
|
|
|
* @since unreleased |
|
189
|
|
|
* |
|
190
|
|
|
* @param string $method Mollie method. |
|
191
|
|
|
* |
|
192
|
|
|
* @return string |
|
193
|
|
|
*/ |
|
194
|
|
|
public static function transform_gateway_method( $method ) { |
|
195
|
|
|
if ( ! is_scalar( $method ) ) { |
|
|
|
|
|
|
196
|
|
|
return null; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
$payment_method = array_search( $method, self::$map, true ); |
|
200
|
|
|
|
|
201
|
|
|
if ( ! $payment_method ) { |
|
202
|
|
|
return null; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
return $payment_method; |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|