1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Integration |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2020 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\Payvision |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Payvision; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Integration |
17
|
|
|
* |
18
|
|
|
* @author Remco Tolsma |
19
|
|
|
* @version 1.1.2 |
20
|
|
|
* @since 1.0.0 |
21
|
|
|
*/ |
22
|
|
|
class Integration extends AbstractGatewayIntegration { |
23
|
|
|
/** |
24
|
|
|
* REST route namespace. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
const REST_ROUTE_NAMESPACE = 'pronamic-pay/payvision/v1'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Construct Payvision integration. |
32
|
|
|
* |
33
|
|
|
* @param array<string, array<string>> $args Arguments. |
34
|
|
|
*/ |
35
|
2 |
|
public function __construct( $args = array() ) { |
36
|
2 |
|
$args = \wp_parse_args( |
37
|
2 |
|
$args, |
38
|
|
|
array( |
39
|
2 |
|
'id' => 'payvision', |
40
|
2 |
|
'name' => 'Payvision', |
41
|
2 |
|
'provider' => 'payvision', |
42
|
2 |
|
'url' => \__( 'https://www.payvision.com/', 'pronamic_ideal' ), |
43
|
2 |
|
'product_url' => \__( 'https://www.payvision.com/', 'pronamic_ideal' ), |
44
|
2 |
|
'dashboard_url' => 'https://tools.payvisionservices.com/acecontrol/dashboard', |
45
|
2 |
|
'manual_url' => \__( |
46
|
2 |
|
'https://www.pronamic.eu/manuals/using-payvision-pronamic-pay/', |
47
|
2 |
|
'pronamic_ideal' |
48
|
|
|
), |
49
|
|
|
'supports' => array(), |
50
|
|
|
) |
51
|
|
|
); |
52
|
|
|
|
53
|
2 |
|
parent::__construct( $args ); |
54
|
2 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get settings fields. |
58
|
|
|
* |
59
|
|
|
* @return array<int, array<string, callable|int|string|bool|array<int|string,int|string>>> |
|
|
|
|
60
|
|
|
*/ |
61
|
1 |
|
public function get_settings_fields() { |
62
|
1 |
|
$fields = array(); |
63
|
|
|
|
64
|
|
|
// Business Id. |
65
|
1 |
|
$fields[] = array( |
66
|
1 |
|
'section' => 'general', |
67
|
|
|
'filter' => \FILTER_SANITIZE_STRING, |
68
|
1 |
|
'meta_key' => '_pronamic_gateway_payvision_business_id', |
69
|
1 |
|
'title' => \_x( 'Business Id', 'payvision', 'pronamic_ideal' ), |
70
|
1 |
|
'type' => 'text', |
71
|
|
|
'classes' => array( 'regular-text', 'code' ), |
72
|
1 |
|
'tooltip' => \__( |
73
|
1 |
|
'A Merchant connecting to the platform is identified by its Business ID (“businessId”).', |
74
|
1 |
|
'pronamic_ideal' |
75
|
|
|
), |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
// User. |
79
|
1 |
|
$fields[] = array( |
80
|
1 |
|
'section' => 'general', |
81
|
|
|
'filter' => \FILTER_SANITIZE_STRING, |
82
|
1 |
|
'meta_key' => '_pronamic_gateway_payvision_username', |
83
|
1 |
|
'title' => \_x( 'User', 'payvision', 'pronamic_ideal' ), |
84
|
1 |
|
'type' => 'text', |
85
|
|
|
'classes' => array( 'regular-text', 'code' ), |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
// Password. |
89
|
1 |
|
$fields[] = array( |
90
|
1 |
|
'section' => 'general', |
91
|
|
|
'filter' => \FILTER_SANITIZE_STRING, |
92
|
1 |
|
'meta_key' => '_pronamic_gateway_payvision_password', |
93
|
1 |
|
'title' => \_x( 'Password', 'payvision', 'pronamic_ideal' ), |
94
|
1 |
|
'type' => 'text', |
95
|
|
|
'classes' => array( 'regular-text', 'code' ), |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
// Store Id. |
99
|
1 |
|
$fields[] = array( |
100
|
1 |
|
'section' => 'general', |
101
|
|
|
'filter' => \FILTER_SANITIZE_STRING, |
102
|
1 |
|
'meta_key' => '_pronamic_gateway_payvision_store_id', |
103
|
1 |
|
'title' => \_x( 'Store ID', 'payvision', 'pronamic_ideal' ), |
104
|
1 |
|
'type' => 'text', |
105
|
|
|
'classes' => array( 'regular-text', 'code' ), |
106
|
|
|
); |
107
|
|
|
|
108
|
|
|
// Return fields. |
109
|
1 |
|
return $fields; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Get configuration by post ID. |
114
|
|
|
* |
115
|
|
|
* @param int $post_id Post ID. |
116
|
|
|
* @return Config |
117
|
|
|
*/ |
118
|
1 |
|
public function get_config( $post_id ) { |
119
|
1 |
|
$mode = $this->get_meta( $post_id, 'mode' ); |
120
|
1 |
|
$business_id = $this->get_meta( $post_id, 'payvision_business_id' ); |
121
|
1 |
|
$username = $this->get_meta( $post_id, 'payvision_username' ); |
122
|
1 |
|
$password = $this->get_meta( $post_id, 'payvision_password' ); |
123
|
1 |
|
$store_id = $this->get_meta( $post_id, 'payvision_store_id' ); |
124
|
|
|
|
125
|
1 |
|
return new Config( $mode, $business_id, $username, $password, $store_id ); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Get gateway. |
130
|
|
|
* |
131
|
|
|
* @param int $post_id Post ID. |
132
|
|
|
* @return Gateway |
133
|
|
|
*/ |
134
|
1 |
|
public function get_gateway( $post_id ) { |
135
|
1 |
|
$config = $this->get_config( $post_id ); |
136
|
|
|
|
137
|
1 |
|
return new Gateway( $config ); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.