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
|
|
|
'webhook_log', |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
// Actions. |
52
|
|
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
53
|
|
|
|
54
|
|
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
55
|
|
|
add_action( 'wp_loaded', $function ); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function get_settings_fields() { |
60
|
|
|
$fields = parent::get_settings_fields(); |
61
|
|
|
|
62
|
|
|
// Hash Key |
63
|
|
|
$fields[] = array( |
64
|
|
|
'section' => 'general', |
65
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
66
|
|
|
'meta_key' => '_pronamic_gateway_ideal_hash_key', |
67
|
|
|
'title' => __( 'Hash Key', 'pronamic_ideal' ), |
68
|
|
|
'type' => 'text', |
69
|
|
|
'classes' => array( 'regular-text', 'code' ), |
70
|
|
|
'tooltip' => __( 'Hash key (also known as: key or secret key) as mentioned in the payment provider dashboard.', 'pronamic_ideal' ), |
71
|
|
|
'methods' => array( 'ideal-basic' ), |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
// XML Notification URL. |
75
|
|
|
$fields[] = array( |
76
|
|
|
'section' => 'feedback', |
77
|
|
|
'title' => __( 'XML Notification URL', 'pronamic_ideal' ), |
78
|
|
|
'type' => 'text', |
79
|
|
|
'classes' => array( 'regular-text', 'code' ), |
80
|
|
|
'value' => add_query_arg( |
81
|
|
|
array( |
82
|
|
|
'gateway' => 'IDealBasic', |
83
|
|
|
'xml_notification' => 'true', |
84
|
|
|
), |
85
|
|
|
site_url( '/' ) |
86
|
|
|
), |
87
|
|
|
'methods' => array( 'ideal-basic' ), |
88
|
|
|
'readonly' => true, |
89
|
|
|
'size' => 200, |
90
|
|
|
'tooltip' => __( 'Copy the XML notification URL to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
// Return fields. |
94
|
|
|
return $fields; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function get_config( $post_id ) { |
98
|
|
|
$mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
99
|
|
|
|
100
|
|
|
$config = new Config(); |
101
|
|
|
|
102
|
|
|
$config->url = $this->aquirer_url; |
103
|
|
|
|
104
|
|
|
if ( 'test' === $mode && null !== $this->aquirer_test_url ) { |
105
|
|
|
$config->url = $this->aquirer_test_url; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true ); |
109
|
|
|
$config->sub_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true ); |
110
|
|
|
$config->hash_key = get_post_meta( $post_id, '_pronamic_gateway_ideal_hash_key', true ); |
111
|
|
|
$config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true ); |
112
|
|
|
|
113
|
|
|
return $config; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get gateway. |
118
|
|
|
* |
119
|
|
|
* @param int $post_id Post ID. |
120
|
|
|
* @return Gateway |
121
|
|
|
*/ |
122
|
|
|
public function get_gateway( $post_id ) { |
123
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|