Search code examples
phpsdkaccess-deniedamazon-pay

Getting "AccessDenied" error on amazon pay after success logged in authorized on amazon account


I have implemented PHP SDK for amazon pay and currently I am facing one error, When I click on amazon pay button then one popup will be open for asking login credentials for amazon and after logged in successfully then it will redirect to Address book and payment methods choose page and on that page I am facing this error and Json response that I am getting are as below.

AmazonPay\ResponseParser Object
(
    [response] => Array
        (
            [Status] => 401
            [ResponseBody] => 


    Sender
    AccessDenied
    Access denied

  11e659e5-6413-4f49-ab38-339472490e5c


        )

)
{
    "Error": {
        "Type": "Sender",
        "Code": "AccessDenied",
        "Message": "Access denied"
    },
    "RequestID": "11e659e5-6413-4f49-ab38-339472490e5c",
    "ResponseStatus": "401"
}

So please suggest to me if you are aware of this error. Thanks in advance!


Solution

  • Please set proper country wise config settings on amazon pay configuration file. i.e If your country select UK based then amazon pay sandbox work with GBP and UK only and if you try with another region or currency then you will get this Access Denied error.

    Also cross check Amazon Sandbox credentials with that you have set in your file and make sure all settings will be correct.

    <?php
    namespace AmazonPay;
    
    $config = array(
        'merchant_id' => 'YOUR_MERCHANT_ID',
        'access_key'  => 'YOUR_ACCESS_KEY',
        'secret_key'  => 'YOUR_SECRET_KEY',
        'client_id'   => 'YOUR_LOGIN_WITH_AMAZON_CLIENT_ID',
        'region'      => 'REGION',
        'sandbox'     => true);
    
    $client = new Client($config);
    
    // Also you can set the sandbox variable in the config() array of the Client class by
    
    $client->setSandbox(true);
    

    Click here to see full documentation for implement amazon pay payment gateway in your website.