Skip to content

Commit 6f3ee86

Browse files
committed
get input data from Request
1 parent 672fb90 commit 6f3ee86

File tree

6 files changed

+59
-290
lines changed

6 files changed

+59
-290
lines changed

.DS_Store

6 KB
Binary file not shown.

phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false">
10+
stopOnFailure="false">
1211
<testsuites>
1312
<testsuite name="Omnipay Test Suite">
1413
<directory>./tests/</directory>

src/Message/AcceptNotificationRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public function sendData($data)
1515
return $this->response = new AcceptNotificationResponse($this, $data);
1616
}
1717

18+
public function getTransactionId()
19+
{
20+
return $this->getNotificationResponse()->getTransactionId();
21+
}
22+
23+
public function getTransactionReference()
24+
{
25+
return $this->getNotificationResponse()->getTransactionReference();
26+
}
27+
1828
public function getTransactionStatus()
1929
{
2030
return $this->getNotificationResponse()->getTransactionStatus();

src/Message/CompletePurchaseRequest.php

Lines changed: 8 additions & 270 deletions
Original file line numberDiff line numberDiff line change
@@ -2,288 +2,26 @@
22

33
namespace Omnipay\MyPay\Message;
44

5+
use JsonException;
56
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
6-
use Omnipay\MyPay\Traits\HasAmount;
7-
use Omnipay\MyPay\Traits\HasEcho;
8-
use Omnipay\MyPay\Traits\HasKey;
9-
use Omnipay\MyPay\Traits\HasOrderInfo;
10-
use Omnipay\MyPay\Traits\HasOrderResult;
117
use Omnipay\MyPay\Traits\HasStore;
12-
use Omnipay\MyPay\Traits\HasUid;
138

149
class CompletePurchaseRequest extends BaseAbstractRequest
1510
{
1611
use HasStore;
17-
use HasKey;
18-
use HasUid;
19-
use HasOrderInfo;
20-
use HasOrderResult;
21-
use HasEcho;
22-
use HasAmount;
23-
24-
/**
25-
* 交易回傳碼(參閱附錄二).
26-
*
27-
* @param string $value
28-
* @return $this
29-
*/
30-
public function setPrc($value)
31-
{
32-
return $this->setParameter('prc', $value);
33-
}
34-
35-
/**
36-
* @return string
37-
*/
38-
public function getPrc()
39-
{
40-
return $this->getParameter('prc');
41-
}
42-
43-
/**
44-
* 卡號/VA/超商代碼
45-
*
46-
* @param string $value
47-
* @return $this
48-
*/
49-
public function setCardno($value)
50-
{
51-
return $this->setParameter('cardno', $value);
52-
}
53-
54-
/**
55-
* @return string
56-
*/
57-
public function getCardno()
58-
{
59-
return $this->getParameter('cardno');
60-
}
61-
62-
/**
63-
* 銀行交易授權碼
64-
*
65-
* @param string $value
66-
* @return $this
67-
*/
68-
public function setAcode($value)
69-
{
70-
return $this->setParameter('acode', $value);
71-
}
72-
73-
/**
74-
* @return string
75-
*/
76-
public function getAcode()
77-
{
78-
return $this->getParameter('acode');
79-
}
80-
81-
/**
82-
* 實際交易金額.
83-
*
84-
* @param string $value
85-
* @return $this
86-
*/
87-
public function setActualCost($value)
88-
{
89-
return $this->setParameter('actual_cost', $value);
90-
}
91-
92-
/**
93-
* @return string
94-
*/
95-
public function getActualCost()
96-
{
97-
return $this->getParameter('actual_cost');
98-
}
99-
100-
/**
101-
* 實際交易幣別.
102-
*
103-
* @param string $value
104-
* @return $this
105-
*/
106-
public function setActualCurrency($value)
107-
{
108-
return $this->setParameter('actual_currency', $value);
109-
}
110-
111-
/**
112-
* @return string
113-
*/
114-
public function getActualCurrency()
115-
{
116-
return $this->getParameter('actual_currency');
117-
}
118-
119-
/**
120-
* 愛心捐款金額(幣別同實際交易幣別).
121-
*
122-
* @param string $value
123-
* @return $this
124-
*/
125-
public function setLoveCost($value)
126-
{
127-
return $this->setParameter('love_cost', $value);
128-
}
129-
130-
/**
131-
* @return string
132-
*/
133-
public function getLoveCost()
134-
{
135-
return $this->getParameter('love_cost');
136-
}
137-
138-
/**
139-
* 回傳訊息.
140-
*
141-
* @param string $value
142-
* @return $this
143-
*/
144-
public function setRetmsg($value)
145-
{
146-
return $this->setParameter('retmsg', $value);
147-
}
148-
149-
/**
150-
* @return string
151-
*/
152-
public function getRetmsg()
153-
{
154-
return $this->getParameter('retmsg');
155-
}
156-
157-
/**
158-
* 交易完成時間(YYYYMMDDHHmmss).
159-
*
160-
* @param string $value
161-
* @return $this
162-
*/
163-
public function setFinishtime($value)
164-
{
165-
return $this->setParameter('finishtime', $value);
166-
}
167-
168-
/**
169-
* @return string
170-
*/
171-
public function getFinishtime()
172-
{
173-
return $this->getParameter('finishtime');
174-
}
175-
176-
/**
177-
* 扣款名稱(定期定額/定期分期交易專用).
178-
*
179-
* @param string $value
180-
* @return $this
181-
*/
182-
public function setPaymentName($value)
183-
{
184-
return $this->setParameter('payment_name', $value);
185-
}
186-
187-
/**
188-
* @return string
189-
*/
190-
public function getPaymentName()
191-
{
192-
return $this->getParameter('payment_name');
193-
}
194-
195-
/**
196-
* 期數 (定期定額/定期分期交易專用).
197-
*
198-
* @param int $value
199-
* @return $this
200-
*/
201-
public function setNois($value)
202-
{
203-
return $this->setParameter('nois', $value);
204-
}
205-
206-
/**
207-
* @return int|null
208-
*/
209-
public function getNois()
210-
{
211-
return $this->getParameter('nois');
212-
}
213-
214-
/**
215-
* 銀行代碼 虛擬帳號資訊.
216-
*
217-
* @param string $value
218-
* @return $this
219-
*/
220-
public function setBankId($value)
221-
{
222-
return $this->setParameter('bank_id', $value);
223-
}
224-
225-
/**
226-
* @return string
227-
*/
228-
public function getBankId()
229-
{
230-
return $this->getParameter('bank_id');
231-
}
232-
233-
/**
234-
* 有效日期虛擬帳號、超商代碼、無卡分期資訊.
235-
*
236-
* @param string $value
237-
* @return $this
238-
*/
239-
public function setExpiredDate($value)
240-
{
241-
return $this->setParameter('expired_date', $value);
242-
}
243-
244-
/**
245-
* @return string|null
246-
*/
247-
public function getExpiredDate()
248-
{
249-
return $this->getParameter('expired_date');
250-
}
25112

25213
/**
25314
* @return array
15+
* @throws JsonException
25416
*/
25517
public function getData()
25618
{
257-
return [
258-
'key' => $this->getKey(),
259-
'prc' => $this->getPrc(),
260-
'finishtime' => $this->getFinishtime(),
261-
'uid' => $this->getTransactionReference(),
262-
'order_id' => $this->getOrderId(),
263-
'user_id' => $this->getUserId(),
264-
'cost' => $this->getCost(),
265-
'currency' => $this->getCurrency(),
266-
'actual_cost' => $this->getActualCost(),
267-
'actual_currency' => $this->getActualCurrency(),
268-
'love_cost' => $this->getLoveCost(),
269-
'retmsg' => $this->getRetmsg(),
270-
'pfn' => $this->getPfn(),
271-
'trans_type' => $this->getTransType(),
272-
'redeem' => $this->getRedeem(),
273-
'payment_name' => $this->getPaymentName(),
274-
'nois' => $this->getNois(),
275-
'group_id' => $this->getGroupId(),
276-
'bank_id' => $this->getBankId(),
277-
'expired_date' => $this->getExpiredDate(),
278-
'result_type' => $this->getResultType(),
279-
'result_content_type' => $this->getResultContentType(),
280-
'result_content' => $this->getResultContent(),
281-
'echo_0' => $this->getEcho0(),
282-
'echo_1' => $this->getEcho1(),
283-
'echo_2' => $this->getEcho2(),
284-
'echo_3' => $this->getEcho3(),
285-
'echo_4' => $this->getEcho4(),
286-
];
19+
$data = $this->httpRequest->request->all();
20+
if (array_key_exists('result_content', $data)) {
21+
$data['result_content'] = json_decode($data['result_content'], true);
22+
}
23+
24+
return $data;
28725
}
28826

28927
/**

0 commit comments

Comments
 (0)