【发布时间】:2018-09-28 17:30:31
【问题描述】:
我正在尝试使用 paypalrestsdk 在 Django 中实现 paypal。
我按照此处示例中的代码示例进行操作:https://prettyprinted.com/blog/1125955/creating-paypal-express-payments-in-flask
但是有这个错误:
这是我的模板 .html、views.py 和 urls.py 的代码 sn-ps https://gist.github.com/axilaris/1e6e34ba5915abceb0dbd06d46baf08b
这里是显示按钮的模板代码:
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
var CREATE_PAYMENT_URL = 'http://127.0.0.1:8000/payment_create';
var EXECUTE_PAYMENT_URL = 'http://127.0.0.1:8000/payment_execute';
paypal.Button.render({
env: 'sandbox', // Or 'sandbox'
commit: true, // Show a 'Pay Now' button
payment: function() {
console.log("payment function")
return paypal.request.post(CREATE_PAYMENT_URL).then(function(data) {
console.log("return create payment")
return data.paymentID;
});
},
onAuthorize: function(data) {
return paypal.request.post(EXECUTE_PAYMENT_URL, {
paymentID: data.paymentID,
payerID: data.payerID
}).then(function(res) {
console.log(res.success)
// The payment is complete!
// You can now show a confirmation message to the customer
});
}
}, '#paypal-button');
</script>
是什么问题,如何解决,ppxo_unhandled_error 是什么?
另外,在 Django 上正确实施 paypal 的最佳方法是什么。 (我只是没有看到任何好的文档)
Django==1.11.7
【问题讨论】:
标签: python django paypal paypal-rest-sdk