Skip to content

Commit dfdedeb

Browse files
committed
void test
1 parent 4ae603c commit dfdedeb

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

src/Message/VoidRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function sendData($data)
8686
'MerchantID_' => $this->getMerchantID(),
8787
'PostData_' => $this->encrypt($data),
8888
]));
89+
var_dump((string) $response->getBody());
8990

9091
$result = [];
9192
parse_str(trim((string) $response->getBody()), $result);

tests/GatewayTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,5 @@ public function testVoid()
137137
]);
138138

139139
self::assertInstanceOf(VoidRequest::class, $request);
140-
141-
$response = $request->send();
142-
143-
self::assertTrue($response->isSuccessful());
144-
self::assertEquals('SUCCESS', $response->getCode());
145-
self::assertEquals('放棄授權成功', $response->getMessage());
146-
self::assertEquals('Vanespl_ec_1641348593', $response->getTransactionId());
147-
self::assertEquals('23111221191660146', $response->getTransactionReference());
148-
149-
parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData);
150-
self::assertEquals(
151-
'61d27f528031d936b29c87802479e4e51e9cc72935abba1cade58c7524504e72a86f00fe167dca60eefc3f9c17917154a7c626641829b6bac38e3863b97c1b11a91399194a674a8fc2820c2247954fc5b16a2094e89a3fa79b15b3bf0c8dbf0677b7420af3e5c528426e1e0e6c41206b',
152-
$postData['PostData_']
153-
);
154140
}
155141
}

tests/Message/VoidRequestTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)