3 months ago

There are no automatic redirection with paypal/rest-api-sdk-php

Posted 3 months ago by mstdmstd

Hello, Implementing paypal in my laravel 5.8 app and looking at the code snippet :

I do not seer which is returns valid format?

here I found that redirect_urls must be used , so my button definition is :

                                // 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 : '',
                                            cancel_url : ''
                                        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');


I see alert in actions.payment.execute method, but no automatic rederection at url specified in return_url, as I expected. I uploaded my site live at under LAMP, Ubuntu 18 , Digital Ocean. Why there are no automatic redirection ?

    $ php artisan --version
    Laravel Framework 5.8.24
In composer.json:
    "paypal/rest-api-sdk-php": "*",


Please sign in or create an account to participate in this conversation.