1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatCsobGateway\Call\ApplePay; |
4
|
|
|
|
5
|
|
|
use DateTimeImmutable; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
use SlevomatCsobGateway\Api\ApiClient; |
8
|
|
|
use SlevomatCsobGateway\Api\Response; |
9
|
|
|
use SlevomatCsobGateway\Api\ResponseCode; |
10
|
|
|
use SlevomatCsobGateway\Call\PaymentStatus; |
11
|
|
|
use SlevomatCsobGateway\Call\ResultCode; |
12
|
|
|
|
13
|
|
|
class StartApplePayRequestTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
public function testSend(): void |
17
|
|
|
{ |
18
|
|
|
$apiClient = $this->getMockBuilder(ApiClient::class) |
19
|
|
|
->disableOriginalConstructor() |
20
|
|
|
->getMock(); |
21
|
|
|
|
22
|
|
|
$apiClient->expects(self::once())->method('post') |
23
|
|
|
->with('applepay/start', [ |
24
|
|
|
'merchantId' => '012345', |
25
|
|
|
'payId' => 'ef08b6e9f22345c', |
26
|
|
|
'payload' => 'eyJmb28iOiJiYXIifQ==', |
27
|
|
|
]) |
28
|
|
|
->willReturn( |
29
|
|
|
new Response(ResponseCode::get(ResponseCode::S200_OK), [ |
30
|
|
|
'payId' => 'ef08b6e9f22345c', |
31
|
|
|
'dttm' => '20190425131559', |
32
|
|
|
'resultCode' => 0, |
33
|
|
|
'resultMessage' => 'OK', |
34
|
|
|
'paymentStatus' => 2, |
35
|
|
|
]) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$initPaymentRequest = new StartApplePayRequest( |
39
|
|
|
'012345', |
40
|
|
|
'ef08b6e9f22345c', |
41
|
|
|
['foo' => 'bar'], |
42
|
|
|
null |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$paymentResponse = $initPaymentRequest->send($apiClient); |
46
|
|
|
|
47
|
|
|
self::assertSame('ef08b6e9f22345c', $paymentResponse->getPayId()); |
48
|
|
|
self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20190425131559'), $paymentResponse->getResponseDateTime()); |
49
|
|
|
self::assertEquals(ResultCode::get(ResultCode::C0_OK), $paymentResponse->getResultCode()); |
50
|
|
|
self::assertSame('OK', $paymentResponse->getResultMessage()); |
51
|
|
|
self::assertEquals(PaymentStatus::get(PaymentStatus::S2_IN_PROGRESS), $paymentResponse->getPaymentStatus()); |
52
|
|
|
self::assertNull($paymentResponse->getAuthCode()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|