1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\PayNL; |
4
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Title: Pay.nl integration |
9
|
|
|
* Description: |
10
|
|
|
* Copyright: 2005-2021 Pronamic |
11
|
|
|
* Company: Pronamic |
12
|
|
|
* |
13
|
|
|
* @author Remco Tolsma |
14
|
|
|
* @version 2.0.4 |
15
|
|
|
* @since 1.0.0 |
16
|
|
|
*/ |
17
|
|
|
class Integration extends AbstractGatewayIntegration { |
18
|
|
|
/** |
19
|
|
|
* Construct Pay.nl integration. |
20
|
|
|
* |
21
|
|
|
* @param array $args Arguments. |
22
|
|
|
*/ |
23
|
|
|
public function __construct( $args = array() ) { |
24
|
|
|
$args = wp_parse_args( |
25
|
|
|
$args, |
26
|
|
|
array( |
27
|
|
|
'id' => 'pay_nl', |
28
|
|
|
'name' => 'Pay.nl', |
29
|
|
|
'url' => 'https://www.pay.nl/', |
30
|
|
|
'product_url' => 'http://www.pay.nl/', |
31
|
|
|
'dashboard_url' => 'https://admin.pay.nl/', |
32
|
|
|
'register_url' => 'https://www.pay.nl/registreren/?id=M-7393-3100', |
33
|
|
|
'provider' => 'pay_nl', |
34
|
|
|
'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-pay-nl-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
35
|
|
|
) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
parent::__construct( $args ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get settings fields. |
43
|
|
|
* |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
|
|
public function get_settings_fields() { |
47
|
|
|
$fields = array(); |
48
|
|
|
|
49
|
|
|
// Intro. |
50
|
|
|
$fields[] = array( |
51
|
|
|
'section' => 'general', |
52
|
|
|
'type' => 'html', |
53
|
|
|
'html' => sprintf( |
54
|
|
|
/* translators: 1: payment provider name */ |
55
|
|
|
__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
56
|
|
|
__( 'Pay.nl', 'pronamic_ideal' ) |
57
|
|
|
), |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
// Token. |
61
|
|
|
$fields[] = array( |
62
|
|
|
'section' => 'general', |
63
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
64
|
|
|
'meta_key' => '_pronamic_gateway_pay_nl_token', |
65
|
|
|
'title' => __( 'Token', 'pronamic_ideal' ), |
66
|
|
|
'type' => 'text', |
67
|
|
|
'classes' => array( 'regular-text', 'code' ), |
68
|
|
|
'tooltip' => __( 'Token as mentioned at <strong>Merchant » Company data (Connection)</strong> in the payment provider dashboard.', 'pronamic_ideal' ), |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
// Service ID. |
72
|
|
|
$fields[] = array( |
73
|
|
|
'section' => 'general', |
74
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
75
|
|
|
'meta_key' => '_pronamic_gateway_pay_nl_service_id', |
76
|
|
|
'title' => __( 'Service ID', 'pronamic_ideal' ), |
77
|
|
|
'type' => 'text', |
78
|
|
|
'classes' => array( 'regular-text', 'code' ), |
79
|
|
|
'tooltip' => __( 'Service ID as mentioned at <strong>Manage » Services</strong> in the payment provider dashboard.', 'pronamic_ideal' ), |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
// Return fields. |
83
|
|
|
return $fields; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function get_config( $post_id ) { |
87
|
|
|
$config = new Config(); |
88
|
|
|
|
89
|
|
|
$config->token = get_post_meta( $post_id, '_pronamic_gateway_pay_nl_token', true ); |
90
|
|
|
$config->service_id = get_post_meta( $post_id, '_pronamic_gateway_pay_nl_service_id', true ); |
91
|
|
|
|
92
|
|
|
return $config; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get gateway. |
97
|
|
|
* |
98
|
|
|
* @param int $post_id Post ID. |
99
|
|
|
* @return Gateway |
100
|
|
|
*/ |
101
|
|
|
public function get_gateway( $post_id ) { |
102
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|