在我的laravel 5.8应用程序中实现贝宝
我看不到哪个返回有效格式?
此处https://developer.paypal.com/docs/integration/direct/payments/paypal-payments/#create-paypal-payment 我发现必须使用redirect_urls,所以我的按钮定义是:
<script>
paypal.Button.render({
// Configure environment
env: 'sandbox',
client: {
sandbox: 'CLIENTID',
production: 'demo_production_client_id'
},
// Customize button (optional)
locale: 'en_US',
style: {
size: 'small',
color: 'blue',
shape: 'pill',
},
commit: true,
payment: function(data, actions) {
return actions.payment.create({
"note_to_payer": "Contact us for any questions on your order.",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
redirect_urls : { //redirect_urls
return_url : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment',
cancel_url : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment_cancel'
},
transactions: [{
amount: {
total: '0.01',
currency: 'USD'
}
}]
});
},
// Execute the payment
onAuthorize: function(data, actions) {
console.log("onAuthorize data::")
console.log( data )
console.log("onAuthorize actions::")
console.log( actions )
return actions.payment.execute().then(function() {
// Show a confirmation message to the buyer
window.alert('Thank you for your purchase! 0');
});
}
}, '#paypal-button');
</script>
我在actions.payment.execute方法中看到警报,但是没有像预期的那样在return_url中指定的URL上自动重新设置。
我在LAMP,Ubuntu 18和Digital Ocean下的https://www.votes.nilov-sergey-demo-apps.tk上实时上传了我的网站。
为什么没有自动重定向?
$ php artisan --version
Laravel Framework 5.8.24
In composer.json:
"paypal/rest-api-sdk-php": "*",
已修改: 付款var创建并返回:
时,我进行了重新制作 payment: function(data, actions) {
var payment = actions.payment.create({
"note_to_payer": "Contact us for any questions on your order.",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
redirect_urls : { //redirect_urls
return_url : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment',
cancel_url : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment_cancel'
},
transactions: [{
amount: {
total: '0.01',
currency: 'USD'
}
}]
});
console.log("payment payment::")
console.log(payment);
// alert( "::"+var_dump(-88) )
return payment;
},
和注意的警告:
Firefox can’t establish a connection to the server at wss://www.votes.nilov-sergey-demo-apps.tk/app/123?protocol=7&client=js&version=4.3.1&flash=false. app.js:1767:16
The connection to wss://www.votes.nilov-sergey-demo-apps.tk/app/123?protocol=7&client=js&version=4.3.1&flash=false was interrupted while the page was loading.
带有控制台付款输出和错误消息的printscreen类似于: https://imgur.com/a/znKtMGw
是什么引起了这些错误?