-
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
6 changed files
with
135 additions
and
1 deletion.
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,62 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
use Omnipay\Gomypay\Traits\HasGomypay; | ||
use Omnipay\Gomypay\Traits\HasOrderNo; | ||
|
||
class VoidRequest extends AbstractRequest | ||
{ | ||
use HasGomypay; | ||
use HasOrderNo; | ||
|
||
public function getGoodsReturn() | ||
{ | ||
return $this->getParameter('Goods_Return'); | ||
} | ||
|
||
/** | ||
* 退貨註記請填 1(申請退貨) | ||
*/ | ||
public function setGoodsRetrun($value) | ||
{ | ||
return $this->setParameter('Goods_Return', $value); | ||
} | ||
|
||
public function getGoodsReturnReason() | ||
{ | ||
return $this->getParameter('Goods_Return_Reason'); | ||
} | ||
|
||
/** | ||
* 退貨原因 | ||
*/ | ||
public function setGoodsReturnReason($value) | ||
{ | ||
return $this->setParameter('Goods_Return_Reason', $value); | ||
} | ||
|
||
public function getData() | ||
{ | ||
return [ | ||
'Order_No' => $this->getTransactionId(), | ||
'CustomerId' => $this->getCustomerId(), | ||
'Str_Check' => $this->getStrCheck(), | ||
'Goods_Return' => $this->getGoodsReturn() ?: 1, | ||
'Goods_Return_Reason' => $this->getGoodsReturnReason() ?: '退貨', | ||
]; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$response = $this->httpClient->request( | ||
'POST', | ||
$this->getUrl('GoodReturn.aspx'), | ||
['content-type' => 'application/x-www-form-urlencoded'], | ||
http_build_query($data) | ||
); | ||
$data = json_decode((string) $response->getBody(), true); | ||
|
||
return $this->response = new VoidResponse($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,21 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
class VoidResponse extends AbstractResponse | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return false; | ||
} | ||
|
||
public function getCode() | ||
{ | ||
return $this->data['result']; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return $this->data['ret_msg']; | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Tests\Message; | ||
|
||
use Omnipay\Gomypay\Message\VoidRequest; | ||
use Omnipay\Tests\TestCase; | ||
|
||
class VoidRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var VoidRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new VoidRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize([ | ||
'CustomerId' => '42816104A05', | ||
'Str_Check' => '2b1bef9d8ab6a81e9a2739c6ecc64ef8', | ||
'test_mode' => true, | ||
|
||
'transaction_id' => 'AH15482399052114', | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$this->setMockHttpResponse('VoidSuccess.txt'); | ||
$response = $this->request->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertEquals('申請退貨完成', $response->getMessage()); | ||
$this->assertEquals('1', $response->getCode()); | ||
} | ||
} |
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,7 @@ | ||
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":"申請退貨完成"} |