1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Icepay; |
4
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Title: ICEPAY integration |
9
|
|
|
* Description: |
10
|
|
|
* Copyright: 2005-2019 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 AbstractIntegration { |
18
|
3 |
|
public function __construct( $args = array() ) { |
19
|
3 |
|
$args = wp_parse_args( |
20
|
3 |
|
$args, |
21
|
|
|
array( |
22
|
3 |
|
'id' => 'icepay-ideal', |
23
|
3 |
|
'name' => 'ICEPAY', |
24
|
3 |
|
'url' => 'https://icepay.com/', |
25
|
3 |
|
'product_url' => __( 'https://icepay.com/nl/en/pricing-and-accounts/', 'pronamic_ideal' ), |
26
|
3 |
|
'manual_url' => __( 'https://www.pronamic.eu/support/how-to-connect-icepay-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
27
|
3 |
|
'dashboard_url' => 'https://portal.icepay.com/', |
28
|
3 |
|
'provider' => 'icepay', |
29
|
|
|
) |
30
|
|
|
); |
31
|
|
|
|
32
|
3 |
|
$this->id = $args['id']; |
33
|
3 |
|
$this->name = $args['name']; |
34
|
3 |
|
$this->url = $args['url']; |
35
|
3 |
|
$this->product_url = $args['product_url']; |
36
|
3 |
|
$this->dashboard_url = $args['dashboard_url']; |
37
|
3 |
|
$this->provider = $args['provider']; |
38
|
3 |
|
$this->supports = array( |
39
|
|
|
'webhook', |
40
|
|
|
'webhook_log', |
41
|
|
|
); |
42
|
|
|
|
43
|
3 |
|
$this->set_manual_url( $args['manual_url'] ); |
44
|
|
|
|
45
|
|
|
// Actions |
46
|
3 |
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
47
|
|
|
|
48
|
3 |
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
49
|
1 |
|
add_action( 'wp_loaded', $function ); |
50
|
|
|
} |
51
|
3 |
|
} |
52
|
|
|
|
53
|
1 |
|
public function get_settings_fields() { |
54
|
1 |
|
$fields = array(); |
55
|
|
|
|
56
|
|
|
// Merchant ID |
57
|
1 |
|
$fields[] = array( |
58
|
1 |
|
'section' => 'general', |
59
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
60
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_merchant_id', |
61
|
1 |
|
'title' => _x( 'Merchant ID', 'icepay', 'pronamic_ideal' ), |
62
|
1 |
|
'type' => 'text', |
63
|
1 |
|
'tooltip' => __( 'Merchant ID as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
// Secret Code |
67
|
1 |
|
$fields[] = array( |
68
|
1 |
|
'section' => 'general', |
69
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
70
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_secret_code', |
71
|
1 |
|
'title' => _x( 'Secret Code', 'icepay', 'pronamic_ideal' ), |
72
|
1 |
|
'type' => 'text', |
73
|
|
|
'classes' => array( 'regular-text', 'code' ), |
74
|
1 |
|
'tooltip' => __( 'Secret Code as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
// Purchase ID |
78
|
1 |
|
$fields[] = array( |
79
|
1 |
|
'section' => 'advanced', |
80
|
|
|
'filter' => array( |
81
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
82
|
1 |
|
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
83
|
|
|
), |
84
|
1 |
|
'meta_key' => '_pronamic_gateway_icepay_order_id', |
85
|
1 |
|
'title' => __( 'Order ID', 'pronamic_ideal' ), |
86
|
1 |
|
'type' => 'text', |
87
|
|
|
'classes' => array( 'regular-text', 'code' ), |
88
|
1 |
|
'tooltip' => sprintf( |
89
|
|
|
/* translators: %s: <code>OrderID</code> */ |
90
|
1 |
|
__( 'The Icepay %s parameter.', 'pronamic_ideal' ), |
91
|
1 |
|
sprintf( '<code>%s</code>', 'OrderID' ) |
92
|
|
|
), |
93
|
1 |
|
'description' => sprintf( |
94
|
1 |
|
'%s %s<br />%s', |
95
|
1 |
|
__( 'Available tags:', 'pronamic_ideal' ), |
96
|
1 |
|
sprintf( |
97
|
1 |
|
'<code>%s</code> <code>%s</code>', |
98
|
1 |
|
'{order_id}', |
99
|
1 |
|
'{payment_id}' |
100
|
|
|
), |
101
|
1 |
|
sprintf( |
102
|
|
|
/* translators: %s: <code>{payment_id}</code> */ |
103
|
1 |
|
__( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
104
|
1 |
|
'{payment_id}' |
105
|
|
|
) |
106
|
|
|
), |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
// Thank you page URL |
110
|
1 |
|
$fields[] = array( |
111
|
1 |
|
'section' => 'feedback', |
112
|
1 |
|
'title' => __( 'Thank you page URL', 'pronamic_ideal' ), |
113
|
1 |
|
'type' => 'text', |
114
|
|
|
'classes' => array( 'regular-text', 'code' ), |
115
|
1 |
|
'value' => home_url( '/' ), |
116
|
|
|
'readonly' => true, |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
// Error page URL |
120
|
1 |
|
$fields[] = array( |
121
|
1 |
|
'section' => 'feedback', |
122
|
1 |
|
'title' => __( 'Error page URL', 'pronamic_ideal' ), |
123
|
1 |
|
'type' => 'text', |
124
|
|
|
'classes' => array( 'regular-text', 'code' ), |
125
|
1 |
|
'value' => home_url( '/' ), |
126
|
|
|
'readonly' => true, |
127
|
|
|
); |
128
|
|
|
|
129
|
|
|
// Postback URL |
130
|
1 |
|
$fields[] = array( |
131
|
1 |
|
'section' => 'feedback', |
132
|
1 |
|
'title' => __( 'Postback URL', 'pronamic_ideal' ), |
133
|
1 |
|
'type' => 'text', |
134
|
|
|
'classes' => array( 'regular-text', 'code' ), |
135
|
1 |
|
'value' => home_url( '/' ), |
136
|
|
|
'readonly' => true, |
137
|
|
|
); |
138
|
|
|
|
139
|
1 |
|
return $fields; |
140
|
|
|
} |
141
|
|
|
|
142
|
2 |
|
public function get_config( $post_id ) { |
143
|
2 |
|
$config = new Config(); |
144
|
|
|
|
145
|
2 |
|
$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_merchant_id', true ); |
146
|
2 |
|
$config->secret_code = get_post_meta( $post_id, '_pronamic_gateway_icepay_secret_code', true ); |
147
|
2 |
|
$config->order_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_order_id', true ); |
148
|
|
|
|
149
|
2 |
|
return $config; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Get gateway. |
154
|
|
|
* |
155
|
|
|
* @param int $post_id Post ID. |
156
|
|
|
* @return Gateway |
157
|
|
|
*/ |
158
|
1 |
|
public function get_gateway( $post_id ) { |
159
|
1 |
|
return new Gateway( $this->get_config( $post_id ) ); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|