在laravel 5.8应用程序中,我使用paypal / rest-api-sdk-php集成到Paypal 我做为:
// Set up a payment
payment: function(data, actions) {
return actions.payment.create({
return_urls : {
return_url : 'http://local-votes.com/paypal_payment'
},
transactions: [{
amount: {
total: '0.01',
currency: 'USD'
}
}]
});
},
// Execute the payment
如果return_urls是注释,则控制台出现错误:
VM19:1 POST https://www.sandbox.paypal.com/v1/payments/payment 400 (Bad Request)
(anonymous) @ VM19:1
(anonymous) @ http.js:147
ZalgoPromise @ promise.js:41
request @ http.js:48
(anonymous) @ rest.js:243
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.then @ promise.js:242
(anonymous) @ rest.js:225
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.then @ promise.js:242
(anonymous) @ rest.js:217
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.resolve @ promise.js:96
_loop @ promise.js:213
_proto.dispatch @ promise.js:153
_proto.resolve @ promise.js:96
(anonymous) @ promise.js:43
(anonymous) @ http.js:117
load (async)
(anonymous) @ http.js:78
ZalgoPromise @ promise.js:41
request @ http.js:48
Object.time @ rest.js:37
(anonymous) @ util.js:54
createPayment @ rest.js:209
(anonymous) @ serialize.js:34
ZalgoPromise.try @ promise.js:401
(anonymous) @ serialize.js:33
(anonymous) @ types.js:68
ZalgoPromise.try @ promise.js:401
_RECEIVE_MESSAGE_TYPE.(anonymous function) @ types.js:56
receiveMessage @ index.js:114
messageListener @ index.js:140
serialize.js:175 Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payments/payment failed with 400 error. Correlation id: 987ea0c89740a, 987ea0c89740a
{
"name": "MALFORMED_REQUEST",
"message": "Incoming JSON request does not map to API request",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
"debug_id": "987ea0c89740a"
}
at XMLHttpRequest.<anonymous> (http.js:114)
at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:4206:27)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:4206:27)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at serialize.js:175
at serialize.js:212
at util.js:140
at util.js:102
at util.js:116
at replaceObject (util.js:138)
at util.js:147
at util.js:109
at util.js:118
at replaceObject (util.js:138)
其中http://local-votes.com是我的本地主机LAMP / Ubuntu 18
如果要评论return_urls付款正常,但我没有付款重新调整操作。 如果有一种在本地使用它的方法。看一些示例代码,看起来是可能的...
已修改:
我将应用程序上传到我的托管下,托管页面位于 https://www.mysite/test
我重新设置了贝宝付款功能,
payment: function(data, actions) {
return actions.payment.create({
return_urls : {
return_url : 'https://mysite/paypal_payment'
},
transactions: [{
amount: {
total: '0.01',
currency: 'USD'
}
}]
});
},
我期望它是在https下的远程托管,它将起作用,但是无论如何我都遇到了JS错误:
VM19:1 POST https://www.sandbox.paypal.com/v1/payments/payment 400 (Bad Request)
(anonymous) @ VM19:1
(anonymous) @ http.js:147
ZalgoPromise @ promise.js:41
request @ http.js:48
(anonymous) @ rest.js:243
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.then @ promise.js:242
(anonymous) @ rest.js:225
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.then @ promise.js:242
(anonymous) @ rest.js:217
_loop @ promise.js:162
_proto.dispatch @ promise.js:153
_proto.resolve @ promise.js:96
_loop @ promise.js:213
_proto.dispatch @ promise.js:153
_proto.resolve @ promise.js:96
(anonymous) @ promise.js:43
(anonymous) @ http.js:117
load (async)
(anonymous) @ http.js:78
ZalgoPromise @ promise.js:41
request @ http.js:48
Object.time @ rest.js:37
(anonymous) @ util.js:54
createPayment @ rest.js:209
(anonymous) @ serialize.js:34
ZalgoPromise.try @ promise.js:401
(anonymous) @ serialize.js:33
(anonymous) @ types.js:68
ZalgoPromise.try @ promise.js:401
_RECEIVE_MESSAGE_TYPE.(anonymous function) @ types.js:56
receiveMessage @ index.js:114
messageListener @ index.js:140
serialize.js:175 Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payments/payment failed with 400 error. Correlation id: 216d1df6b8ce, 216d1df6b8ce
{
"name": "MALFORMED_REQUEST",
"message": "Incoming JSON request does not map to API request",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
"debug_id": "216d1df6b8ce"
}
at XMLHttpRequest.<anonymous> (http.js:114)
at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:4206:27)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:4206:27)
at receiveMessage (index.js:114)
at messageListener (index.js:140)
at serialize.js:175
at serialize.js:212
at util.js:140
at util.js:102
at util.js:116
at replaceObject (util.js:138)
at util.js:147
at util.js:109
at util.js:118
at replaceObject (util.js:138)
Why error and how to fix it ?
答案 0 :(得分:0)
有效语法为:
return actions.payment.create({
redirect_urls : {
return_url : 'https://www.mysite/paypal_payment',
cancel_url : 'https://www.mysite/paypal_payment_cancel'
},
已修复错误