Skip to content

Commit

Permalink
Amazon Pay PHP SDK 3.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Shangamesh T committed Jan 25, 2021
1 parent d5a273e commit 87229f6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 9 deletions.
10 changes: 6 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.6.0';
const SDK_VERSION = '3.7.0';
const MWS_VERSION = '2013-01-01';
const MAX_ERROR_RETRY = 3;

Expand Down Expand Up @@ -361,7 +361,7 @@ private function setParametersAndPost($parameters, $fieldMappings, $requestParam
}

// Ensure that no unexpected type coercions have happened
if ($param === 'capture_now' || $param === 'confirm_now' || $param === 'inherit_shipping_address' || $param === 'request_payment_authorization') {
if ($param === 'capture_now' || $param === 'confirm_now' || $param === 'inherit_shipping_address' || $param === 'request_payment_authorization' || $param === 'expect_immediate_authorization') {
if (!is_bool($value)) {
throw new \Exception($param . ' value ' . $value . ' is of type ' . gettype($value) . ' and should be a boolean value');
}
Expand Down Expand Up @@ -622,7 +622,7 @@ public function getOrderReferenceDetails($requestParameters = array())
* @optional requestParameters['created_end_time'] - [String] (Date/Time ISO8601) Limited to 31 days
* @optional requestParameters['sort_order'] - [String] (Ascending/Descending)
* @optional requestParameters['mws_auth_token'] - [String]
* @optional requestParameters['status_list'] - [Array]
* @optional requestParameters['order_status_list'] - [Array]
*/
public function listOrderReference($requestParameters = array())
{
Expand Down Expand Up @@ -791,6 +791,7 @@ public function setOrderAttributes($requestParameters = array())
* @optional requestParameters['authorization_amount'] - [String]
* @optional requestParameters['currency_code'] - [String]
* @optional requestParameters['mws_auth_token'] - [String]
* @optional requestParameters['expect_immediate_authorization'] - [Boolean] Default value is false
*/
public function confirmOrderReference($requestParameters = array())
{
Expand All @@ -805,7 +806,8 @@ public function confirmOrderReference($requestParameters = array())
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount',
'currency_code' => 'AuthorizationAmount.CurrencyCode',
'mws_auth_token' => 'MWSAuthToken'
'mws_auth_token' => 'MWSAuthToken',
'expect_immediate_authorization' => 'ExpectImmediateAuthorization'
);

if (isset($requestParameters['authorization_amount']) && !isset($requestParameters['currency_code'])) {
Expand Down
1 change: 1 addition & 0 deletions AmazonPay/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public function setOrderAttributes($requestParameters = array());
* @optional requestParameters['authorization_amount'] - [String]
* @optional requestParameters['currency_code'] - [String]
* @optional requestParameters['mws_auth_token'] - [String]
* @optional requestParameters['expect_immediate_authorization'] - [Boolean] Default value is false
*/
public function confirmOrderReference($requestParameters = array());

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.7.0 - January 2021
- Added additional attribute (expect_immediate_authorization) to ConfirmOrderReference. This value can be set to true or false (Boolean). See Amazon Pay Strong Customer Authentication (SCA) Upgrade Integration Guide for more information.

3.6.0 - November 2019
- Add GetMerchantNotificationConfiguration API call
- Add SetMerchantNotificationConfiguration API call
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ and the amount captured by making the `capture` API call after the shipment is c
| Platform ID | `platform_id` | no | Platform ID of the Solution provider |
| Custom Information | `custom_information` | no | Any custom string |
| MWS Auth Token | `mws_auth_token` | no | MWS Auth Token required if API call is made on behalf of the seller |
| ExpectImmediateAuthorization | `expect_immediate_authorization` | no | Setting value to true, will make OrderReferenceObject to be closed automatically in case no authorization is triggered within 60 minutes |

```php
// Create an array that will contain the parameters for the charge API call
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.6.0",
"version": "3.7.0",
"keywords": [
"amazon",
"pay",
Expand Down
38 changes: 34 additions & 4 deletions tst/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ public function testConfirmOrderReferenceWithAllSCA()
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount',
'currency_code' => 'AuthorizationAmount.CurrencyCode'
'currency_code' => 'AuthorizationAmount.CurrencyCode',
'expect_immediate_authorization' => 'ExpectImmediateAuthorization'
);

$action = 'ConfirmOrderReference';
Expand All @@ -389,7 +390,8 @@ public function testConfirmOrderReferenceWithAllButCurrencyCodeSCA()
'mws_auth_token' => 'MWSAuthToken',
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl',
'authorization_amount' => 'AuthorizationAmount.Amount'
'authorization_amount' => 'AuthorizationAmount.Amount',
'expect_immediate_authorization' => 'ExpectImmediateAuthorization'
);

$action = 'ConfirmOrderReference';
Expand All @@ -415,7 +417,8 @@ public function testConfirmOrderReferenceWithUrlSCA()
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
'mws_auth_token' => 'MWSAuthToken',
'success_url' => 'SuccessUrl',
'failure_url' => 'FailureUrl'
'failure_url' => 'FailureUrl',
'expect_immediate_authorization' => 'ExpectImmediateAuthorization'
);

$action = 'ConfirmOrderReference';
Expand Down Expand Up @@ -457,6 +460,33 @@ public function testConfirmOrderReferenceWithoutSCA()
$this->assertEquals($apiParametersString, $expectedStringParams);
}

/*
* Test to validate ConfirmOrderReference API with ExpectImmediateAuthorization optional value as null
* It is expected to accept only Boolean value (i.e true or false)
*/
public function testConfirmOrderReferenceWithExpectImmediateAuthorizationValueAsNull() {
$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',
'expect_immediate_authorization' => 'ExpectImmediateAuthorization'
);
$action = 'ConfirmOrderReference';
$parameters = $this->setParametersAndPost($fieldMappings, $action);
$apiCallParams = $parameters['apiCallParams'];
$apiCallParams['expect_immediate_authorization'] = null;
try{
$response = $client->confirmOrderReference($apiCallParams);
}
catch (\Exception $expected) {
$this->assertRegExp('/should be a boolean value/i', strval($expected));
}
}

public function testCancelOrderReference()
{
$client = new Client($this->configParams);
Expand Down Expand Up @@ -1227,7 +1257,7 @@ private function setParametersAndPost($fieldMappings, $action)
$expectedParameters['Action'] = $action;

foreach ($fieldMappings as $parm => $value) {
if ($parm === 'capture_now' || $parm === 'confirm_now' || $parm === 'inherit_shipping_address' || $parm === 'request_payment_authorization') {
if ($parm === 'capture_now' || $parm === 'confirm_now' || $parm === 'inherit_shipping_address' || $parm === 'request_payment_authorization' || $parm === 'expect_immediate_authorization') {
$expectedParameters[$value] = true;
$apiCallParams[$parm] = true;
} elseif ($parm === 'order_item_categories') {
Expand Down

0 comments on commit 87229f6

Please sign in to comment.