Skip to content

Commit

Permalink
test completePurchase
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Nov 11, 2023
1 parent 638ca98 commit 514f757
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ public function testPurchase(): void
], $response->getRedirectData());
}

public function testCompletePurchase()
{
$httpRequest = $this->getHttpRequest();
$httpRequest->request->add([
'Status' => 'SUCCESS',
'MerchantID' => 'MS127874575',
'Version' => '2.0',
'TradeInfo' => 'ee11d1501e6dc8433c75988258f2343d11f4d0a423be672e8e02aaf373c53c2363aeffdb4992579693277359b3e449ebe644d2075fdfbc10150b1c40e7d24cb215febefdb85b16a5cde449f6b06c58a5510d31e8d34c95284d459ae4b52afc1509c2800976a5c0b99ef24cfd28a2dfc8004215a0c98a1d3c77707773c2f2132f9a9a4ce3475cb888c2ad372485971876f8e2fec0589927544c3463d30c785c2d3bd947c06c8c33cf43e131f57939e1f7e3b3d8c3f08a84f34ef1a67a08efe177f1e663ecc6bedc7f82640a1ced807b548633cfa72d060864271ec79854ee2f5a170aa902000e7c61d1269165de330fce7d10663d1668c711571776365bfdcd7ddc915dcb90d31a9f27af9b79a443ca8302e508b0dbaac817d44cfc44247ae613075dde4ac960f1bdff4173b915e4344bc4567bd32e86be7d796e6d9b9cf20476e4996e98ccc315f1ed03a34139f936797d971f2a3f90bc18f8a155a290bcbcf04f4277171c305bf554f5cba243154b30082748a81f2e5aa432ef9950cc9668cd4330ef7c37537a6dcb5e6ef01b4eca9705e4b097cf6913ee96e81d0389e5f775',
'TradeSha' => 'C80876AEBAC0036268C0E240E5BFF69C0470DE9606EEE083C5C8DD64FDB3347A',
]);

$response = $this->gateway->completePurchase()->send();

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

public function testAcceptNotification()
{
$httpRequest = $this->getHttpRequest();
Expand Down
33 changes: 33 additions & 0 deletions tests/Message/AcceptNotificationRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Omnipay\NewebPay\Tests\Message;

use Omnipay\Common\Message\NotificationInterface;
use Omnipay\NewebPay\Message\AcceptNotificationRequest;
use Omnipay\Tests\TestCase;

class AcceptNotificationRequestTest extends TestCase
{
public function testGetData(): void
{
$httpRequest = $this->getHttpRequest();
$httpRequest->request->add([
'Status' => 'SUCCESS',
'MerchantID' => 'MS127874575',
'Version' => '2.0',
'TradeInfo' => 'ee11d1501e6dc8433c75988258f2343d11f4d0a423be672e8e02aaf373c53c2363aeffdb4992579693277359b3e449ebe644d2075fdfbc10150b1c40e7d24cb215febefdb85b16a5cde449f6b06c58a5510d31e8d34c95284d459ae4b52afc1509c2800976a5c0b99ef24cfd28a2dfc8004215a0c98a1d3c77707773c2f2132f9a9a4ce3475cb888c2ad372485971876f8e2fec0589927544c3463d30c785c2d3bd947c06c8c33cf43e131f57939e1f7e3b3d8c3f08a84f34ef1a67a08efe177f1e663ecc6bedc7f82640a1ced807b548633cfa72d060864271ec79854ee2f5a170aa902000e7c61d1269165de330fce7d10663d1668c711571776365bfdcd7ddc915dcb90d31a9f27af9b79a443ca8302e508b0dbaac817d44cfc44247ae613075dde4ac960f1bdff4173b915e4344bc4567bd32e86be7d796e6d9b9cf20476e4996e98ccc315f1ed03a34139f936797d971f2a3f90bc18f8a155a290bcbcf04f4277171c305bf554f5cba243154b30082748a81f2e5aa432ef9950cc9668cd4330ef7c37537a6dcb5e6ef01b4eca9705e4b097cf6913ee96e81d0389e5f775',
'TradeSha' => 'C80876AEBAC0036268C0E240E5BFF69C0470DE9606EEE083C5C8DD64FDB3347A',
]);
$request = new AcceptNotificationRequest($this->getHttpClient(), $httpRequest);
$request->initialize([
'HashKey' => 'Fs5cX1TGqYM2PpdbE14a9H83YQSQF5jn',
'HashIV' => 'C6AcmfqJILwgnhIP',
'MerchantID' => 'MS127874575',
'testMode' => false,
]);

self::assertEquals('23092714215835071', $request->getTransactionReference());
self::assertEquals(NotificationInterface::STATUS_COMPLETED, $request->getTransactionStatus());
self::assertEquals('授權成功', $request->getMessage());
}
}

0 comments on commit 514f757

Please sign in to comment.