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