1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Payment brands. |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2022 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\OmniKassa2 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\Core\PaymentMethods; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Payment brands. |
17
|
|
|
* |
18
|
|
|
* @author Remco Tolsma |
19
|
|
|
* @version 2.1.8 |
20
|
|
|
* @since 1.0.0 |
21
|
|
|
*/ |
22
|
|
|
class PaymentBrands { |
23
|
|
|
/** |
24
|
|
|
* Payment brand 'IDEAL'. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
const IDEAL = 'IDEAL'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Payment brand 'AFTERPAY'. |
32
|
|
|
* |
33
|
|
|
* Note: this is for AfterPay (afterpay.nl) and not for Afterpay (afterpay.com). |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
const AFTERPAY = 'AFTERPAY'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Payment brand 'PAYPAL'. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
const PAYPAL = 'PAYPAL'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Payment brand 'MASTERCARD'. |
48
|
|
|
* |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
const MASTERCARD = 'MASTERCARD'; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Payment brand 'VISA'. |
55
|
|
|
* |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
const VISA = 'VISA'; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Payment brand 'BANCONTACT'. |
62
|
|
|
* |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
const BANCONTACT = 'BANCONTACT'; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Payment brand 'MAESTRO'. |
69
|
|
|
* |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
const MAESTRO = 'MAESTRO'; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Payment brand 'V_PAY'. |
76
|
|
|
* |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
const V_PAY = 'V_PAY'; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Payment brand 'CARDS'. |
83
|
|
|
* |
84
|
|
|
* The CARDS value ensures that the consumer can choose between payment methods: |
85
|
|
|
* MASTERCARD, VISA, BANCONTACT, MAESTRO and V_PAY. |
86
|
|
|
* |
87
|
|
|
* Dutch: De waarde CARDS zorgt ervoor dat de consument kan kiezen uit de betaalmethoden: |
88
|
|
|
* MASTERCARD, VISA, BANCONTACT, MAESTRO en V_PAY. |
89
|
|
|
* |
90
|
|
|
* @var string |
91
|
|
|
*/ |
92
|
|
|
const CARDS = 'CARDS'; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Map payment methods to payment brands. |
96
|
|
|
* |
97
|
|
|
* @var array<string, string> |
98
|
|
|
*/ |
99
|
|
|
private static $map = array( |
100
|
|
|
PaymentMethods::AFTERPAY_NL => self::AFTERPAY, |
101
|
|
|
PaymentMethods::BANCONTACT => self::BANCONTACT, |
102
|
|
|
PaymentMethods::CREDIT_CARD => self::CARDS, |
103
|
|
|
PaymentMethods::IDEAL => self::IDEAL, |
104
|
|
|
PaymentMethods::MAESTRO => self::MAESTRO, |
105
|
|
|
PaymentMethods::MASTERCARD => self::MASTERCARD, |
106
|
|
|
PaymentMethods::PAYPAL => self::PAYPAL, |
107
|
|
|
PaymentMethods::V_PAY => self::V_PAY, |
108
|
|
|
PaymentMethods::VISA => self::VISA, |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Transform WordPress payment method to OmniKassa method. |
113
|
|
|
* |
114
|
|
|
* @since 1.0.0 |
115
|
|
|
* @param string|null $payment_method Payment method. |
116
|
|
|
* @param string $default Default payment method. |
117
|
5 |
|
* @return string|null |
118
|
5 |
|
*/ |
119
|
|
|
public static function transform( $payment_method, $default = null ) { |
120
|
|
|
if ( ! \is_scalar( $payment_method ) ) { |
121
|
|
|
return null; |
122
|
5 |
|
} |
123
|
4 |
|
|
124
|
|
|
if ( isset( self::$map[ $payment_method ] ) ) { |
125
|
|
|
return self::$map[ $payment_method ]; |
126
|
1 |
|
} |
127
|
|
|
|
128
|
|
|
return $default; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|