PayPal沙盒发布错误 401(未经授权)



在此处输入图像描述我一直在使用 react-PayPal-express-checkout 的PayPal沙盒教程并完全遵循它,但是当我尝试打开PayPal窗口时,它会立即关闭并抛出此错误。

照片:照片在这里

发短信:

http.js:147 POST https://www.sandbox.paypal.com/v1/payment-experience/web-profiles 401 (Unauthorized)
types.js:121 Uncaught Error: Request to post https://www.sandbox.paypal.com/v1/payment-experience/web-profiles failed with 401 error. Correlation id: bfca9a9c3fdfc
{
"name": "AUTHENTICATION_FAILURE",
"debug_id": "bfca9a9c3fdfc",
"message": "Authentication failed due to invalid authentication credentials or a missing Authorization header",
"information_link": "https://developer.paypal.com/docs/api/payment-experience/#errors",
"details": []
}
at XMLHttpRequest.xhrLoad (http.js:114)
at Object._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_response] (types.js:121)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at Object._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_response] (types.js:121)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
_RECEIVE_MESSAGE_TYPE.<computed> @ types.js:121
receiveMessage @ index.js:114
messageListener @ index.js:140
setTimeout (async)
dispatchPossiblyUnhandledError @ exceptions.js:16
(anonymous) @ promise.js:122
setTimeout (async)
reject @ promise.js:120
dispatch @ promise.js:179
reject @ promise.js:127
dispatch @ promise.js:179
reject @ promise.js:127
dispatch @ promise.js:186
reject @ promise.js:127
(anonymous) @ promise.js:157
dispatch @ promise.js:184
reject @ promise.js:127
(anonymous) @ promise.js:51
respond @ client.js:147
_RECEIVE_MESSAGE_TYPE.<computed> @ types.js:126
receiveMessage @ index.js:114
messageListener @ index.js:140
serialize.js:175 Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payment-experience/web-profiles failed with 401 error. Correlation id: bfca9a9c3fdfc
{
"name": "AUTHENTICATION_FAILURE",
"debug_id": "bfca9a9c3fdfc",
"message": "Authentication failed due to invalid authentication credentials or a missing Authorization header",
"information_link": "https://developer.paypal.com/docs/api/payment-experience/#errors",
"details": []
}
at XMLHttpRequest.xhrLoad (http.js:114)
at Object._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_response] (types.js:121)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at Object._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_response] (types.js:121)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at deserializeError (serialize.js:175)
at serialize.js:212
at util.js:140
at eachArray (util.js:102)
at each (util.js:116)
at replaceObject (util.js:138)
at util.js:147
at eachObject (util.js:109)
at each (util.js:118)
at replaceObject (util.js:138)

这是我的按钮页面,所有教程人员的更改都是我所做的沙盒ID:

import React from 'react';
import PaypalExpressBtn from 'react-paypal-express-checkout';
export default class MyApp extends React.Component {
render() {
const onSuccess = (payment) => {
// Congratulation, it came here means everything's fine!
console.log("The payment was succeeded!", payment);
// You can bind the "payment" object's value to your state or props or whatever here, please see below for sample returned data
}
const onCancel = (data) => {
// User pressed "cancel" or close Paypal's popup!
console.log('The payment was cancelled!', data);
// You can bind the "data" object's value to your state or props or whatever here, please see below for sample returned data
}
const onError = (err) => {
// The main Paypal's script cannot be loaded or somethings block the loading of that script!
console.log("Error!", err);
// Because the Paypal's main script is loaded asynchronously from "https://www.paypalobjects.com/api/checkout.js"
// => sometimes it may take about 0.5 second for everything to get set, or for the button to appear
}
let env = 'sandbox'; // you can set here to 'production' for production
let currency = 'USD'; // or you can set this value from your props or state
let total = 1; // same as above, this is the total amount (based on currency) to be paid by using Paypal express checkout
// Document on Paypal's currency code: https://developer.paypal.com/docs/classic/api/currency_codes/
const client = {
sandbox:    'ASloDPNYZO9LtigzQd58tcYQHuORCH3TlvPS-LWMdwzIWiEiefonUQE7KmWCE-WkaEaiiJb54RSNcrLE',
production: 'YOUR-PRODUCTION-APP-ID',
}
// In order to get production's app-ID, you will have to send your app to Paypal for approval first
// For sandbox app-ID (after logging into your developer account, please locate the "REST API apps" section, click "Create App"):
//   => https://developer.paypal.com/docs/classic/lifecycle/sb_credentials/
// For production app-ID:
//   => https://developer.paypal.com/docs/classic/lifecycle/goingLive/
// NB. You can also have many Paypal express checkout buttons on page, just pass in the correct amount and they will work!
return (
<PaypalExpressBtn env={env} client={client} currency={currency} total={total} onError={onError} onSuccess={onSuccess} onCancel={onCancel} />
);
}
}

反应PayPal-快速结帐存储库不引用 v1/支付体验/网络配置文件 ,所以我不确定您的错误实际上来自哪里

v1/支付体验/Web 配置文件 API 需要有效的ClientId和用于身份验证的Secret

相关内容

  • 没有找到相关文章

最新更新