|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Buckaroo; |
|
4
|
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Title: Buckaroo integration |
|
9
|
|
|
* Description: |
|
10
|
|
|
* Copyright: 2005-2019 Pronamic |
|
11
|
|
|
* Company: Pronamic |
|
12
|
|
|
* |
|
13
|
|
|
* @author Reüel van der Steege |
|
14
|
|
|
* @version 2.0.0 |
|
15
|
|
|
* @since 1.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class Integration extends AbstractIntegration { |
|
18
|
|
|
public function __construct() { |
|
19
|
|
|
$this->id = 'buckaroo'; |
|
20
|
|
|
$this->name = 'Buckaroo - HTML'; |
|
21
|
|
|
$this->url = 'https://plaza.buckaroo.nl/'; |
|
22
|
|
|
$this->product_url = __( 'http://www.buckaroo-payments.com', 'pronamic_ideal' ); |
|
23
|
|
|
$this->dashboard_url = 'https://plaza.buckaroo.nl/'; |
|
24
|
|
|
$this->provider = 'buckaroo'; |
|
25
|
|
|
$this->supports = array( |
|
|
|
|
|
|
26
|
|
|
'webhook', |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
// Actions |
|
30
|
|
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
31
|
|
|
|
|
32
|
|
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
|
33
|
|
|
add_action( 'wp_loaded', $function ); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function get_settings_fields() { |
|
38
|
|
|
$fields = array(); |
|
39
|
|
|
|
|
40
|
|
|
// Website Key. |
|
41
|
|
|
$fields[] = array( |
|
42
|
|
|
'section' => 'general', |
|
43
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
|
44
|
|
|
'meta_key' => '_pronamic_gateway_buckaroo_website_key', |
|
45
|
|
|
'title' => __( 'Website Key', 'pronamic_ideal' ), |
|
46
|
|
|
'type' => 'text', |
|
47
|
|
|
'classes' => array( 'code' ), |
|
48
|
|
|
'tooltip' => __( 'Website key as mentioned in the Buckaroo dashboard on the page "Profile » Website".', 'pronamic_ideal' ), |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
// Secret Key. |
|
52
|
|
|
$fields[] = array( |
|
53
|
|
|
'section' => 'general', |
|
54
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
|
55
|
|
|
'meta_key' => '_pronamic_gateway_buckaroo_secret_key', |
|
56
|
|
|
'title' => __( 'Secret Key', 'pronamic_ideal' ), |
|
57
|
|
|
'type' => 'text', |
|
58
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
59
|
|
|
'tooltip' => __( 'Secret key as mentioned in the Buckaroo dashboardb on the page "Configuration » Secret Key for Digital Signature".', 'pronamic_ideal' ), |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
// Excluded services. |
|
63
|
|
|
$fields[] = array( |
|
64
|
|
|
'section' => 'advanced', |
|
65
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
|
66
|
|
|
'meta_key' => '_pronamic_gateway_buckaroo_excluded_services', |
|
67
|
|
|
'title' => __( 'Excluded services', 'pronamic_ideal' ), |
|
68
|
|
|
'type' => 'text', |
|
69
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
70
|
|
|
'tooltip' => sprintf( |
|
71
|
|
|
/* translators: %s: <code>brq_exludedservices</code> */ |
|
72
|
|
|
__( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ), |
|
73
|
|
|
sprintf( '<code>%s</code>', 'brq_exludedservices' ) |
|
74
|
|
|
), |
|
75
|
|
|
); |
|
76
|
|
|
|
|
77
|
|
|
// Invoice number. |
|
78
|
|
|
$fields[] = array( |
|
79
|
|
|
'section' => 'advanced', |
|
80
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
|
81
|
|
|
'meta_key' => '_pronamic_gateway_buckaroo_invoice_number', |
|
82
|
|
|
'title' => __( 'Invoice number', 'pronamic_ideal' ), |
|
83
|
|
|
'type' => 'text', |
|
84
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
85
|
|
|
'tooltip' => sprintf( |
|
86
|
|
|
/* translators: %s: <code>brq_invoicenumber</code> */ |
|
87
|
|
|
__( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ), |
|
88
|
|
|
sprintf( '<code>%s</code>', 'brq_invoicenumber' ) |
|
89
|
|
|
), |
|
90
|
|
|
'description' => sprintf( |
|
91
|
|
|
'%s<br />%s', |
|
92
|
|
|
/* translators: %s: <code>{order_id}</code> <code>{payment_id}</code> */ |
|
93
|
|
|
sprintf( __( 'Available tags: %s', 'pronamic_ideal' ), sprintf( '<code>%s</code> <code>%s</code>', '{order_id}', '{payment_id}' ) ), |
|
94
|
|
|
/* translators: %s: <code>{payment_id}</code> */ |
|
95
|
|
|
sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), '{payment_id}' ) |
|
96
|
|
|
), |
|
97
|
|
|
); |
|
98
|
|
|
|
|
99
|
|
|
// Push URL. |
|
100
|
|
|
$fields[] = array( |
|
101
|
|
|
'section' => 'feedback', |
|
102
|
|
|
'title' => __( 'Push URL', 'pronamic_ideal' ), |
|
103
|
|
|
'type' => 'text', |
|
104
|
|
|
'classes' => array( 'large-text', 'code' ), |
|
105
|
|
|
'value' => add_query_arg( 'buckaroo_push', '', home_url( '/' ) ), |
|
106
|
|
|
'readonly' => true, |
|
107
|
|
|
'tooltip' => __( 'The Push URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
|
108
|
|
|
); |
|
109
|
|
|
|
|
110
|
|
|
return $fields; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function get_config( $post_id ) { |
|
114
|
|
|
$config = new Config(); |
|
115
|
|
|
|
|
116
|
|
|
$config->website_key = get_post_meta( $post_id, '_pronamic_gateway_buckaroo_website_key', true ); |
|
117
|
|
|
$config->secret_key = get_post_meta( $post_id, '_pronamic_gateway_buckaroo_secret_key', true ); |
|
118
|
|
|
$config->excluded_services = get_post_meta( $post_id, '_pronamic_gateway_buckaroo_excluded_services', true ); |
|
119
|
|
|
$config->invoice_number = get_post_meta( $post_id, '_pronamic_gateway_buckaroo_invoice_number', true ); |
|
120
|
|
|
$config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
return $config; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Get gateway. |
|
127
|
|
|
* |
|
128
|
|
|
* @param int $post_id Post ID. |
|
129
|
|
|
* @return Gateway |
|
130
|
|
|
*/ |
|
131
|
|
|
public function get_gateway( $post_id ) { |
|
132
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|