Jump to content

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


mstdmstdd

Recommended Posts

Hello,
Implementing paypal in my laravel 5.8 app 
and looking at the code snippet :
https://developer.paypal.com/docs/archive/checkout/integrate/?mark=get the code#set-up-your-development-environment

I do not seer which is returns valid format?

here https://developer.paypal.com/docs/integration/direct/payments/paypal-payments/#create-paypal-payment
I found that redirect_urls must be used , so my button definition is :

                        <script>
                            paypal.Button.render({
                                // 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 : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment',
                                            cancel_url : 'https://www.votes.nilov-sergey-demo-apps.tk/paypal_payment_cancel'
                                        },
                                        
                                        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');

                        </script>

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 https://www.votes.nilov-sergey-demo-apps.tk 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": "*",

Thanks!

Link to comment
Share on other sites

Could you please look at paypal with sanbox at my site live :
open https://www.votes.nilov-sergey-demo-apps.tk/test and click https://prnt.sc/oaejzc
I see “Thank you for your purchase!” message and no any redirect. Can it be issue of my paypal app some options missed
or account I login into the app ?
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.