-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable repeat purchases to be done via the purchase (and authorize) m…
…ethods This is more compatible with other processors that accept a token or card reference against the purchase and authorize actions in order to process a new payment using information stored on file from previous interactions
- Loading branch information
1 parent
ecc048d
commit 92a6ca9
Showing
6 changed files
with
139 additions
and
20 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
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
57 changes: 57 additions & 0 deletions
57
tests/Message/ServerRepeatPurchaseViaPurchaseRequestTest.php
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,57 @@ | ||
<?php | ||
|
||
namespace Omnipay\SagePay\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
/** | ||
* Class SharedRepeatPurchaseViaPurchaseRequestTest | ||
* | ||
* Tests for using the purchase action to process repeat | ||
* purchases. | ||
* | ||
* @package Omnipay\SagePay\Message | ||
*/ | ||
class ServerRepeatPurchaseViaPurchaseRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var \Omnipay\SagePay\Message\SharedPurchaseRequest $request | ||
*/ | ||
protected $request; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new ServerPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize( | ||
array( | ||
'amount' => '12.00', | ||
'currency' => 'EUR', | ||
'transactionId' => '123', | ||
) | ||
); | ||
} | ||
|
||
public function testSettingOfRelatedTransaction() | ||
{ | ||
$relatedTransactionRef = | ||
'{"SecurityKey":"F6AF4AIB1G","TxAuthNo":"1518884596","VPSTxId":"{9EC5D0BC-A816-E8C3-859A-55C1E476E7C2}","VendorTxCode":"D6429BY7x2217743"}'; | ||
$this->request->setTransactionReference($relatedTransactionRef); | ||
$this->request->setDescription('testSettingOfRelatedTransaction'); | ||
$data = $this->request->getData(); | ||
|
||
$this->assertEquals('12.00', $data['Amount'], 'Transaction amount does not match'); | ||
$this->assertEquals('EUR', $data['Currency'], 'Currency code does not match'); | ||
$this->assertEquals('123', $data['VendorTxCode'], 'Transaction ID does not match'); | ||
$this->assertEquals('F6AF4AIB1G', $data['RelatedSecurityKey'], 'Security Key does not match'); | ||
$this->assertEquals('{9EC5D0BC-A816-E8C3-859A-55C1E476E7C2}', $data['RelatedVPSTxId'], | ||
'Related VPSTxId does not match'); | ||
$this->assertEquals('D6429BY7x2217743', $data['RelatedVendorTxCode'], 'Related VendorTxCode does not match'); | ||
$this->assertEquals('1518884596', $data['RelatedTxAuthNo'], 'Related TxAuthNo does not match'); | ||
|
||
$this->assertEquals('REPEAT', $data['TxType']); | ||
$this->assertEquals('repeat', $this->request->getService()); | ||
} | ||
|
||
} |