设置客户端调用服务器端PayPal API时获取控制台错误
设置时,PayPal客户端代码用于测试服务器集成,从 我的代码如下:设置客户端调用服务器端PayPal API时获取控制台错误,paypal,paypal-sandbox,Paypal,Paypal Sandbox,设置时,PayPal客户端代码用于测试服务器集成,从 我的代码如下: <html> <head> <title>TEST PAYMENT</title> </head> <body> <div id="paypal-button"></div> <script src="https://www.paypalobjects.com/api/checko
<html>
<head>
<title>TEST PAYMENT</title>
</head>
<body>
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
env: 'sandbox', // Or 'production'
// Set up the payment:
// 1. Add a payment callback
payment: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/api/paypal/create-payment')
.then(function(res) {
console.log(res);
// 3. Return res.id from the response
return res.id;
});
},
// Execute the payment:
// 1. Add an onAuthorize callback
onAuthorize: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/api/paypal/execute-payment', {
paymentID: data.paymentID,
payerID: data.payerID
})
.then(function(res) {
// 3. Show the buyer a confirmation message.
});
}
}, '#paypal-button');
</script>
</body>
</html>
试金
paypal.Button.render({
env:'沙盒',//或'生产'
//设置付款:
//1.添加付款回拨
支付:功能(数据、操作){
//2.向服务器发出请求
returnactions.request.post(“/api/paypal/createpayment”)
.然后(功能(res){
控制台日志(res);
//3.从响应返回res.id
返回res.id;
});
},
//执行付款:
//1.添加onAuthorize回调
onAuthorize:函数(数据、操作){
//2.向服务器发出请求
returnactions.request.post(“/api/paypal/executepayment”{
paymentID:data.paymentID,
payerID:data.payerID
})
.然后(功能(res){
//3.向买方显示确认信息。
});
}
}“#贝宝按钮”);
当我打开页面时。
当我单击该按钮时,一个模式窗口会显示一秒钟,并关闭,出现以下错误
您尝试使用的
checkout.js
集成已被弃用
以下是当前用于调用服务器的JSSDK:您能建议一下,这种服务器端集成的PHP示例代码是什么吗?官方指南真是一团糟。您可以使用几个API(包括不推荐使用的API),但当前的v2/checkout/orders“Create Order”和“Capture Order”是最好的,记录在: