Skip to content

Commit

Permalink
Amazon Pay PHP SDK 3.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bjguillot committed Feb 11, 2019
1 parent 4abae04 commit aff849d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AmazonPay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class Client implements ClientInterface, LoggerAwareInterface
{
const SDK_VERSION = '3.4.0';
const SDK_VERSION = '3.4.1';
const MWS_VERSION = '2013-01-01';
const MAX_ERROR_RETRY = 3;

Expand Down
1 change: 0 additions & 1 deletion AmazonPay/IpnHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ private function validateUrl($url)
/* Verify that the signature is correct for the given data and
* public key
*
* @param string $data data to validate
* @param string $signature decoded signature to compare against
* @param string $certificatePath path to certificate, can be file or url
*
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
3.4.1 - February 2019
- Fix undefined index message in ConfirmOrderReference

3.4.0 - January 2019
- Added new supplementary_data attribute for AuthorizeOnBillingAgreement and CreateOrderReferenceForId.
- Added additional attributes (success_url, failure_url, authorization_amount, currency_code) to ConfirmOrderReference. Amazon Pay Strong Customer Authentication (SCA) Upgrade Integration Guide
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "amzn/amazon-pay-sdk-php",
"type": "library",
"description": "Amazon Pay SDK (PHP)",
"version": "3.4.0",
"version": "3.4.1",
"keywords": [
"amazon",
"pay",
Expand Down
79 changes: 78 additions & 1 deletion tst/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function testSetOrderAttributesAfterConfirm()
$this->assertEquals($apiParametersString, $expectedStringParams);
}

public function testConfirmOrderReference()
public function testConfirmOrderReferenceWithAllSCA()
{
$client = new Client($this->configParams);
$fieldMappings = array(
Expand Down Expand Up @@ -380,6 +380,83 @@ public function testConfirmOrderReference()
$this->assertEquals($apiParametersString, $expectedStringParams);
}

public function testConfirmOrderReferenceWithAllButCurrencyCodeSCA()
{
$client = new Client($this->configParams);
$fieldMappings = array(
'merchant_id' => 'SellerId',
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken',
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount'
);

$action = 'ConfirmOrderReference';

$parameters = $this->setParametersAndPost($fieldMappings, $action);
$expectedParameters = $parameters['expectedParameters'];
$apiCallParams = $parameters['apiCallParams'];

$expectedParameters['AuthorizationAmount.CurrencyCode'] = 'USD'; # default from client
$expectedStringParams = $this->callPrivateMethod($client, 'calculateSignatureAndParametersToString', $expectedParameters);

$response = $client->confirmOrderReference($apiCallParams);

$apiParametersString = $client->getParameters();
$this->assertEquals($apiParametersString, $expectedStringParams);
}

public function testConfirmOrderReferenceWithUrlSCA()
{
$client = new Client($this->configParams);
$fieldMappings = array(
'merchant_id' => 'SellerId',
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken',
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl'
);

$action = 'ConfirmOrderReference';

$parameters = $this->setParametersAndPost($fieldMappings, $action);
$expectedParameters = $parameters['expectedParameters'];
$apiCallParams = $parameters['apiCallParams'];

$expectedStringParams = $this->callPrivateMethod($client, 'calculateSignatureAndParametersToString', $expectedParameters);

$response = $client->confirmOrderReference($apiCallParams);

$apiParametersString = $client->getParameters();

$this->assertEquals($apiParametersString, $expectedStringParams);
}

public function testConfirmOrderReferenceWithoutSCA()
{
$client = new Client($this->configParams);
$fieldMappings = array(
'merchant_id' => 'SellerId',
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken'
);

$action = 'ConfirmOrderReference';

$parameters = $this->setParametersAndPost($fieldMappings, $action);
$expectedParameters = $parameters['expectedParameters'];
$apiCallParams = $parameters['apiCallParams'];

$expectedStringParams = $this->callPrivateMethod($client, 'calculateSignatureAndParametersToString', $expectedParameters);

$response = $client->confirmOrderReference($apiCallParams);

$apiParametersString = $client->getParameters();

$this->assertEquals($apiParametersString, $expectedStringParams);
}

public function testCancelOrderReference()
{
$client = new Client($this->configParams);
Expand Down

0 comments on commit aff849d

Please sign in to comment.