Skip to content

Commit

Permalink
FetchTransactionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Nov 13, 2023
1 parent f157737 commit a4548dd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Message/FetchTransactionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function getData()
return $value !== null && $value !== '';
});

var_dump($data);
$data['CheckValue'] = $this->checkValue($data);

return $data;
Expand Down
3 changes: 0 additions & 3 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ public function testFetchTransaction()
self::assertEquals('授權成功', $response->getMessage());
self::assertEquals('Vanespl_ec_1695795668', $response->getTransactionId());
self::assertEquals('23092714215835071', $response->getTransactionReference());

parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData);
self::assertEquals('CD326F689018E7862727547F85CECD7DD7AE0FDB7782DE2C1E46B4417245B51F', $postData['CheckValue']);
}

public function testVoid()
Expand Down
39 changes: 39 additions & 0 deletions tests/Message/FetchTransactionRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Omnipay\NewebPay\Tests\Message;

use Omnipay\NewebPay\Message\FetchTransactionRequest;
use Omnipay\Tests\TestCase;

class FetchTransactionRequestTest extends TestCase
{
public function testSendDataForJSON(): void
{
$timestamp = 1695795668;
$request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest());

$this->setMockHttpResponse('FetchTransactionSuccess.txt');

$request->initialize(array_merge([
'HashKey' => 'Fs5cX1TGqYM2PpdbE14a9H83YQSQF5jn',
'HashIV' => 'C6AcmfqJILwgnhIP',
'MerchantID' => 'MS127874575',
'testMode' => true,
], [
'TimeStamp' => $timestamp,
'transactionId' => 'Vanespl_ec_'.$timestamp,
'amount' => 30,
]));

$response = $request->send();

self::assertTrue($response->isSuccessful());
self::assertEquals('00', $response->getCode());
self::assertEquals('授權成功', $response->getMessage());
self::assertEquals('Vanespl_ec_1695795668', $response->getTransactionId());
self::assertEquals('23092714215835071', $response->getTransactionReference());

parse_str((string) $this->getMockClient()->getLastRequest()->getBody(), $postData);
self::assertEquals('CD326F689018E7862727547F85CECD7DD7AE0FDB7782DE2C1E46B4417245B51F', $postData['CheckValue']);
}
}

0 comments on commit a4548dd

Please sign in to comment.