Paypal Location Issue with @paypal/react-paypal-js: Paypal位置问题与@paypal/react-paypal-js

huangapple go评论70阅读模式
英文:

Paypal Location Issue with @paypal/react-paypal-js

问题

I have a problem with paypal integration to my react project.
Actually I have implemented the paypal with this code.

const onCreateOrder = (data, actions) => {
  return actions.order.create({
    intent: "CAPTURE",
    application_context: {
      shipping_preferences: "NO_SHIPPING",
    },
    purchase_units: [
      {
        amount: {
          value: 150,
        },
      },
    ],
  });
};

But with this code, users can't input address on paypal platform. So I updated the code like this.

const onCreateOrder = (data, actions) => {
  return actions.order.create({
    intent: "CAPTURE",
    application_context: {
      shipping_preferences: "GET_FROM_FILE",
    },
    purchase_units: [
      {
        amount: {
          value: 150,
        },
      },
    ],
  });
};

Then I get this error on paypal.
This is the screenshot.

Could you please help me here?
Thank you.

I tried to change the address several times but not working.

英文:

I have a problem with paypal integration to my react project.
Actually I have implemented the paypal with this code.

const onCreateOrder = (data, actions) => {
  return actions.order.create({
    intent: "CAPTURE",
    application_context: {
      shipping_preferences: "NO_SHIPPING",
    },
    purchase_units: [
      {
        amount: {
          value: 150,
        },
      },
    ],
  });
};

But with this code, users can't input address on paypal platform. So I updated the code like this.

const onCreateOrder = (data, actions) => {
  return actions.order.create({
    intent: "CAPTURE",
    application_context: {
      shipping_preferences: "GET_FROM_FILE",
    },
    purchase_units: [
      {
        amount: {
          value: 150,
        },
      },
    ],
  });
};

Then I get this error on paypal.
This is the screenshot.

Could you please help me here?
Thank you.

I tried to change the address several times but not working.

答案1

得分: 1

屏幕截图中的错误发生在存在一个onShippingChange回调函数被拒绝的时候(未成功返回)。

该回调函数的文档在此。如果您不需要它,请从您的按钮组件中删除它的定义。如果您确实需要它,请调试并修复以使其正常工作。

英文:

The error in the screenshot occurs when there is an onShippingChange callback function that rejects the promise (does not return successfully).

The callback function is documented here. If you do not need it, remove its definition from your buttons component. If you do need it, debug and correct it to work as it should.

huangapple
  • 本文由 发表于 2023年5月22日 19:54:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305918.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定