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