我试图使用paypalrestsdk实现与Django PayPal.
我按照示例中的代码示例进行了操作:https://prettyprinted.com/blog/1125955/creating-paypal-express-payments-in-flask
但是有这个错误:

这是我的模板.html,views.py和urls.py的代码片段 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 …Run Code Online (Sandbox Code Playgroud)