1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Icepay; |
4
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Title: ICEPAY integration |
9
|
|
|
* Description: |
10
|
|
|
* Copyright: 2005-2021 Pronamic |
11
|
|
|
* Company: Pronamic |
12
|
|
|
* |
13
|
|
|
* @author Reüel van der Steege |
14
|
|
|
* @version 2.0.6 |
15
|
|
|
* @since 1.0.0 |
16
|
|
|
*/ |
17
|
|
|
class Integration extends AbstractGatewayIntegration { |
18
|
|
|
/** |
19
|
|
|
* Construct ICEPAY integration. |
20
|
|
|
* |
21
|
|
|
* @param array $args Arguments. |
22
|
|
|
*/ |
23
|
3 |
|
public function __construct( $args = array() ) { |
24
|
3 |
|
$args = wp_parse_args( |
25
|
3 |
|
$args, |
26
|
|
|
array( |
27
|
3 |
|
'id' => 'icepay-ideal', |
28
|
3 |
|
'name' => 'ICEPAY', |
29
|
3 |
|
'url' => 'https://icepay.com/', |
30
|
3 |
|
'product_url' => \__( 'https://icepay.com/nl/en/pricing-and-accounts/', 'pronamic_ideal' ), |
31
|
3 |
|
'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-icepay-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
32
|
3 |
|
'dashboard_url' => 'https://portal.icepay.com/', |
33
|
3 |
|
'provider' => 'icepay', |
34
|
|
|
'supports' => array( |
35
|
|
|
'webhook', |
36
|
|
|
'webhook_log', |
37
|
|
|
), |
38
|
|
|
) |
39
|
|
|
); |
40
|
|
|
|
41
|
3 |
|
parent::__construct( $args ); |
42
|
|
|
|
43
|
|
|
// Actions |
44
|
3 |
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
45
|
|
|
|
46
|
3 |
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
47
|
1 |
|
add_action( 'wp_loaded', $function ); |
48
|
|
|
} |
49
|
3 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get settings fields. |
53
|
|
|
* |
54
|
|
|
* @return array<int, array<string, callable|int|string|bool|array<int|string,int|string>>> |
55
|
|
|
*/ |
56
|
1 |
|
public function get_settings_fields() { |
57
|
1 |
|
$fields = array(); |
58
|
|
|
|
59
|
|
|
// Merchant ID |
60
|
1 |
|
$fields[] = array( |
61
|
1 |
|
'section' => 'general', |
62
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
63
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_merchant_id', |
64
|
1 |
|
'title' => _x( 'Merchant ID', 'icepay', 'pronamic_ideal' ), |
65
|
1 |
|
'type' => 'text', |
66
|
1 |
|
'tooltip' => __( 'Merchant ID as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
// Secret Code |
70
|
1 |
|
$fields[] = array( |
71
|
1 |
|
'section' => 'general', |
72
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
73
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_secret_code', |
74
|
1 |
|
'title' => _x( 'Secret Code', 'icepay', 'pronamic_ideal' ), |
75
|
1 |
|
'type' => 'text', |
76
|
|
|
'classes' => array( 'regular-text', 'code' ), |
77
|
1 |
|
'tooltip' => __( 'Secret Code as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
78
|
|
|
); |
79
|
|
|
|
80
|
|
|
// Purchase ID |
81
|
1 |
|
$fields[] = array( |
82
|
1 |
|
'section' => 'advanced', |
83
|
|
|
'filter' => array( |
84
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
85
|
1 |
|
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
86
|
|
|
), |
87
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_order_id', |
88
|
1 |
|
'title' => __( 'Order ID', 'pronamic_ideal' ), |
89
|
1 |
|
'type' => 'text', |
90
|
|
|
'classes' => array( 'regular-text', 'code' ), |
91
|
1 |
|
'tooltip' => sprintf( |
92
|
|
|
/* translators: %s: <code>OrderID</code> */ |
93
|
1 |
|
__( 'The Icepay %s parameter.', 'pronamic_ideal' ), |
94
|
1 |
|
sprintf( '<code>%s</code>', 'OrderID' ) |
95
|
|
|
), |
96
|
1 |
|
'description' => sprintf( |
97
|
1 |
|
'%s %s<br />%s', |
98
|
1 |
|
__( 'Available tags:', 'pronamic_ideal' ), |
99
|
1 |
|
sprintf( |
100
|
1 |
|
'<code>%s</code> <code>%s</code>', |
101
|
1 |
|
'{order_id}', |
102
|
1 |
|
'{payment_id}' |
103
|
|
|
), |
104
|
1 |
|
sprintf( |
105
|
|
|
/* translators: %s: default code */ |
106
|
1 |
|
__( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
107
|
1 |
|
'{payment_id}' |
108
|
|
|
) |
109
|
|
|
), |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
// Thank you page URL |
113
|
1 |
|
$fields[] = array( |
114
|
1 |
|
'section' => 'feedback', |
115
|
1 |
|
'title' => __( 'Thank you page URL', 'pronamic_ideal' ), |
116
|
1 |
|
'type' => 'text', |
117
|
|
|
'classes' => array( 'regular-text', 'code' ), |
118
|
1 |
|
'value' => home_url( '/' ), |
119
|
|
|
'readonly' => true, |
120
|
|
|
); |
121
|
|
|
|
122
|
|
|
// Error page URL |
123
|
1 |
|
$fields[] = array( |
124
|
1 |
|
'section' => 'feedback', |
125
|
1 |
|
'title' => __( 'Error page URL', 'pronamic_ideal' ), |
126
|
1 |
|
'type' => 'text', |
127
|
|
|
'classes' => array( 'regular-text', 'code' ), |
128
|
1 |
|
'value' => home_url( '/' ), |
129
|
|
|
'readonly' => true, |
130
|
|
|
); |
131
|
|
|
|
132
|
|
|
// Postback URL |
133
|
1 |
|
$fields[] = array( |
134
|
1 |
|
'section' => 'feedback', |
135
|
1 |
|
'title' => __( 'Postback URL', 'pronamic_ideal' ), |
136
|
1 |
|
'type' => 'text', |
137
|
|
|
'classes' => array( 'regular-text', 'code' ), |
138
|
1 |
|
'value' => home_url( '/' ), |
139
|
|
|
'readonly' => true, |
140
|
|
|
); |
141
|
|
|
|
142
|
1 |
|
return $fields; |
143
|
|
|
} |
144
|
|
|
|
145
|
2 |
|
public function get_config( $post_id ) { |
146
|
2 |
|
$config = new Config(); |
147
|
|
|
|
148
|
2 |
|
$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_merchant_id', true ); |
|
|
|
|
149
|
2 |
|
$config->secret_code = get_post_meta( $post_id, '_pronamic_gateway_icepay_secret_code', true ); |
|
|
|
|
150
|
2 |
|
$config->order_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_order_id', true ); |
|
|
|
|
151
|
|
|
|
152
|
2 |
|
return $config; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Get gateway. |
157
|
|
|
* |
158
|
|
|
* @param int $post_id Post ID. |
159
|
|
|
* @return Gateway |
160
|
|
|
*/ |
161
|
1 |
|
public function get_gateway( $post_id ) { |
162
|
1 |
|
return new Gateway( $this->get_config( $post_id ) ); |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.