最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Paypal Button returns 'Order could not be captured' - Stack Overflow

programmeradmin1浏览0评论

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..

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./docs/checkout/integrate/#1-get-paypal-rest-api-credentials

Share Improve this question asked Mar 12, 2019 at 22:02 user3094755user3094755 1,64117 silver badges23 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 2

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

https://www.sandbox.paypal./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.

Can you check using CURL which returns the Paypal server? This is a ment but I do not have 50pkt S / O. Sorry.

If you get a Xss message in the console, just try in private navigation, disconnect from your paypal buyer account.

I have had the same "Order could not be captured" error at "actions.order.capture()" in the onApprove callback.

In my case, it worked on the first run but not the subsequent calls. I found my order always had the same invoice_id. I removed invoice_id and Paypal stopped plaining.

It should be good if the invoice_id was always unique.

Same problem with Nuxt , checkout works but catch error response : Error 500 order-could-not-be-captured

<template>
  <no-ssr>
    <v-layout row wrap>  
      <div ref="paypal"></div>   
    </v-layout>
  </no-ssr>
</template>

Script

mounted() {
    const script = document.createElement("script");
    script.src =
      "https://www.paypal./sdk/js?client-id=MyKeyID";
    script.addEventListener("load", this.setLoaded);
    document.body.appendChild(script);
  },
  methods: {
    setLoaded: function() {
      this.loaded = true;
      window.paypal
        .Buttons({
          createOrder: (data, actions) => {
            return actions.order.create({
              purchase_units: [
                {
                  description: "Test description",
                  amount: {
                    currency_code: "USD",
                    value: 1
                  }
                }
              ]
            });
          },
          onApprove: async (data, actions) => {
            const order = await actions.order.capture();
            this.paidFor = true;
            console.log(order);
          },
          onError: err => {
            console.log(err);
          }
        })
        .render(this.$refs.paypal);
    }
发布评论

评论列表(0)

  1. 暂无评论