Skip to content

Commit 0b84766

Browse files
committed
get amount directly
1 parent 2a6698c commit 0b84766

11 files changed

+25
-23
lines changed

src/Gateway.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function getDefaultParameters()
4444
}
4545

4646
/**
47-
* @param array $options
4847
* @return RequestInterface
4948
*/
5049
public function purchase(array $options = [])
@@ -53,7 +52,6 @@ public function purchase(array $options = [])
5352
}
5453

5554
/**
56-
* @param array $options
5755
* @return RequestInterface
5856
*/
5957
public function completePurchase(array $options = [])
@@ -62,7 +60,6 @@ public function completePurchase(array $options = [])
6260
}
6361

6462
/**
65-
* @param array $options
6663
* @return RequestInterface|NotificationInterface
6764
*/
6865
public function acceptNotification(array $options = [])
@@ -71,7 +68,6 @@ public function acceptNotification(array $options = [])
7168
}
7269

7370
/**
74-
* @param array $options
7571
* @return RequestInterface
7672
*/
7773
public function fetchTransaction(array $options = [])
@@ -80,7 +76,6 @@ public function fetchTransaction(array $options = [])
8076
}
8177

8278
/**
83-
* @param array $options
8479
* @return RequestInterface
8580
*/
8681
public function refund(array $options = [])

src/Message/FetchTransactionRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function sendData($data)
5858
}
5959

6060
/**
61-
* @param $data
6261
* @return array
6362
*
6463
* @throws RtnException

src/Message/PurchaseRequest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Omnipay\Common\Exception\InvalidRequestException;
77
use Omnipay\Common\Message\AbstractRequest;
88
use Omnipay\ECPay\Item;
9+
use Omnipay\ECPay\Traits\HasAmount;
910
use Omnipay\ECPay\Traits\HasATMFields;
1011
use Omnipay\ECPay\Traits\HasATMOrCVSOrBARCODEFields;
1112
use Omnipay\ECPay\Traits\HasCreditFields;
@@ -32,6 +33,7 @@ class PurchaseRequest extends AbstractRequest
3233
use HasATMFields;
3334
use HasCVSOrBARCODEFields;
3435
use HasATMOrCVSOrBARCODEFields;
36+
use HasAmount;
3537

3638
protected $liveEndpoint = 'https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5';
3739

@@ -125,12 +127,14 @@ private function prepareItems()
125127
$currency = $this->getCurrency() ?: 'TWD';
126128

127129
if (! $items) {
128-
return [new Item([
129-
'Name' => $this->getDescription(),
130-
'Price' => $this->getAmount(),
131-
'Currency' => $currency,
132-
'Quantity' => 1,
133-
])];
130+
return [
131+
new Item([
132+
'Name' => $this->getDescription(),
133+
'Price' => $this->getAmount(),
134+
'Currency' => $currency,
135+
'Quantity' => 1,
136+
]),
137+
];
134138
}
135139

136140
return array_map(static function ($item) use ($currency) {

src/Message/RefundRequest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Ecpay\Sdk\Exceptions\RtnException;
66
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\ECPay\Traits\HasAmount;
78
use Omnipay\ECPay\Traits\HasDefaults;
89
use Omnipay\ECPay\Traits\HasECPay;
910
use Omnipay\ECPay\Traits\HasMerchantTradeNo;
@@ -15,6 +16,7 @@ class RefundRequest extends AbstractRequest
1516
use HasDefaults;
1617
use HasMerchantTradeNo;
1718
use HasTotalAmount;
19+
use HasAmount;
1820

1921
public function setTradeNo($value)
2022
{

src/Traits/HasAmount.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Omnipay\ECPay\Traits;
4+
5+
trait HasAmount
6+
{
7+
public function getAmount()
8+
{
9+
return $this->getParameter('amount');
10+
}
11+
}

tests/Message/AcceptNotificationRequestTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public function testGetData()
5252

5353
/**
5454
* @depends testGetData
55-
*
56-
* @param $results
5755
*/
5856
public function testSendData($results)
5957
{

tests/Message/CompletePurchaseRequestTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public function testGetData()
5151

5252
/**
5353
* @depends testGetData
54-
*
55-
* @param $result
5654
*/
5755
public function testSendData($result)
5856
{

tests/Message/FetchTransactionRequestTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public function testGetData()
3535

3636
/**
3737
* @depends testGetData
38-
*
39-
* @param $result
4038
*/
4139
public function testSendData($result)
4240
{

tests/Message/RefundRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testGetData()
2222
'MerchantTradeNo' => '2821567410556',
2323
'TradeNo' => '1909021549160081',
2424
'Action' => 'R',
25-
'TotalAmount' => '1000.00',
25+
'TotalAmount' => '1000',
2626
], $request->getData());
2727
}
2828
}

tests/Message/VoidRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testGetData()
2222
'MerchantTradeNo' => '2821567410556',
2323
'TradeNo' => '1909021549160081',
2424
'Action' => 'N',
25-
'TotalAmount' => '1000.00',
25+
'TotalAmount' => '1000',
2626
], $request->getData());
2727
}
2828
}

0 commit comments

Comments
 (0)