1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Return parameters |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2018 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\OmniKassa2 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2; |
12
|
|
|
|
13
|
|
|
use InvalidArgumentException; |
14
|
|
|
use Pronamic\WordPress\Pay\GatewayPostType; |
|
|
|
|
15
|
|
|
use Pronamic\WordPress\Pay\Plugin; |
|
|
|
|
16
|
|
|
use Pronamic\WordPress\Pay\Core\Gateway; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Return parameters |
20
|
|
|
* |
21
|
|
|
* @author Remco Tolsma |
22
|
|
|
* @version 2.0.2 |
23
|
|
|
* @since 2.0.2 |
24
|
|
|
*/ |
25
|
|
|
class ReturnParameters extends ResponseMessage { |
26
|
|
|
/** |
27
|
|
|
* The "merchantOrderId" as used in the Order announce. |
28
|
|
|
* |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $order_id; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The status of the order, see below for more details. |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $status; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Construct return parameters object. |
42
|
|
|
* |
43
|
|
|
* @param string $order_id Order ID. |
44
|
|
|
* @param string $status Status. |
45
|
|
|
* @param string $signature Signature. |
46
|
|
|
*/ |
47
|
|
|
public function __construct( $order_id, $status, $signature ) { |
48
|
|
|
parent::__construct( $signature ); |
49
|
|
|
|
50
|
|
|
$this->order_id = $order_id; |
51
|
|
|
$this->status = $status; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get order ID. |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function get_order_id() { |
60
|
|
|
return $this->order_id; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get status. |
65
|
|
|
* |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function get_status() { |
69
|
|
|
return $this->status; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get signature data. |
74
|
|
|
* |
75
|
|
|
* The signature is calculated in the same way as other signatures. In this case, the two fields (in order: order_id, status) are used as input. |
76
|
|
|
* |
77
|
|
|
* @return array |
78
|
|
|
*/ |
79
|
|
|
public function get_signature_data() { |
80
|
|
|
return array( |
81
|
|
|
$this->get_order_id(), |
82
|
|
|
$this->get_status(), |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Check if data array contains return parameters. |
88
|
|
|
* |
89
|
|
|
* @param array $data Data array. |
90
|
|
|
* @return bool True if array contains return parameters, false otherwise. |
91
|
|
|
*/ |
92
|
|
|
public static function contains( array $data ) { |
93
|
|
|
return ( |
94
|
|
|
array_key_exists( 'order_id', $data ) |
95
|
|
|
&& |
96
|
|
|
array_key_exists( 'status', $data ) |
97
|
|
|
&& |
98
|
|
|
array_key_exists( 'signature', $data ) |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Get return parameters from the specifieid data array. |
104
|
|
|
* |
105
|
|
|
* @param array $data Data array. |
106
|
|
|
* @return ReturnParameters |
107
|
|
|
* @throws InvalidArgumentException Throws invalid argument exception when array does not contains the required keys. |
108
|
|
|
*/ |
109
|
|
|
public static function from_array( array $data ) { |
110
|
|
|
if ( ! array_key_exists( 'order_id', $data ) ) { |
111
|
|
|
throw new InvalidArgumentException( 'Data array must contain `order_id` field.' ); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if ( ! array_key_exists( 'status', $data ) ) { |
115
|
|
|
throw new InvalidArgumentException( 'Data array must contain `status` field.' ); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
if ( ! array_key_exists( 'signature', $data ) ) { |
119
|
|
|
throw new InvalidArgumentException( 'Data array must contain `signature` field.' ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return new self( |
123
|
|
|
$data['order_id'], |
124
|
|
|
$data['status'], |
125
|
|
|
$data['signature'] |
126
|
|
|
); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths