Skip to content

Commit

Permalink
PayMode
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Oct 13, 2024
1 parent 415c9fd commit b171f20
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Message/XWallet/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
18 changes: 18 additions & 0 deletions src/Traits/XWallet/HasEPays.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions src/XWalletGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function getDefaultParameters(): array
return [
'HashKey' => '',
'HashIV' => '',
'PayMode' => 1,
'testMode' => false,
];
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Message/XWallet/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -32,6 +33,7 @@ public function testGetData(): void
self::assertEquals([
'FirmOrderNo' => 'test202309011123001',
'PayType' => 1,
'PayMode' => 4,
'Price' => 100,
'Mobile' => '0912345678',
], $request->getData());
Expand All @@ -43,6 +45,7 @@ public function testSendData()
'transactionId' => 'test202309011123001',
'amount' => 100,
'PayType' => 1,
'PayMode' => 4,
'Mobile' => '0912345678',
];
$request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
Expand All @@ -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());
}
}

0 comments on commit b171f20

Please sign in to comment.