1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Integration. |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2021 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Title: ING Kassa Compleet integration |
17
|
|
|
* Description: |
18
|
|
|
* Copyright: 2005-2021 Pronamic |
19
|
|
|
* Company: Pronamic |
20
|
|
|
* |
21
|
|
|
* @author Reüel van der Steege |
22
|
|
|
* @version 2.0.3 |
23
|
|
|
* @since 1.0.0 |
24
|
|
|
*/ |
25
|
|
|
class Integration extends AbstractGatewayIntegration { |
26
|
|
|
/** |
27
|
|
|
* Construct ING Kassa Compleet integration. |
28
|
|
|
* |
29
|
|
|
* @param array $args Arguments. |
30
|
|
|
*/ |
31
|
|
|
public function __construct( $args = array() ) { |
32
|
|
|
$args = wp_parse_args( |
33
|
|
|
$args, |
34
|
|
|
array( |
35
|
|
|
'deprecated' => true, |
36
|
|
|
'id' => 'ing-kassa-compleet', |
37
|
|
|
'name' => 'ING - Kassa Compleet', |
38
|
|
|
'provider' => 'ing', |
39
|
|
|
'product_url' => 'https://www.ing.nl/zakelijk/betalen/geld-ontvangen/kassa-compleet/', |
40
|
|
|
'dashboard_url' => 'https://portal.kassacompleet.nl/', |
41
|
|
|
'supports' => array( |
42
|
|
|
'payment_status_request', |
43
|
|
|
'webhook', |
44
|
|
|
'webhook_log', |
45
|
|
|
), |
46
|
|
|
'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-ing-kassa-compleet-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
47
|
|
|
) |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
parent::__construct( $args ); |
51
|
|
|
|
52
|
|
|
// Actions. |
53
|
|
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
54
|
|
|
|
55
|
|
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
56
|
|
|
add_action( 'wp_loaded', $function ); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get settings fields. |
62
|
|
|
* |
63
|
|
|
* @return array |
64
|
|
|
*/ |
65
|
|
|
public function get_settings_fields() { |
66
|
|
|
$fields = array(); |
67
|
|
|
|
68
|
|
|
// API Key. |
69
|
|
|
$fields[] = array( |
70
|
|
|
'section' => 'general', |
71
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
72
|
|
|
'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key', |
73
|
|
|
'title' => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ), |
74
|
|
|
'type' => 'text', |
75
|
|
|
'classes' => array( 'regular-text', 'code' ), |
76
|
|
|
'tooltip' => sprintf( |
77
|
|
|
'%s %s.', |
78
|
|
|
__( 'API key', 'pronamic_ideal' ), |
79
|
|
|
sprintf( |
80
|
|
|
/* translators: %s: payment provider name */ |
81
|
|
|
__( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), |
82
|
|
|
__( 'ING Kassa Compleet', 'pronamic_ideal' ) |
83
|
|
|
) |
84
|
|
|
), |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
// Webhook URL. |
88
|
|
|
$fields[] = array( |
89
|
|
|
'section' => 'feedback', |
90
|
|
|
'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
91
|
|
|
'type' => 'text', |
92
|
|
|
'classes' => array( 'large-text', 'code' ), |
93
|
|
|
'value' => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ), |
94
|
|
|
'readonly' => true, |
95
|
|
|
'tooltip' => sprintf( |
96
|
|
|
/* translators: %s: payment provider name */ |
97
|
|
|
__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
98
|
|
|
__( 'ING Kassa Compleet', 'pronamic_ideal' ) |
99
|
|
|
), |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
return $fields; |
103
|
|
|
} |
104
|
|
|
/** |
105
|
|
|
* Get config with specified post ID. |
106
|
|
|
* |
107
|
|
|
* @param int $post_id Post ID. |
108
|
|
|
* |
109
|
|
|
* @return Config|null |
110
|
|
|
*/ |
111
|
|
|
public function get_config( $post_id ) { |
112
|
|
|
$config = new Config(); |
113
|
|
|
|
114
|
|
|
$config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' ); |
115
|
|
|
$config->mode = $this->get_meta( $post_id, 'mode' ); |
116
|
|
|
|
117
|
|
|
return $config; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get gateway. |
122
|
|
|
* |
123
|
|
|
* @param int $post_id Post ID. |
124
|
|
|
* @return Gateway |
125
|
|
|
*/ |
126
|
|
|
public function get_gateway( $post_id ) { |
127
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|