|
@@ 112-129 (lines=18) @@
|
| 109 |
|
/** |
| 110 |
|
* Test get payment status. |
| 111 |
|
*/ |
| 112 |
|
public function test_get_payment_status() { |
| 113 |
|
$config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
| 114 |
|
|
| 115 |
|
$gateway = new Gateway( $config ); |
| 116 |
|
|
| 117 |
|
$this->mock_http_response( |
| 118 |
|
'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4d', |
| 119 |
|
__DIR__ . '/../http/get-payment-result-0.http' |
| 120 |
|
); |
| 121 |
|
|
| 122 |
|
$payment = new Payment(); |
| 123 |
|
|
| 124 |
|
$payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4d' ); |
| 125 |
|
|
| 126 |
|
$gateway->update_status( $payment ); |
| 127 |
|
|
| 128 |
|
$this->assertEquals( PaymentStatus::SUCCESS, $payment->get_status() ); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
/** |
| 132 |
|
* Test get payment status. |
|
@@ 134-154 (lines=21) @@
|
| 131 |
|
/** |
| 132 |
|
* Test get payment status. |
| 133 |
|
*/ |
| 134 |
|
public function test_get_payment_status_fake() { |
| 135 |
|
$config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
| 136 |
|
|
| 137 |
|
$gateway = new Gateway( $config ); |
| 138 |
|
|
| 139 |
|
$this->mock_http_response( |
| 140 |
|
'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
| 141 |
|
__DIR__ . '/../http/get-payment-by-fake-id.http' |
| 142 |
|
); |
| 143 |
|
|
| 144 |
|
$payment = new Payment(); |
| 145 |
|
|
| 146 |
|
$payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
| 147 |
|
|
| 148 |
|
$this->expectException( \Throwable::class ); |
| 149 |
|
$this->expectExceptionMessage( |
| 150 |
|
'Could not JSON decode Payvision response, HTTP response: "404 Not Found", HTTP body length: "2", JSON error: "Syntax error".' |
| 151 |
|
); |
| 152 |
|
|
| 153 |
|
$gateway->update_status( $payment ); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
/** |
| 157 |
|
* Test get payment empty body. |
|
@@ 159-177 (lines=19) @@
|
| 156 |
|
/** |
| 157 |
|
* Test get payment empty body. |
| 158 |
|
*/ |
| 159 |
|
public function test_get_payment_empty_body() { |
| 160 |
|
$config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
| 161 |
|
|
| 162 |
|
$gateway = new Gateway( $config ); |
| 163 |
|
|
| 164 |
|
$this->mock_http_response( |
| 165 |
|
'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
| 166 |
|
__DIR__ . '/../http/get-payment-body-empty.http' |
| 167 |
|
); |
| 168 |
|
|
| 169 |
|
$payment = new Payment(); |
| 170 |
|
|
| 171 |
|
$payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
| 172 |
|
|
| 173 |
|
$this->expectException( \Throwable::class ); |
| 174 |
|
$this->expectExceptionMessage( 'Payvision response is empty, HTTP response: "200 OK".' ); |
| 175 |
|
|
| 176 |
|
$gateway->update_status( $payment ); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
/** |
| 180 |
|
* Test get payment no object. |
|
@@ 182-202 (lines=21) @@
|
| 179 |
|
/** |
| 180 |
|
* Test get payment no object. |
| 181 |
|
*/ |
| 182 |
|
public function test_get_payment_no_object() { |
| 183 |
|
$config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
| 184 |
|
|
| 185 |
|
$gateway = new Gateway( $config ); |
| 186 |
|
|
| 187 |
|
$this->mock_http_response( |
| 188 |
|
'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
| 189 |
|
__DIR__ . '/../http/get-payment-no-object.http' |
| 190 |
|
); |
| 191 |
|
|
| 192 |
|
$payment = new Payment(); |
| 193 |
|
|
| 194 |
|
$payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
| 195 |
|
|
| 196 |
|
$this->expectException( \Throwable::class ); |
| 197 |
|
$this->expectExceptionMessage( |
| 198 |
|
'Could not JSON decode Payvision response to an object, HTTP response: "200 OK", HTTP body: "[]".' |
| 199 |
|
); |
| 200 |
|
|
| 201 |
|
$gateway->update_status( $payment ); |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
/** |
| 205 |
|
* Test WordPress error. |