Permission denied when trying to access sandbox or live client api

superchay
Contributor
Contributor

Hello,

 

I'm creating a paypal checkout for a client and I've followed pretty much the exact code given here: https://developer.paypal.com/demo/checkout/#/pattern/experience

 

However, when I click on the paypal button, the popup window displays for a brief moment then disappears. The console in chrome shows the following errors:

 

Failed to load resource: the server responded with a status of 403 (Forbidden)
props.js:246 Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payments/payment failed with 403 error. Correlation id: 71cb81ccc57e5, 71cb81ccc57e5

{
"name": "PERMISSION_DENIED",
"message": "No permission for the requested operation",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "71cb81ccc57e5"
}

at XMLHttpRequest.<anonymous> (https://www.paypalobjects.com/api/checkout.js:15266:39)
at Object.postrobot_message_response (https://www.paypalobjects.com/api/checkout.js:2797:31)
at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2842:60)
at messageListener (https://www.paypalobjects.com/api/checkout.js:2863:13)
at Object.postrobot_message_response (https://www.paypalobjects.com/api/checkout.js:2797:31)
at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2842:60)
at messageListener (https://www.paypalobjects.com/api/checkout.js:2863:13)

at XMLHttpRequest.<anonymous> (https://www.paypalobjects.com/api/checkout.js:15266:39)
at Object.postrobot_message_response (https://www.paypalobjects.com/api/checkout.js:2797:31)
at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2842:60)
at messageListener (https://www.paypalobjects.com/api/checkout.js:2863:13)
at Object.postrobot_message_response (https://www.paypalobjects.com/api/checkout.js:2797:31)
at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2842:60)
at messageListener (https://www.paypalobjects.com/api/checkout.js:2863:13)
at deserializeError (https://www.paypalobjects.com/api/checkout.js:3578:23)
at https://www.paypalobjects.com/api/checkout.js:3599:270
at https://www.paypalobjects.com/api/checkout.js:3331:30
at eachArray (https://www.paypalobjects.com/api/checkout.js:3314:51)
at each (https://www.paypalobjects.com/api/checkout.js:3320:35)
at replaceObject (https://www.paypalobjects.com/api/checkout.js:3330:13)
at https://www.paypalobjects.com/api/checkout.js:3332:169
at eachObject (https://www.paypalobjects.com/api/checkout.js:3317:65)
at each (https://www.paypalobjects.com/api/checkout.js:3320:144)
at replaceObject (https://www.paypalobjects.com/api/checkout.js:3330:13)

 

I have supplied the correct sandbox and live client IDs, ad given by my client. 

 

I'm at my wits end. Any help would be appreciated.

 

The code I'm using is below:

            <div id="paypal-button-container" class="text-center"></div>
            <script>
                paypal.Button.render({

                    env: 'sandbox', // sandbox | production

                    style: {
                        label: 'pay',
                        size:  'medium', // small | medium | large | responsive
                        shape: 'rect',   // pill | rect
                        color: 'gold'   // gold | blue | silver | black
                    },
                    // PayPal Client IDs - replace with your own
                    // Create a PayPal app: https://developer.paypal.com/developer/applications/create
                    client: {
                        sandbox:    'AW0YywJAAvREPqpKy_Px5OXozeBVScnjyGy9X54_TzSnZbq1uBYQn5lMQi3CRC-vgUzPH96qullHj699',
                        production: 'ARUNqtNcWkPei05vrxz9YFZGj9wse0o5-8R_NED_vsOuPYrUF4BCcIttpbL5pj4UoNkUaHhTWF7ojIo-'
                    },

                    // Show the buyer a 'Pay Now' button in the checkout flow
                    commit: true,

                    // payment() is called when the button is clicked
                    payment: function(data, actions) {

                        // Make a call to the REST api to create the payment
                        return actions.payment.create({
                            payment: {
                                transactions: [
                                    {
                                        amount: { total: '11.00', currency: 'USD' }
                                    }
                                ]
                            }
                        });
                    },

                    // onAuthorize() is called when the buyer approves the payment
                    onAuthorize: function(data, actions) {

                        // Make a call to the REST api to execute the payment
                        return actions.payment.execute().then(function() {
                            window.alert('Payment Complete!');
                        });
                    }

                }, '#paypal-button-container');

            </script>

Thanks

Daniel

Login to Me Too
4 REPLIES 4

yldong
Contributor
Contributor

I was able to successfully popup the PayPal express checkout window and complete a checkout flow last week. However since last Wednesday I am starting to get this permission denied error, the PayPal checkout window won't even open. Is there something going on at PayPal side?

Login to Me Too

IDFABRIK
Member
Member

I have Exactly the same problem, I implemented Client Side Express Checkout using REST in my tea shop. After that I tested and it works fine.

But now the popup close immediately after opening. In the console : PERMISSION_DENIED

Test link => https://lesthesduchat.com/2018-06-02-paiement.html
I can't understand that behavior and will be very happy to find a solution

Tanks

Tawan

Login to Me Too

mandeep_m91
New Community Member

I am facing the same issue. It works when I use the clientId shown on their demo page but when I use my own sandbox client id, it fails with this error.

Login to Me Too

yldong
Contributor
Contributor

After back and forth with Paypal support, they have identified the problem. When your app negotiate with Paypal through /token api, the token response generated by Paypal shall contain all the valid scope as following:

 "scope":"https://uri.paypal.com/services/subscriptions' 
 'https://api.paypal.com/v1/payments/.*' 
 'https://api.paypal.com/v1/vault/credit-card' 
 'https://uri.paypal.com/services/applications/webhooks' 
 'openid' 
 'https://uri.paypal.com/payments/payouts' 
 'https://api.paypal.com/v1/vault/credit-card/.*"' 
...

 

but instead, it returns 

{"scope":"https://uri.paypal.com/services/subscriptions 
https://api.paypal.com/v1/vault/credit-card openid 
https://api.paypal.com/v1/vault/credit-card/.* 
...

Even I have enabled all features in Paypal, the token response is still missing the important scopes such as /payment/.*

That is why we are getting permission denied error

Paypal is actively working on the issue. to expedite the fix, maybe you should also file support ticket for the issue.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.