Skip to content

Commit

Permalink
Amazon Pay PHP SDK 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TruLove committed Feb 5, 2019
1 parent 77f494f commit af6ef40
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 21 deletions.
25 changes: 21 additions & 4 deletions 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.3.2';
const SDK_VERSION = '3.4.0';
const MWS_VERSION = '2013-01-01';
const MAX_ERROR_RETRY = 3;

Expand Down Expand Up @@ -431,7 +431,7 @@ private function setDefaultValues($parameters, $fieldMappings, $requestParameter
if (array_key_exists('currency_code', $fieldMappings)) {
if (!empty($requestParameters['currency_code'])) {
$parameters[$fieldMappings['currency_code']] = strtoupper($requestParameters['currency_code']);
} else if (!(array_key_exists('Action', $parameters) && $parameters['Action'] === 'SetOrderAttributes')) {
} else if (!(array_key_exists('Action', $parameters) && ( $parameters['Action'] === 'SetOrderAttributes' || $parameters['Action'] === 'ConfirmOrderReference'))) {
// Only supply a default CurrencyCode parameter if not using SetOrderAttributes API
$parameters[$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
}
Expand Down Expand Up @@ -757,6 +757,10 @@ public function setOrderAttributes($requestParameters = array())
* @param requestParameters['merchant_id'] - [String]
* @param requestParameters['amazon_order_reference_id'] - [String]
* @optional requestParameters['success_url'] - [String]'
* @optional requestParameters['failure_url'] - [String]
* @optional requestParameters['authorization_amount'] - [String]
* @optional requestParameters['currency_code'] - [String]
* @optional requestParameters['mws_auth_token'] - [String]
*/
public function confirmOrderReference($requestParameters = array())
Expand All @@ -766,12 +770,21 @@ public function confirmOrderReference($requestParameters = array())
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);

$fieldMappings = array(
'merchant_id' => 'SellerId',
'merchant_id' => 'SellerId',
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken'
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount',
'currency_code' => 'AuthorizationAmount.CurrencyCode',
'mws_auth_token' => 'MWSAuthToken'
);

if ($requestParameters['authorization_amount'] && !$requestParameters['currency_code']) {
$requestParameters['currency_code'] = strtoupper($this->config['currency_code']);
}

$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);

return ($responseObject);
}

Expand Down Expand Up @@ -1083,6 +1096,7 @@ public function getServiceStatus($requestParameters = array())
* @optional requestParameters['seller_note'] - [String]
* @optional requestParameters['seller_order_id'] - [String]
* @optional requestParameters['store_name'] - [String]
* @optional requestParameters['supplementary_data'] - [String]
* @optional requestParameters['custom_information'] - [String]
* @optional requestParameters['mws_auth_token'] - [String]
*/
Expand All @@ -1104,6 +1118,7 @@ public function createOrderReferenceForId($requestParameters = array())
'seller_note' => 'OrderReferenceAttributes.SellerNote',
'seller_order_id' => 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId',
'store_name' => 'OrderReferenceAttributes.SellerOrderAttributes.StoreName',
'supplementary_data' => 'OrderReferenceAttributes.SupplementaryData',
'custom_information' => 'OrderReferenceAttributes.SellerOrderAttributes.CustomInformation',
'mws_auth_token' => 'MWSAuthToken'
);
Expand Down Expand Up @@ -1245,6 +1260,7 @@ public function validateBillingAgreement($requestParameters = array())
* @optional requestParameters['custom_information'] - [String]
* @optional requestParameters['seller_order_id'] - [String]
* @optional requestParameters['store_name'] - [String]
* @optional requestParameters['supplementary_data'] - [String]
* @optional requestParameters['inherit_shipping_address'] [Boolean] - Defaults to true
* @optional requestParameters['mws_auth_token'] - [String]
*/
Expand All @@ -1269,6 +1285,7 @@ public function authorizeOnBillingAgreement($requestParameters = array())
'custom_information' => 'SellerOrderAttributes.CustomInformation',
'seller_order_id' => 'SellerOrderAttributes.SellerOrderId',
'store_name' => 'SellerOrderAttributes.StoreName',
'supplementary_data' => 'SellerOrderAttributes.SupplementaryData',
'inherit_shipping_address' => 'InheritShippingAddress',
'mws_auth_token' => 'MWSAuthToken'
);
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
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

3.3.2 - August 2018
- Added method for listOrderReference API call
- Added method for listOrderReferenceByNextToken API call
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*-*-**-***-*****-********-*************
Amazon Pay SDK (PHP)
Copyright 2013-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copyright 2013-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
*-*-**-***-*****-********-*************

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.3.2",
"version": "3.4.0",
"keywords": [
"amazon",
"pay",
Expand Down
Binary file removed dist/amazon-pay.phar
Binary file not shown.
34 changes: 19 additions & 15 deletions tst/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
class ClientTest extends \PHPUnit_Framework_TestCase
{
private $configParams = array(
'merchant_id' => 'MERCHANT1234567',
'access_key' => 'ABCDEFGHI1JKLMN2O7',
'secret_key' => "abc123Def456gHi789jKLmpQ987rstu6vWxyz",
'currency_code' => 'usd',
'client_id' => 'amzn1.application-oa2-client.45789c45a8f34927830be1d9e029f480',
'region' => 'us',
'sandbox' => true,
'platform_id' => 'test',
'application_name' => 'sdk testing',
'application_version' => '1.0',
'proxy_host' => null,
'proxy_port' => -1,
'proxy_username' => null,
'proxy_Password' => null
'merchant_id' => 'MERCHANT1234567',
'access_key' => 'ABCDEFGHI1JKLMN2O7',
'secret_key' => "abc123Def456gHi789jKLmpQ987rstu6vWxyz",
'currency_code' => 'usd',
'client_id' => 'amzn1.application-oa2-client.45789c45a8f34927830be1d9e029f480',
'region' => 'us',
'sandbox' => true,
'platform_id' => 'test',
'application_name' => 'sdk testing',
'application_version' => '1.0',
'proxy_host' => null,
'proxy_port' => -1,
'proxy_username' => null,
'proxy_Password' => null
);

public function testConfigArray()
Expand Down Expand Up @@ -358,7 +358,11 @@ public function testConfirmOrderReference()
$fieldMappings = array(
'merchant_id' => 'SellerId',
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken'
'mws_auth_token' => 'MWSAuthToken',
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount',
'currency_code' => 'AuthorizationAmount.CurrencyCode'
);

$action = 'ConfirmOrderReference';
Expand Down

0 comments on commit af6ef40

Please sign in to comment.