-
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
11 changed files
with
155 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,20 +32,26 @@ The result will be a redirect to the gateway or bank. | |
```php | ||
use Omnipay\Omnipay; | ||
|
||
<<<<<<< HEAD | ||
$gateway = Omnipay::create('APS'); | ||
======= | ||
$gateway = Omnipay::create('Amazon Payment Service'); | ||
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455 | ||
|
||
// Send purchase request (don't get so excited... params below are just fake :)) | ||
$gateway->setTestMode(TRUE); | ||
$gateway->setRequestPhrase('PASS'); | ||
|
||
//$gateway->setAccessCode('zx0IPmPy5jp1vAz8Kpg7') | ||
// ->setAmount(10000) // amount * 100 | ||
// ->setMerchantIdentifier(123) | ||
// ->setMerchantReference('random') | ||
// ->setCustomerEmail('[email protected]') | ||
// ->setOrderDescription('iPhone 6-S'); | ||
// .... OR .... | ||
|
||
$response = $gateway->purchase([ | ||
'access_code' => 'zx0IPmPy5jp1vAz8Kpg7', | ||
'amount' => '10000', // amount * 100 | ||
'merchant_identifier' => 'CycHZxVj', | ||
'merchant_reference' => 'XYZ9239-yu898', | ||
'amount' => '10000', | ||
'currency' => 'AED', | ||
'language' => 'en', | ||
'currency' => 'AED', // default AED | ||
'language' => 'en', // default en | ||
'customer_email' => '[email protected]', | ||
'order_description' => 'iPhone 6-S', | ||
])->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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,94 @@ | ||
<?php | ||
<?php namespace Omnipay\APS; | ||
|
||
namespace Omnipay\APS\Tests; | ||
|
||
use Omnipay\APS\Message\Response\AuthorizationResponse; | ||
use Omnipay\Stripe\Message\AuthorizeRequest; | ||
use Omnipay\Tests\GatewayTestCase; | ||
use Omnipay\APS\Message\Response\PurchaseResponse; | ||
|
||
class GatewayTest extends GatewayTestCase | ||
{ | ||
/** | ||
* @var Gateway | ||
*/ | ||
protected $gateway; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $options; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->gateway->setTestMode(TRUE); | ||
|
||
$this->options = [ | ||
'access_code' => 'zx0IPmPy5jp1vAz8Kpg7', | ||
'merchant_identifier' => 'CycHZxVj', | ||
'merchant_reference' => 'XYZ9239-yu898', | ||
'currency' => 'AED', | ||
'language' => 'en', | ||
'customer_email' => '[email protected]', | ||
<<<<<<< HEAD | ||
======= | ||
'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a', | ||
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455 | ||
'order_description' => 'iPhone 6-S', | ||
]; | ||
} | ||
/** | ||
* @var Gateway | ||
*/ | ||
protected $gateway; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $options; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->gateway->setTestMode(TRUE); | ||
$this->gateway->setRequestPhrase('PASS'); | ||
|
||
$this->options = [ | ||
'access_code' => 'zx0IPmPy5jp1vAz8Kpg7', | ||
'merchant_identifier' => 'CycHZxVj', | ||
'merchant_reference' => 'XYZ9239-yu898', | ||
'currency' => 'AED', | ||
'language' => 'en', | ||
'customer_email' => '[email protected]', | ||
'order_description' => 'iPhone 6-S', | ||
'request_phrase' => 'iPhone 6-S', | ||
]; | ||
} | ||
|
||
/** | ||
* Authorization success | ||
*/ | ||
public function testAuthorizationSuccess() | ||
{ | ||
$this->setMockHttpResponse('AuthorizationSuccess.txt'); | ||
public function testAuthorizationSuccess() | ||
{ | ||
$this->setMockHttpResponse('AuthorizationSuccess.txt'); | ||
|
||
$this->options['amount'] = '10000'; | ||
$this->options['amount'] = '10000'; | ||
|
||
/** @var AuthorizationResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->send(); | ||
/** @var AuthorizationResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertEquals('Success.', $response->getMessage()); | ||
} | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertStringContainsString('Success', $response->getMessage()); | ||
} | ||
|
||
/** | ||
* Authorization failure | ||
*/ | ||
public function testAuthorizationFailure() | ||
{ | ||
$this->setMockHttpResponse('AuthorizationFailure.txt'); | ||
/** | ||
* Authorization failure | ||
*/ | ||
public function testAuthorizationFailure() | ||
{ | ||
$this->setMockHttpResponse('AuthorizationFailure.txt'); | ||
|
||
$this->options['amount'] = NULL; | ||
$this->options['amount'] = 100; | ||
|
||
/** @var AuthorizationResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->send(); | ||
/** @var AuthorizationResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertSame('Invalid amount.', $response->getMessage()); | ||
} | ||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertSame('Invalid amount.', $response->getMessage()); | ||
} | ||
|
||
/** | ||
* Purchase success. Purchase combines authorization and capture requests | ||
*/ | ||
public function testPurchaseSuccess() | ||
{ | ||
$this->setMockHttpResponse('PurchaseFailure.txt'); | ||
$this->setMockHttpResponse('PurchaseSuccess.txt'); | ||
|
||
$this->options['amount'] = '10000'; | ||
|
||
/** @var PurchaseResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->purchase($this->options) | ||
->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertEquals('Success.', $response->getMessage()); | ||
$this->assertStringContainsString('Success', $response->getMessage()); | ||
} | ||
|
||
|
||
|
@@ -101,13 +97,13 @@ public function testPurchaseSuccess() | |
*/ | ||
public function testPurchaseFailure() | ||
{ | ||
$this->setMockHttpResponse('PurchaseSuccess.txt'); | ||
$this->setMockHttpResponse('PurchaseFailure.txt'); | ||
|
||
$this->options['amount'] = '10001'; | ||
|
||
/** @var PurchaseResponse $response */ | ||
$response = $this->gateway | ||
->authorize($this->options) | ||
->purchase($this->options) | ||
->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
|
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
HTTP/2 200 | ||
server: nginx | ||
date: Fri, 30 Aug 2019 17:13:47 GMT | ||
content-type: application/json | ||
vary: Accept-Encoding | ||
vary: Accept-Encoding | ||
x-powered-by: PHP/7.0.7 | ||
cache-control: private, must-revalidate | ||
pragma: no-cache | ||
expires: -1 | ||
|
||
{"command":"AUTHORIZATION","access_code":"zx0IPmPy5jp1vAz8Kpg7","merchant_identifier":"CycHZxVj","merchant_reference":"XYZ9239-yu898","amount":"10000","currency":"AED","language":"en","customer_email":"[email protected]","signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a","fort_id":"149295435400084008","payment_option":"VISA","eci":"ECOMMERCE","order_description":"iPhone6-S","customer_ip":"192.178.1.10","customer_name":"John","response_message":"Invalid amount.","response_code":"20064","status":"03","card_holder_name":"John Smith","expiry_date":"2105","card_number":"400555******0001"} |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
HTTP/2 200 | ||
server: nginx | ||
date: Fri, 30 Aug 2019 17:13:47 GMT | ||
content-type: application/json | ||
vary: Accept-Encoding | ||
vary: Accept-Encoding | ||
x-powered-by: PHP/7.0.7 | ||
cache-control: private, must-revalidate | ||
pragma: no-cache | ||
expires: -1 | ||
|
||
{"command":"AUTHORIZATION","access_code":"zx0IPmPy5jp1vAz8Kpg7","merchant_identifier":"CycHZxVj","merchant_reference":"XYZ9239-yu898","amount":"10000","currency":"AED","language":"en","customer_email":"[email protected]","signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a","fort_id":"149295435400084008","payment_option":"VISA","eci":"ECOMMERCE","order_description":"iPhone6-S","customer_ip":"192.178.1.10","customer_name":"John","response_message":"Success","response_code":"20064","status":"02","card_holder_name":"John Smith","expiry_date":"2105","card_number":"400555******0001"} |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
{"command":"AUTHORIZATION","access_code":"zx0IPmPy5jp1vAz8Kpg7","merchant_identifier":"CycHZxVj","merchant_reference":"XYZ9239-yu898","amount":"10000","currency":"AED","language":"en","customer_email":"[email protected]","signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a","fort_id":"149295435400084008","payment_option":"VISA","eci":"ECOMMERCE","order_description":"iPhone6-S","customer_ip":"192.178.1.10","customer_name":"John","response_message":"Operation amount exceeds the authorized amount.","response_code":"14042","status":"14","card_holder_name":"John Smith","expiry_date":"2105","card_number":"400555******0001"} | ||
HTTP/2 200 | ||
server: nginx | ||
date: Fri, 30 Aug 2019 17:13:47 GMT | ||
content-type: application/json | ||
vary: Accept-Encoding | ||
vary: Accept-Encoding | ||
x-powered-by: PHP/7.0.7 | ||
cache-control: private, must-revalidate | ||
pragma: no-cache | ||
expires: -1 | ||
|
||
{"command":"AUTHORIZATION","access_code":"zx0IPmPy5jp1vAz8Kpg7","merchant_identifier":"CycHZxVj","merchant_reference":"XYZ9239-yu898","amount":"10000","currency":"AED","language":"en","customer_email":"[email protected]","signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a","fort_id":"149295435400084008","payment_option":"VISA","eci":"ECOMMERCE","order_description":"iPhone6-S","customer_ip":"192.178.1.10","customer_name":"John","response_message":"Operation amount exceeds the authorized amount.","response_code":"14042","status":"13","card_holder_name":"John Smith","expiry_date":"2105","card_number":"400555******0001"} |
Oops, something went wrong.