|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic; |
|
4
|
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Gateways\IDeal\AbstractIntegration; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Title: Integration |
|
9
|
|
|
* Description: |
|
10
|
|
|
* Copyright: 2005-2019 Pronamic |
|
11
|
|
|
* Company: Pronamic |
|
12
|
|
|
* |
|
13
|
|
|
* @author Remco Tolsma |
|
14
|
|
|
* @version 2.0.0 |
|
15
|
|
|
* @since 1.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class Integration extends AbstractIntegration { |
|
18
|
|
|
/** |
|
19
|
|
|
* Construct and initialize integration. |
|
20
|
|
|
*/ |
|
21
|
|
|
public function __construct( $args = array() ) { |
|
22
|
|
|
$args = wp_parse_args( |
|
23
|
|
|
$args, |
|
24
|
|
|
array( |
|
25
|
|
|
'id' => 'ideal-basic', |
|
26
|
|
|
'name' => 'iDEAL Basic', |
|
27
|
|
|
'url' => __( 'https://www.ideal.nl/en/', 'pronamic_ideal' ), |
|
28
|
|
|
'product_url' => __( 'https://www.ideal.nl/en/', 'pronamic_ideal' ), |
|
29
|
|
|
'dashboard_url' => null, |
|
30
|
|
|
'provider' => null, |
|
31
|
|
|
'aquirer_url' => null, |
|
32
|
|
|
'aquirer_test_url' => null, |
|
33
|
|
|
) |
|
34
|
|
|
); |
|
35
|
|
|
|
|
36
|
|
|
$this->id = $args['id']; |
|
37
|
|
|
$this->name = $args['name']; |
|
38
|
|
|
$this->url = $args['url']; |
|
39
|
|
|
$this->product_url = $args['product_url']; |
|
40
|
|
|
$this->dashboard_url = $args['dashboard_url']; |
|
41
|
|
|
$this->provider = $args['provider']; |
|
42
|
|
|
|
|
43
|
|
|
$this->aquirer_url = $args['aquirer_url']; |
|
|
|
|
|
|
44
|
|
|
$this->aquirer_test_url = $args['aquirer_test_url']; |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
$this->supports = array( |
|
|
|
|
|
|
47
|
|
|
'webhook', |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
// Actions. |
|
51
|
|
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
52
|
|
|
|
|
53
|
|
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
|
54
|
|
|
add_action( 'wp_loaded', $function ); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function get_settings_fields() { |
|
59
|
|
|
$fields = parent::get_settings_fields(); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
// Hash Key |
|
62
|
|
|
$fields[] = array( |
|
63
|
|
|
'section' => 'general', |
|
64
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
|
65
|
|
|
'meta_key' => '_pronamic_gateway_ideal_hash_key', |
|
66
|
|
|
'title' => __( 'Hash Key', 'pronamic_ideal' ), |
|
67
|
|
|
'type' => 'text', |
|
68
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
69
|
|
|
'tooltip' => __( 'Hash key (also known as: key or secret key) as mentioned in the payment provider dashboard.', 'pronamic_ideal' ), |
|
70
|
|
|
'methods' => array( 'ideal-basic' ), |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
// XML Notification URL. |
|
74
|
|
|
$fields[] = array( |
|
75
|
|
|
'section' => 'feedback', |
|
76
|
|
|
'title' => __( 'XML Notification URL', 'pronamic_ideal' ), |
|
77
|
|
|
'type' => 'text', |
|
78
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
79
|
|
|
'value' => add_query_arg( |
|
80
|
|
|
array( |
|
81
|
|
|
'gateway' => 'IDealBasic', |
|
82
|
|
|
'xml_notification' => 'true', |
|
83
|
|
|
), |
|
84
|
|
|
site_url( '/' ) |
|
85
|
|
|
), |
|
86
|
|
|
'methods' => array( 'ideal-basic' ), |
|
87
|
|
|
'readonly' => true, |
|
88
|
|
|
'size' => 200, |
|
89
|
|
|
'tooltip' => __( 'Copy the XML notification URL to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
|
90
|
|
|
); |
|
91
|
|
|
|
|
92
|
|
|
// Return fields. |
|
93
|
|
|
return $fields; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function get_config( $post_id ) { |
|
97
|
|
|
$mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
98
|
|
|
|
|
99
|
|
|
$config = new Config(); |
|
100
|
|
|
|
|
101
|
|
|
$config->url = $this->aquirer_url; |
|
102
|
|
|
|
|
103
|
|
|
if ( 'test' === $mode && null !== $this->aquirer_test_url ) { |
|
104
|
|
|
$config->url = $this->aquirer_test_url; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true ); |
|
108
|
|
|
$config->sub_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true ); |
|
109
|
|
|
$config->hash_key = get_post_meta( $post_id, '_pronamic_gateway_ideal_hash_key', true ); |
|
110
|
|
|
$config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true ); |
|
111
|
|
|
|
|
112
|
|
|
return $config; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Get gateway. |
|
117
|
|
|
* |
|
118
|
|
|
* @param int $post_id Post ID. |
|
119
|
|
|
* @return Gateway |
|
120
|
|
|
*/ |
|
121
|
|
|
public function get_gateway( $post_id ) { |
|
122
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|