简体   繁体   English

集成到本地服务器上的贝宝

[英]Integration to paypal at local server

In laravel 5.8 app I make integration to paypal with paypal/rest-api-sdk-php and I make as : 在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

if return_urls is uncomment I got error in console : 如果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)

where http://local-votes.com is my local host LAMP/Ubuntu 18 其中http://local-votes.com是我的本地主机LAMP / Ubuntu 18

if to comment return_urls payment works ok but I do not have payment retun action. 如果要发表评论return_urls付款可以,但是我没有付款取消操作。 If there is a way to work with it locally. 如果有一种在本地使用它的方法。 Looking at some example code, looks like that is possible... 查看一些示例代码,看起来这是可能的...

MODIFIED : 已修改:

I uploaded the app under my hosting and hosting page is at https://www.mysite/test 我将应用程序上传到托管页面,托管页面位于https://www.mysite/test

I remade paypal payment function, as 我重新制作了贝宝付款功能,

                            payment: function(data, actions) {
                                return actions.payment.create({

                                    return_urls : {
                                        return_url : 'https://mysite/paypal_payment' 
                                    },

                                    transactions: [{
                                        amount: {
                                            total: '0.01',
                                            currency: 'USD'
                                        }
                                    }]
                                });
                            },

I expected as it is remote hosting under https it will work but anyway I got JS error : 我期望它是在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 ?

Valid syntax was : 有效语法为:

return actions.payment.create({ 返回actions.payment.create({

redirect_urls : {
    return_url : 'https://www.mysite/paypal_payment',
    cancel_url : 'https://www.mysite/paypal_payment_cancel'
},

that fixed the error 修复了错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM