1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Integration |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2019 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Payments |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Sisow; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
14
|
|
|
use Pronamic\WordPress\Pay\Payments\Payment; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Title: Sisow integration |
18
|
|
|
* Description: |
19
|
|
|
* Copyright: 2005-2019 Pronamic |
20
|
|
|
* Company: Pronamic |
21
|
|
|
* |
22
|
|
|
* @author Remco Tolsma |
23
|
|
|
* @version 2.0.0 |
24
|
|
|
* @since 1.0.0 |
25
|
|
|
*/ |
26
|
|
|
class Integration extends AbstractIntegration { |
27
|
|
|
/** |
28
|
|
|
* Construct integration. |
29
|
|
|
*/ |
30
|
|
|
public function __construct() { |
31
|
|
|
$this->id = 'sisow-ideal'; |
32
|
|
|
$this->name = 'Sisow'; |
33
|
|
|
$this->url = 'https://www.sisow.nl/'; |
34
|
|
|
$this->product_url = 'https://www.sisow.nl/epay-online-betaalmogelijkheden/epay-informatie'; |
35
|
|
|
$this->dashboard_url = 'https://www.sisow.nl/Sisow/iDeal/Login.aspx'; |
36
|
|
|
$this->register_url = 'https://www.sisow.nl/Sisow/iDeal/Aanmelden.aspx?r=120872'; |
|
|
|
|
37
|
|
|
$this->provider = 'sisow'; |
38
|
|
|
$this->supports = array( |
39
|
|
|
'webhook', |
40
|
|
|
'webhook_log', |
41
|
|
|
'webhook_no_config', |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-sisow-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) ); |
|
|
|
|
45
|
|
|
|
46
|
|
|
\add_filter( 'pronamic_pay_return_should_redirect', array( $this, 'return_should_redirect' ), 10, 2 ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Filter whether or not to redirect when handling return. |
51
|
|
|
* |
52
|
|
|
* @param bool $should_redirect Whether or not to redirect. |
53
|
|
|
* @param Payment $payment Payment. |
54
|
|
|
* |
55
|
|
|
* @return bool |
56
|
|
|
*/ |
57
|
|
|
public function return_should_redirect( $should_redirect, Payment $payment ) { |
58
|
|
|
// Check if the request is a callback request. |
59
|
|
|
if ( filter_has_var( \INPUT_GET, 'callback' ) && filter_input( \INPUT_GET, 'callback', \FILTER_VALIDATE_BOOLEAN ) ) { |
60
|
|
|
$should_redirect = false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
// Check if the request is a notify request. |
64
|
|
|
if ( filter_has_var( \INPUT_GET, 'notify' ) && filter_input( \INPUT_GET, 'notify', \FILTER_VALIDATE_BOOLEAN ) ) { |
65
|
|
|
// Log webhook request. |
66
|
|
|
do_action( 'pronamic_pay_webhook_log_payment', $payment ); |
67
|
|
|
|
68
|
|
|
$should_redirect = false; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $should_redirect; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get settings fields. |
76
|
|
|
* |
77
|
|
|
* @return array |
78
|
|
|
*/ |
79
|
|
|
public function get_settings_fields() { |
80
|
|
|
$fields = array(); |
81
|
|
|
|
82
|
|
|
// Intro. |
83
|
|
|
$fields[] = array( |
84
|
|
|
'section' => 'general', |
85
|
|
|
'type' => 'html', |
86
|
|
|
'html' => sprintf( |
87
|
|
|
/* translators: %s: Sisow */ |
88
|
|
|
__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
89
|
|
|
__( 'Sisow', 'pronamic_ideal' ) |
90
|
|
|
), |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
// Merchant ID. |
94
|
|
|
$fields[] = array( |
95
|
|
|
'section' => 'general', |
96
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
97
|
|
|
'methods' => array( 'sisow' ), |
98
|
|
|
'meta_key' => '_pronamic_gateway_sisow_merchant_id', |
99
|
|
|
'title' => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ), |
100
|
|
|
'type' => 'text', |
101
|
|
|
'classes' => array( 'code' ), |
102
|
|
|
'tooltip' => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
103
|
|
|
); |
104
|
|
|
|
105
|
|
|
// Merchant Key. |
106
|
|
|
$fields[] = array( |
107
|
|
|
'section' => 'general', |
108
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
109
|
|
|
'methods' => array( 'sisow' ), |
110
|
|
|
'meta_key' => '_pronamic_gateway_sisow_merchant_key', |
111
|
|
|
'title' => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ), |
112
|
|
|
'type' => 'text', |
113
|
|
|
'classes' => array( 'regular-text', 'code' ), |
114
|
|
|
'tooltip' => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
115
|
|
|
); |
116
|
|
|
|
117
|
|
|
// Shop ID. |
118
|
|
|
$fields[] = array( |
119
|
|
|
'section' => 'general', |
120
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
121
|
|
|
'methods' => array( 'sisow' ), |
122
|
|
|
'meta_key' => '_pronamic_gateway_sisow_shop_id', |
123
|
|
|
'title' => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ), |
124
|
|
|
'type' => 'text', |
125
|
|
|
'classes' => array( 'regular-text', 'code' ), |
126
|
|
|
'tooltip' => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
127
|
|
|
/* translators: %s: 0 */ |
128
|
|
|
'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ), |
129
|
|
|
'default' => 0, |
130
|
|
|
); |
131
|
|
|
|
132
|
|
|
return $fields; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get configuration. |
137
|
|
|
* |
138
|
|
|
* @param int $post_id Post ID. |
139
|
|
|
* @return Config |
140
|
|
|
*/ |
141
|
|
|
public function get_config( $post_id ) { |
142
|
|
|
$config = new Config(); |
143
|
|
|
|
144
|
|
|
$config->merchant_id = $this->get_meta( $post_id, 'sisow_merchant_id' ); |
145
|
|
|
$config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' ); |
146
|
|
|
$config->shop_id = $this->get_meta( $post_id, 'sisow_shop_id' ); |
147
|
|
|
$config->mode = $this->get_meta( $post_id, 'mode' ); |
148
|
|
|
|
149
|
|
|
return $config; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Get gateway. |
154
|
|
|
* |
155
|
|
|
* @param int $post_id Post ID. |
156
|
|
|
* @return Gateway |
157
|
|
|
*/ |
158
|
|
|
public function get_gateway( $post_id ) { |
159
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|