From b171f201b8df0ba05a6d9ec58cd7fb87bfe47fd6 Mon Sep 17 00:00:00 2001 From: recca0120 Date: Sun, 13 Oct 2024 03:18:31 +0800 Subject: [PATCH] PayMode --- src/Message/XWallet/PurchaseRequest.php | 1 + src/Traits/XWallet/HasEPays.php | 18 ++++++++++++++++++ src/XWalletGateway.php | 1 + tests/Message/XWallet/PurchaseRequestTest.php | 5 ++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Message/XWallet/PurchaseRequest.php b/src/Message/XWallet/PurchaseRequest.php index 73285cd..b3d5cd3 100644 --- a/src/Message/XWallet/PurchaseRequest.php +++ b/src/Message/XWallet/PurchaseRequest.php @@ -92,6 +92,7 @@ public function getData() return [ 'FirmOrderNo' => $this->getTransactionId(), 'PayType' => (int) $this->getPaymentMethod() ?: 1, + 'PayMode' => (int) $this->getPayMode() ?: 1, 'Price' => (int) $this->getAmount(), 'Mobile' => $this->getMobile(), ]; diff --git a/src/Traits/XWallet/HasEPays.php b/src/Traits/XWallet/HasEPays.php index 5c3904d..2d3baae 100644 --- a/src/Traits/XWallet/HasEPays.php +++ b/src/Traits/XWallet/HasEPays.php @@ -28,6 +28,24 @@ public function setHashIV($value) return $this->setParameter('HashIV', $value); } + /** + * 購買模式:1.點數卡、4.模式A、5.模式B + * + * @param int $value + */ + public function setPayMode($value) + { + return $this->setParameter('PayMode', $value); + } + + /** + * @return ?int + */ + public function getPayMode() + { + return $this->getParameter('PayMode'); + } + /** * @throws InvalidResponseException */ diff --git a/src/XWalletGateway.php b/src/XWalletGateway.php index 9b961d9..8426046 100644 --- a/src/XWalletGateway.php +++ b/src/XWalletGateway.php @@ -25,6 +25,7 @@ public function getDefaultParameters(): array return [ 'HashKey' => '', 'HashIV' => '', + 'PayMode' => 1, 'testMode' => false, ]; } diff --git a/tests/Message/XWallet/PurchaseRequestTest.php b/tests/Message/XWallet/PurchaseRequestTest.php index d66e834..75b8156 100644 --- a/tests/Message/XWallet/PurchaseRequestTest.php +++ b/tests/Message/XWallet/PurchaseRequestTest.php @@ -24,6 +24,7 @@ public function testGetData(): void 'transactionId' => 'test202309011123001', 'amount' => 100, 'PayType' => 1, + 'PayMode' => 4, 'Mobile' => '0912345678', ]; $request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); @@ -32,6 +33,7 @@ public function testGetData(): void self::assertEquals([ 'FirmOrderNo' => 'test202309011123001', 'PayType' => 1, + 'PayMode' => 4, 'Price' => 100, 'Mobile' => '0912345678', ], $request->getData()); @@ -43,6 +45,7 @@ public function testSendData() 'transactionId' => 'test202309011123001', 'amount' => 100, 'PayType' => 1, + 'PayMode' => 4, 'Mobile' => '0912345678', ]; $request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); @@ -55,7 +58,7 @@ public function testSendData() self::assertEquals('POST', $response->getRedirectMethod()); self::assertEquals([ 'Hashkey' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - 'data' => 'u4OlyM8T0QFQPQkL8XhzfxH5QVFmVcYqUW+hXuic5a+y9cIjEY8qr3gOoIUmOZLufZtW/3fDRNP2yQAR2kt4Uaqpq24cR9GTgQBXg5eZDjEzsv4hCE+vXqHdQeNBOe+R', + 'data' => 'u4OlyM8T0QFQPQkL8XhzfxH5QVFmVcYqUW+hXuic5a+y9cIjEY8qr3gOoIUmOZLuxQ/kHvhMtvcaw2MdnEAgcJfL2SjqVkp3B1MtO3w4yDKWmAMbaYfTxuP2O3T8d4qa', ], $response->getRedirectData()); } }