1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay; |
4
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Title: MultiSafepay Connect integration |
9
|
|
|
* Description: |
10
|
|
|
* Copyright: 2005-2019 Pronamic |
11
|
|
|
* Company: Pronamic |
12
|
|
|
* |
13
|
|
|
* @author Remco Tolsma |
14
|
|
|
* @version 2.0.2 |
15
|
|
|
* @since 1.2.6 |
16
|
|
|
*/ |
17
|
|
|
class Integration extends AbstractIntegration { |
18
|
|
|
/** |
19
|
|
|
* Integration constructor. |
20
|
|
|
*/ |
21
|
|
|
public function __construct() { |
22
|
|
|
$this->id = 'multisafepay-connect'; |
23
|
|
|
$this->name = 'MultiSafepay - Connect'; |
24
|
|
|
$this->url = 'http://www.multisafepay.com/'; |
25
|
|
|
$this->product_url = __( 'http://www.multisafepay.com/', 'pronamic_ideal' ); |
26
|
|
|
$this->dashboard_url = 'https://merchant.multisafepay.com/'; |
27
|
|
|
$this->provider = 'multisafepay'; |
28
|
|
|
$this->supports = array( |
|
|
|
|
29
|
|
|
'payment_status_request', |
30
|
|
|
'webhook', |
31
|
|
|
'webhook_no_config', |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function get_settings_fields() { |
36
|
|
|
$fields = array(); |
37
|
|
|
|
38
|
|
|
// Account ID |
39
|
|
|
$fields[] = array( |
40
|
|
|
'section' => 'general', |
41
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
42
|
|
|
'meta_key' => '_pronamic_gateway_multisafepay_account_id', |
43
|
|
|
'title' => __( 'Account ID', 'pronamic_ideal' ), |
44
|
|
|
'type' => 'text', |
45
|
|
|
'classes' => array( 'code' ), |
46
|
|
|
'tooltip' => sprintf( |
47
|
|
|
'%s %s.', |
48
|
|
|
__( 'Account ID', 'pronamic_ideal' ), |
49
|
|
|
/* translators: %s: MultiSafepay */ |
50
|
|
|
sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
51
|
|
|
), |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
// Site ID |
55
|
|
|
$fields[] = array( |
56
|
|
|
'section' => 'general', |
57
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
58
|
|
|
'meta_key' => '_pronamic_gateway_multisafepay_site_id', |
59
|
|
|
'title' => __( 'Site ID', 'pronamic_ideal' ), |
60
|
|
|
'type' => 'text', |
61
|
|
|
'classes' => array( 'code' ), |
62
|
|
|
'tooltip' => sprintf( |
63
|
|
|
'%s %s.', |
64
|
|
|
__( 'Site ID', 'pronamic_ideal' ), |
65
|
|
|
/* translators: %s: MultiSafepay */ |
66
|
|
|
sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
67
|
|
|
), |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
// Site Security Code |
71
|
|
|
$fields[] = array( |
72
|
|
|
'section' => 'general', |
73
|
|
|
'filter' => FILTER_SANITIZE_STRING, |
74
|
|
|
'meta_key' => '_pronamic_gateway_multisafepay_site_code', |
75
|
|
|
'title' => __( 'Site Security Code', 'pronamic_ideal' ), |
76
|
|
|
'type' => 'text', |
77
|
|
|
'classes' => array( 'code' ), |
78
|
|
|
'tooltip' => sprintf( |
79
|
|
|
'%s %s.', |
80
|
|
|
__( 'Site Security Code', 'pronamic_ideal' ), |
81
|
|
|
/* translators: %s: MultiSafepay */ |
82
|
|
|
sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
83
|
|
|
), |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
return $fields; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get config. |
91
|
|
|
* |
92
|
|
|
* @param $post_id |
93
|
|
|
* |
94
|
|
|
* @return Config |
95
|
|
|
*/ |
96
|
|
|
public function get_config( $post_id ) { |
97
|
|
|
$config = new Config(); |
98
|
|
|
|
99
|
|
|
$config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
|
|
|
100
|
|
|
$config->account_id = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_account_id', true ); |
101
|
|
|
$config->site_id = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_site_id', true ); |
102
|
|
|
$config->site_code = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_site_code', true ); |
103
|
|
|
|
104
|
|
|
if ( Gateway::MODE_TEST === $config->mode ) { |
105
|
|
|
$config->api_url = MultiSafepay::API_TEST_URL; |
106
|
|
|
} else { |
107
|
|
|
$config->api_url = MultiSafepay::API_PRODUCTION_URL; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $config; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get gateway. |
115
|
|
|
* |
116
|
|
|
* @param int $post_id Post ID. |
117
|
|
|
* @return Gateway |
118
|
|
|
*/ |
119
|
|
|
public function get_gateway( $post_id ) { |
120
|
|
|
return new Gateway( $this->get_config( $post_id ) ); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|