PayPal SDK添加客户端id时出错PayPal未定义



使用下面显示的test客户端id时,一切正常:

<body>
<script src="https://www.paypal.com/sdk/js?client-id=test&currency=USD"></script>
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '77.44' // Can reference variables or functions. Example: `value: document.getElementById('...').value`
}
}]
});
},
// Finalize the transaction after payer approval
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Successful capture! For dev/demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
var transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction '+ transaction.status + ': ' + transaction.id + 'nnSee console for all available details');
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '';
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL:  actions.redirect('thank_you.html');
});
}
}).render('#paypal-button-container');
</script>
</body>
</html>

但是,如果我将查询参数客户端id从test更改为我的沙箱id:

<script src="https://www.paypal.com/sdk/js?client-id=sb-v444pg***79*^@business.example.com&currency=USD"></script>

我收到一个控制台错误,说贝宝没有定义。为什么我的身份证不起作用?

client id=sb-v444pg**79^@business.example.com

这不是客户端id,而是沙盒帐户电子邮件。

从我的应用程序获取REST API客户端id;资格证书创建沙盒应用程序时,您可以选择与其关联的帐户。

最新更新