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-2020 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 | * Gateway Santander |
||
146 | * |
||
147 | * @var string |
||
148 | */ |
||
149 | const SANTANDER = 'SANTANDER'; |
||
150 | |||
151 | /** |
||
152 | * Payments methods map. |
||
153 | * |
||
154 | * @var array |
||
155 | */ |
||
156 | private static $map = array( |
||
157 | PaymentMethods::ALIPAY => self::ALIPAY, |
||
158 | PaymentMethods::BANCONTACT => self::BANCONTACT, |
||
159 | PaymentMethods::BANK_TRANSFER => self::BANK_TRANSFER, |
||
160 | PaymentMethods::BELFIUS => self::BELFIUS, |
||
161 | PaymentMethods::DIRECT_DEBIT => self::DIRECT_DEBIT, |
||
162 | PaymentMethods::GIROPAY => self::GIROPAY, |
||
163 | PaymentMethods::SANTANDER => self::SANTANDER, |
||
164 | PaymentMethods::IDEALQR => self::IDEALQR, |
||
165 | PaymentMethods::KBC => self::KBC, |
||
166 | PaymentMethods::PAYPAL => self::PAYPAL, |
||
167 | PaymentMethods::SOFORT => self::SOFORT, |
||
168 | ); |
||
169 | |||
170 | /** |
||
171 | * Transform WordPress payment method to MultiSafepay method. |
||
172 | * |
||
173 | * @since unreleased |
||
174 | * |
||
175 | * @param string $payment_method Payment method. |
||
176 | * @param mixed $default Default payment method. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public static function transform( $payment_method, $default = null ) { |
||
181 | if ( ! is_scalar( $payment_method ) ) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
182 | return null; |
||
183 | } |
||
184 | |||
185 | if ( isset( self::$map[ $payment_method ] ) ) { |
||
186 | return self::$map[ $payment_method ]; |
||
187 | } |
||
188 | |||
189 | return $default; |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * Transform MultiSafepay method to WordPress payment method. |
||
194 | * |
||
195 | * @since unreleased |
||
196 | * |
||
197 | * @param string $method Mollie method. |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public static function transform_gateway_method( $method ) { |
||
202 | if ( ! is_scalar( $method ) ) { |
||
0 ignored issues
–
show
|
|||
203 | return null; |
||
204 | } |
||
205 | |||
206 | $payment_method = array_search( $method, self::$map, true ); |
||
207 | |||
208 | if ( ! $payment_method ) { |
||
209 | return null; |
||
210 | } |
||
211 | |||
212 | return $payment_method; |
||
213 | } |
||
214 | } |
||
215 |