-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
172 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
use Omnipay\Gomypay\Traits\HasGomypay; | ||
|
||
class FetchTransactionRequest extends AbstractRequest | ||
{ | ||
use HasGomypay; | ||
|
||
public function getData() | ||
{ | ||
$this->validate('transactionId'); | ||
|
||
return [ | ||
'Order_No' => $this->getTransactionId(), | ||
'CustomerId' => $this->getCustomerId(), | ||
'Str_Check' => $this->getStrCheck(), | ||
]; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$response = $this->httpClient->request( | ||
'POST', | ||
$this->getUrl('CallOrder.aspx'), | ||
['content-type' => 'application/json'], | ||
http_build_query($data) | ||
); | ||
$data = json_decode((string) $response->getBody(), true); | ||
|
||
return $this->response = new FetchTransactionResponse($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
class FetchTransactionResponse extends AbstractResponse | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return (int) $this->getCode() === 1; | ||
} | ||
|
||
public function getCode() | ||
{ | ||
return $this->data['result']; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return $this->data['ret_msg']; | ||
} | ||
|
||
public function getTransactionId() | ||
{ | ||
return $this->data['e_orderno']; | ||
} | ||
|
||
public function getTransactionReference() | ||
{ | ||
return $this->data['OrderID']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Traits; | ||
|
||
trait HasOrderNo | ||
{ | ||
public function getOrderNo() | ||
{ | ||
return $this->getTransactionId(); | ||
} | ||
|
||
/** | ||
* 交易單號,如無則自動帶入系統預設交易單號 | ||
* 若使用系統預設交易畫面,交易單號不可為無 | ||
*/ | ||
public function setOrderNo($value) | ||
{ | ||
return $this->setTransactionId($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Tests\Message; | ||
|
||
use Omnipay\Gomypay\Message\FetchTransactionRequest; | ||
use Omnipay\Tests\TestCase; | ||
|
||
class FetchTransactionRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var FetchTransactionRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize([ | ||
'CustomerId' => '83759795', | ||
'Str_Check' => 'tak8ebh0qg1irbs72t1a34f2qdc7jyc7', | ||
'test_mode' => true, | ||
|
||
'transaction_id' => '2024101311', | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$this->setMockHttpResponse('FetchTransactionSuccess.txt'); | ||
var_dump($this->request->send()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
HTTP/1.1 200 OK | ||
Server: Apache | ||
Date: Sun, 11 May 2014 21:17:31 GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Status: 200 OK | ||
|
||
{ | ||
"result": "1", | ||
"ret_msg": "已繳費", | ||
"OrderID": "2019012300000000569", | ||
"e_Cur": "NT", | ||
"e_money": "10000", | ||
"PayAmount": "10000", | ||
"e_date": "20190123", | ||
"e_time": "18:37:59", | ||
"p_date": "20190123", | ||
"p_time": "18:42:17", | ||
"e_orderno": "AH15482399052114", | ||
"e_no": "42816104A05", | ||
"e_outlay": "26", | ||
"bankname": "", | ||
"avcode": "", | ||
"Buyer_Name": "User", | ||
"Buyer_Mail": "paymoney159@gmail.com", | ||
"Buyer_Telm": "0900000000", | ||
"Buyer_Memo": "此為商城虛擬商品購買,並非實體商品交易,請勿受騙上當,並請勿代他人繳款儲值,小心觸法", | ||
"Creditcard_No": "", | ||
"Installment": "0", | ||
"Shop_PaymentCode": "1610A8259J3291", | ||
"Virtual_Account": "", | ||
"e_PayInfo": "", | ||
"Send_Type": "6", | ||
"Goods_Return": "0", | ||
"Goods_Return_Statu": "", | ||
"pay_result": "1", | ||
"LimitDate": "20190123", | ||
"Market_ID": "FM", | ||
"Shop_Store_Name": "中壢興廣店(桃園市中壢區新中北路二段489號)" | ||
} |