Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe committed Dec 15, 2017
1 parent cd3d31f commit 489e182
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ $response->isSuccessful();
$response->getTransactionId();
$response->getAmount();
$response->getCurrency();
$response->getCard(); // card number
$response->getCardNumber(); // card number
$response->getMessage(); // message response from MyCard query api
$response->getData(); // output RAW data
```
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"omnipay/common": "~2.0"
},
"require-dev": {
"illuminate/support": "~v5.4",
"omnipay/tests": "~2.0"
}
}
4 changes: 2 additions & 2 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


use Omnipay\Common\AbstractGateway;
use Omnipay\MyCard\Message\compareTransaction;
use Omnipay\MyCard\Message\CompareTransaction;

class Gateway extends AbstractGateway
{
Expand Down Expand Up @@ -80,7 +80,7 @@ public function fetchTransaction(array $parameters = array())

public function compareTransaction()
{
return new compareTransaction();
return new CompareTransaction();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

use DateTime;
use DateTimeZone;
use Omnipay\MyCard\Exception\DefaultException;
use Symfony\Component\HttpFoundation\Request as HttpRequest;

class compareTransaction
class CompareTransaction
{

protected $data;
Expand Down Expand Up @@ -46,6 +47,7 @@ public function getParams()

/**
* 设置数据
* INGAME: 卡片儲值; COSTPOINT: 會員扣點; (Billing): 其他代碼為小額付費之付費方式
* $data = [
* [
* 'type' => 'INGAME',
Expand All @@ -69,9 +71,6 @@ public function setData(array $data = [])

foreach ($data as $value) {
$dateTime->setTimestamp($value['time']);
// INGAME : 卡片儲值
// COSTPOINT: 會員扣點
// (Billing): 其他代碼為小額付費之付費方式
$this->data .=
$value['type'] . ',' .
$value['transactionReference'] . ',' .
Expand All @@ -95,7 +94,7 @@ public function send()

public function error()
{
exit('IP Not Allowed');
throw new DefaultException('IP Not Allowed');
}


Expand Down
2 changes: 1 addition & 1 deletion src/Message/FetchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getCurrency()
}


public function getCard()
public function getCardNumber()
{
return $this->getData()['MyCardTradeNo'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Message/NotificationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function getReturnParams()
$this->setTransactionId($FacTradeSeq);
$this->setParameter('code', $ReturnCode);
$this->setParameter('message', $ReturnMsg);
$this->setParameter('raw', $this->httpRequest->request->all());
$this->setParameter('raw', $this->httpRequest->request->all() + $this->httpRequest->query->all());
}


Expand Down
18 changes: 9 additions & 9 deletions src/Message/NotificationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ public function confirm()
{
// 查询
$fetchResponse = $this->request->fetchTransaction($this->token);
$this->data['raw'] = $fetchResponse->getData();
if ($fetchResponse->getData()['PayResult'] != 3) { // 交易成功為3; 交易失敗為0;
$this->status = static::STATUS_FAILED;
}
else {
$this->data['raw'] = $fetchResponse->getData(); // 用查询数据覆盖掉通知过来的数据

$this->status = static::STATUS_FAILED;
if ($fetchResponse->getData()['PayResult'] == 3) { // 交易成功為3; 交易失敗為0;
$this->status = static::STATUS_COMPLETED;
}


// 确认订单
// TODO :: 二次确认会失败
$confirmResponse = $this->request->confirmTransaction();
if ($confirmResponse->getData()['ReturnCode'] == 1) {
// TODO :: 二次确认会失败
// $this->status = static::STATUS_COMPLETED;
$this->data['raw']['confirm'] = true;
}
else {
$this->data['raw']['confirm'] = false;
}
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Message/TokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getToken()
'FacServiceId' => $this->getAppId(),
'FacTradeSeq' => $this->getTransactionId(),
'TradeType' => $this->getTradeType(),
'ServerId' => $this->getServerId() ?: '', // 服务器ID
'ServerId' => $this->getServerId() ?: '', // 服务器ID
'CustomerId' => $this->getAccountId() ?: $this->getTransactionId(), // 用户ID
'PaymentType' => $this->getPaymentType() ?: '',
'ItemCode' => $this->getItemCode() ?: '',
Expand Down

0 comments on commit 489e182

Please sign in to comment.