diff --git a/src/Gateway.php b/src/Gateway.php index e5d9261..6edd1e8 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -44,7 +44,6 @@ public function getDefaultParameters() } /** - * @param array $options * @return RequestInterface */ public function purchase(array $options = []) @@ -53,7 +52,6 @@ public function purchase(array $options = []) } /** - * @param array $options * @return RequestInterface */ public function completePurchase(array $options = []) @@ -62,7 +60,6 @@ public function completePurchase(array $options = []) } /** - * @param array $options * @return RequestInterface|NotificationInterface */ public function acceptNotification(array $options = []) @@ -71,7 +68,6 @@ public function acceptNotification(array $options = []) } /** - * @param array $options * @return RequestInterface */ public function fetchTransaction(array $options = []) @@ -80,7 +76,6 @@ public function fetchTransaction(array $options = []) } /** - * @param array $options * @return RequestInterface */ public function refund(array $options = []) diff --git a/src/Message/FetchTransactionRequest.php b/src/Message/FetchTransactionRequest.php index 83cb2c0..ebb5444 100644 --- a/src/Message/FetchTransactionRequest.php +++ b/src/Message/FetchTransactionRequest.php @@ -58,7 +58,6 @@ public function sendData($data) } /** - * @param $data * @return array * * @throws RtnException diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index efdc394..042e064 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -6,6 +6,7 @@ use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\ECPay\Item; +use Omnipay\ECPay\Traits\HasAmount; use Omnipay\ECPay\Traits\HasATMFields; use Omnipay\ECPay\Traits\HasATMOrCVSOrBARCODEFields; use Omnipay\ECPay\Traits\HasCreditFields; @@ -32,6 +33,7 @@ class PurchaseRequest extends AbstractRequest use HasATMFields; use HasCVSOrBARCODEFields; use HasATMOrCVSOrBARCODEFields; + use HasAmount; protected $liveEndpoint = 'https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5'; @@ -125,12 +127,14 @@ private function prepareItems() $currency = $this->getCurrency() ?: 'TWD'; if (! $items) { - return [new Item([ - 'Name' => $this->getDescription(), - 'Price' => $this->getAmount(), - 'Currency' => $currency, - 'Quantity' => 1, - ])]; + return [ + new Item([ + 'Name' => $this->getDescription(), + 'Price' => $this->getAmount(), + 'Currency' => $currency, + 'Quantity' => 1, + ]), + ]; } return array_map(static function ($item) use ($currency) { diff --git a/src/Message/RefundRequest.php b/src/Message/RefundRequest.php index 80379ec..2f1fd71 100644 --- a/src/Message/RefundRequest.php +++ b/src/Message/RefundRequest.php @@ -4,6 +4,7 @@ use Ecpay\Sdk\Exceptions\RtnException; use Omnipay\Common\Message\AbstractRequest; +use Omnipay\ECPay\Traits\HasAmount; use Omnipay\ECPay\Traits\HasDefaults; use Omnipay\ECPay\Traits\HasECPay; use Omnipay\ECPay\Traits\HasMerchantTradeNo; @@ -15,6 +16,7 @@ class RefundRequest extends AbstractRequest use HasDefaults; use HasMerchantTradeNo; use HasTotalAmount; + use HasAmount; public function setTradeNo($value) { diff --git a/src/Traits/HasAmount.php b/src/Traits/HasAmount.php new file mode 100644 index 0000000..5c84dfc --- /dev/null +++ b/src/Traits/HasAmount.php @@ -0,0 +1,11 @@ +getParameter('amount'); + } +} diff --git a/tests/Message/AcceptNotificationRequestTest.php b/tests/Message/AcceptNotificationRequestTest.php index 00833b0..75c382e 100644 --- a/tests/Message/AcceptNotificationRequestTest.php +++ b/tests/Message/AcceptNotificationRequestTest.php @@ -52,8 +52,6 @@ public function testGetData() /** * @depends testGetData - * - * @param $results */ public function testSendData($results) { diff --git a/tests/Message/CompletePurchaseRequestTest.php b/tests/Message/CompletePurchaseRequestTest.php index c63243d..ee84c50 100644 --- a/tests/Message/CompletePurchaseRequestTest.php +++ b/tests/Message/CompletePurchaseRequestTest.php @@ -51,8 +51,6 @@ public function testGetData() /** * @depends testGetData - * - * @param $result */ public function testSendData($result) { diff --git a/tests/Message/FetchTransactionRequestTest.php b/tests/Message/FetchTransactionRequestTest.php index cf80169..9cc3e82 100644 --- a/tests/Message/FetchTransactionRequestTest.php +++ b/tests/Message/FetchTransactionRequestTest.php @@ -35,8 +35,6 @@ public function testGetData() /** * @depends testGetData - * - * @param $result */ public function testSendData($result) { diff --git a/tests/Message/RefundRequestTest.php b/tests/Message/RefundRequestTest.php index 0af50ea..e996139 100644 --- a/tests/Message/RefundRequestTest.php +++ b/tests/Message/RefundRequestTest.php @@ -22,7 +22,7 @@ public function testGetData() 'MerchantTradeNo' => '2821567410556', 'TradeNo' => '1909021549160081', 'Action' => 'R', - 'TotalAmount' => '1000.00', + 'TotalAmount' => '1000', ], $request->getData()); } } diff --git a/tests/Message/VoidRequestTest.php b/tests/Message/VoidRequestTest.php index d282ce1..7b24a74 100644 --- a/tests/Message/VoidRequestTest.php +++ b/tests/Message/VoidRequestTest.php @@ -22,7 +22,7 @@ public function testGetData() 'MerchantTradeNo' => '2821567410556', 'TradeNo' => '1909021549160081', 'Action' => 'N', - 'TotalAmount' => '1000.00', + 'TotalAmount' => '1000', ], $request->getData()); } } diff --git a/tests/Stubs/StubGateway.php b/tests/Stubs/StubGateway.php index c5007a5..f782a05 100644 --- a/tests/Stubs/StubGateway.php +++ b/tests/Stubs/StubGateway.php @@ -8,7 +8,6 @@ class StubGateway extends Gateway { /** - * @param array $options * @return RequestInterface */ public function fetchTransaction(array $options = []) @@ -17,7 +16,6 @@ public function fetchTransaction(array $options = []) } /** - * @param array $options * @return RequestInterface */ public function refund(array $options = []) @@ -26,7 +24,6 @@ public function refund(array $options = []) } /** - * @param array $options * @return RequestInterface */ public function void(array $options = [])