Skip to content

Commit a4548dd

Browse files
committed
FetchTransactionTest
1 parent f157737 commit a4548dd

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/Message/FetchTransactionRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function getData()
5959
return $value !== null && $value !== '';
6060
});
6161

62+
var_dump($data);
6263
$data['CheckValue'] = $this->checkValue($data);
6364

6465
return $data;

tests/GatewayTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ public function testFetchTransaction()
116116
self::assertEquals('授權成功', $response->getMessage());
117117
self::assertEquals('Vanespl_ec_1695795668', $response->getTransactionId());
118118
self::assertEquals('23092714215835071', $response->getTransactionReference());
119-
120-
parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData);
121-
self::assertEquals('CD326F689018E7862727547F85CECD7DD7AE0FDB7782DE2C1E46B4417245B51F', $postData['CheckValue']);
122119
}
123120

124121
public function testVoid()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Omnipay\NewebPay\Tests\Message;
4+
5+
use Omnipay\NewebPay\Message\FetchTransactionRequest;
6+
use Omnipay\Tests\TestCase;
7+
8+
class FetchTransactionRequestTest extends TestCase
9+
{
10+
public function testSendDataForJSON(): void
11+
{
12+
$timestamp = 1695795668;
13+
$request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest());
14+
15+
$this->setMockHttpResponse('FetchTransactionSuccess.txt');
16+
17+
$request->initialize(array_merge([
18+
'HashKey' => 'Fs5cX1TGqYM2PpdbE14a9H83YQSQF5jn',
19+
'HashIV' => 'C6AcmfqJILwgnhIP',
20+
'MerchantID' => 'MS127874575',
21+
'testMode' => true,
22+
], [
23+
'TimeStamp' => $timestamp,
24+
'transactionId' => 'Vanespl_ec_'.$timestamp,
25+
'amount' => 30,
26+
]));
27+
28+
$response = $request->send();
29+
30+
self::assertTrue($response->isSuccessful());
31+
self::assertEquals('00', $response->getCode());
32+
self::assertEquals('授權成功', $response->getMessage());
33+
self::assertEquals('Vanespl_ec_1695795668', $response->getTransactionId());
34+
self::assertEquals('23092714215835071', $response->getTransactionReference());
35+
36+
parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData);
37+
self::assertEquals('CD326F689018E7862727547F85CECD7DD7AE0FDB7782DE2C1E46B4417245B51F', $postData['CheckValue']);
38+
}
39+
}

0 commit comments

Comments
 (0)