В приложении laravel 5.8 я делаю интеграцию с PayPal с PayPal / Rest-Api-SDK-php и я делаю как:
// 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 является uncomment, я получил ошибку в консоли:
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
Я переделал функцию оплаты PayPal, как
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 ?