Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal Button returns 'Order could not be captured'

I am using paypal Buttons SDK. The Code activating the button is:-

        paypal.Buttons({
        createOrder: ( data, actions ) => {
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: this.amount.toFixed(2),
                        currency_code: "GBP",
                    }
                }]
            })
        },
        onApprove: ( data, actions ) => {
            return actions.order.capture().then(details => {
              console.log('details',details);
            })
        },
        onError: ( error ) => {
            console.log('error',error);
        }
    }).render('#paypal-button-container')

The User Interface operates as expected, there is then a long pause before the error is returned. The client_id used in the script tag is for a sandbox account. I can find not documentation describing possible cause for the error...

error Error: Order could not be captured

Any advice greatly appreciated.

Paypal.. https://developer.paypal.com/docs/checkout/integrate/#1-get-paypal-rest-api-credentials

like image 926
user3094755 Avatar asked Nov 16 '22 13:11

user3094755


1 Answers

As suggested in the comment try to do a curl with this URL :

https://www.sandbox.paypal.com/smart/api/order/ODER_ID/capture

And it replies with code 401 and did some research and end up finding that I was using a wrong account to make payments.

I refresh the PayPal login and login with the correct sandbox buyer account and make the payment and It works.

Probably paypal should give correct errors messages.

like image 108
Espoir Murhabazi Avatar answered Dec 18 '22 05:12

Espoir Murhabazi