1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatCsobGateway\Call\Masterpass; |
4
|
|
|
|
5
|
|
|
use DateTimeImmutable; |
6
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SlevomatCsobGateway\Api\ApiClient; |
9
|
|
|
use SlevomatCsobGateway\Api\Response; |
10
|
|
|
use SlevomatCsobGateway\Api\ResponseCode; |
11
|
|
|
use SlevomatCsobGateway\Call\PaymentStatus; |
12
|
|
|
use SlevomatCsobGateway\Call\ResultCode; |
13
|
|
|
|
14
|
|
|
class StandardCheckoutRequestTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
public function testSend(): void |
18
|
|
|
{ |
19
|
|
|
/** @var ApiClient|MockObject $apiClient */ |
20
|
|
|
$apiClient = $this->getMockBuilder(ApiClient::class) |
21
|
|
|
->disableOriginalConstructor() |
22
|
|
|
->getMock(); |
23
|
|
|
|
24
|
|
|
$apiClient->expects(self::once())->method('post') |
25
|
|
|
->with('masterpass/standard/checkout', [ |
26
|
|
|
'merchantId' => '012345', |
27
|
|
|
'payId' => '123456789', |
28
|
|
|
'callbackUrl' => 'https://www.vasobchod.cz/masterpass/callback', |
29
|
|
|
'shippingLocationProfile' => 'SP-0001', |
30
|
|
|
]) |
31
|
|
|
->willReturn( |
32
|
|
|
new Response(ResponseCode::get(ResponseCode::S200_OK), [ |
33
|
|
|
'payId' => '123456789', |
34
|
|
|
'dttm' => '20140425131559', |
35
|
|
|
'resultCode' => 0, |
36
|
|
|
'resultMessage' => 'OK', |
37
|
|
|
'paymentStatus' => 1, |
38
|
|
|
'lightboxParams' => [ |
39
|
|
|
'requestToken' => '6a79bf9e320a0460d08aee7ad154f7dab4e19503', |
40
|
|
|
'callbackUrl' => 'https://www.vasobchod.cz/masterpass/callback', |
41
|
|
|
'merchantCheckoutId' => 'a4a6w4vzajswviqy5oeu11irc2e3yb51ws', |
42
|
|
|
'allowedCardTypes' => 'master,visa', |
43
|
|
|
'suppressShippingAddressEnable' => 'true', |
44
|
|
|
'loyaltyEnabled' => 'false', |
45
|
|
|
'version' => 'v6', |
46
|
|
|
'shippingLocationProfile' => 'SP-0001', |
47
|
|
|
], |
48
|
|
|
]) |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
$paymentRequest = new StandardCheckoutRequest( |
52
|
|
|
'012345', |
53
|
|
|
'123456789', |
54
|
|
|
'https://www.vasobchod.cz/masterpass/callback', |
55
|
|
|
'SP-0001' |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
$checkoutResponse = $paymentRequest->send($apiClient); |
59
|
|
|
|
60
|
|
|
self::assertSame('123456789', $checkoutResponse->getPayId()); |
61
|
|
|
self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $checkoutResponse->getResponseDateTime()); |
62
|
|
|
self::assertEquals(ResultCode::get(ResultCode::C0_OK), $checkoutResponse->getResultCode()); |
63
|
|
|
self::assertSame('OK', $checkoutResponse->getResultMessage()); |
64
|
|
|
self::assertEquals(PaymentStatus::get(PaymentStatus::S1_CREATED), $checkoutResponse->getPaymentStatus()); |
65
|
|
|
self::assertNotNull($checkoutResponse->getLightboxParams()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|