diff --git a/AmazonPay/Client.php b/AmazonPay/Client.php index 80dc561..8ecb84d 100644 --- a/AmazonPay/Client.php +++ b/AmazonPay/Client.php @@ -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; @@ -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'); } @@ -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()) { @@ -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()) { @@ -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'])) { diff --git a/AmazonPay/ClientInterface.php b/AmazonPay/ClientInterface.php index 9f8e602..c6d6d5f 100644 --- a/AmazonPay/ClientInterface.php +++ b/AmazonPay/ClientInterface.php @@ -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()); diff --git a/CHANGES.txt b/CHANGES.txt index ee82f1b..24e37ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/README.md b/README.md index 4f933a9..af41be7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/composer.json b/composer.json index 606541d..6224d28 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tst/unit/ClientTest.php b/tst/unit/ClientTest.php index f70acc3..1b117c5 100644 --- a/tst/unit/ClientTest.php +++ b/tst/unit/ClientTest.php @@ -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'; @@ -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'; @@ -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'; @@ -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); @@ -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') {