|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\NewebPay\Tests\Message; |
| 4 | + |
| 5 | +use Omnipay\NewebPay\Message\VoidRequest; |
| 6 | +use Omnipay\Tests\TestCase; |
| 7 | + |
| 8 | +class VoidRequestTest extends TestCase |
| 9 | +{ |
| 10 | + public function testGetData(): void |
| 11 | + { |
| 12 | + $timestamp = 1641348593; |
| 13 | + $request = new VoidRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 14 | + |
| 15 | + $this->setMockHttpResponse('VoidSuccess.txt'); |
| 16 | + |
| 17 | + $request->initialize(array_merge([ |
| 18 | + 'HashKey' => 'Fs5cX1TGqYM2PpdbE14a9H83YQSQF5jn', |
| 19 | + 'HashIV' => 'C6AcmfqJILwgnhIP', |
| 20 | + 'MerchantID' => 'MS127874575', |
| 21 | + 'testMode' => true, |
| 22 | + ], [ |
| 23 | + 'RespondType' => 'String', |
| 24 | + 'Version' => '1.0', |
| 25 | + 'TimeStamp' => $timestamp, |
| 26 | + 'Amt' => '30', |
| 27 | + 'MerchantOrderNo' => "Vanespl_ec_".$timestamp, |
| 28 | + 'IndexType' => '1', |
| 29 | + 'PayerEmail' => 'tek.chen@ezpay.com.tw', |
| 30 | + ])); |
| 31 | + |
| 32 | + $response = $request->send(); |
| 33 | + self::assertTrue($response->isSuccessful()); |
| 34 | + self::assertEquals('SUCCESS', $response->getCode()); |
| 35 | + self::assertEquals('放棄授權成功', $response->getMessage()); |
| 36 | + self::assertEquals('Vanespl_ec_1641348593', $response->getTransactionId()); |
| 37 | + self::assertEquals('23111221191660146', $response->getTransactionReference()); |
| 38 | + |
| 39 | + parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData); |
| 40 | + self::assertEquals( |
| 41 | + '61d27f528031d936b29c87802479e4e51e9cc72935abba1cade58c7524504e72a86f00fe167dca60eefc3f9c17917154a7c626641829b6bac38e3863b97c1b11a91399194a674a8fc2820c2247954fc5b16a2094e89a3fa79b15b3bf0c8dbf0677b7420af3e5c528426e1e0e6c41206b', |
| 42 | + $postData['PostData_'] |
| 43 | + ); |
| 44 | + } |
| 45 | +} |
0 commit comments