samedi 29 juin 2019

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 :

                            // 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 :

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

if to comment return_urls payment works ok but I do not have payment retun action. If there is a way to work with it locally. Looking at some example code, looks like that is possible...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire