#87 Make E-com in Laravel 5.6 / 5.7 | Integrate Live PayPal Link | Add Return/Cancel URL

In Part-87, we are going to integrate live Paypal link instead of Sandbox. And for that we need to create Paypal Business Account and need to complete their verification process. So in this video, we will assume that you made Paypal Business account. Also going to add return URL and cancel URL in Paypal form. By Return URL, user will auto return to website success/thanks page after he makes the payment via Paypal. And by Cancel URL, user will return to website cancel page when he cancels the payment.

1) Add Auto Return Field (After Payment) :-

We can either add Auto Return field in Paypal form or we can add from our Paypal Business account as well.

Search for “return url paypal” in Google and open below link :-
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/ProfileAndTools/

You can copy the return field from above link and paste into your Paypal form as shown in video.

Another way to enable Auto Return from Paypal account is as below :-

1. Log in to your PayPal business account at paypal.com.

2. In the Profile menu, click Profile and settings.

3. In the left menu, click My selling tools.

4. In the Selling online section, click Update next to Website preferences.

5. In Auto Return for Website Payments, click On.

6. In the Return URL field, enter the full path of the URL to which you want to redirect buyers when their payment is complete. Include HTTP:// or HTTPS:// in the path.

2) Create return Route :-

Create GET route for Paypal thanks page in our website we automatically returns when user makes successful payment.

// Paypal Thanks Page
Route::get(‘/paypal/thanks’,’ProductsController@thanksPaypal’);

3) Create thanksPaypal Function :-

Create thanksPaypal Function in ProductsController that we will return to thanks_paypal.blade.php file.

4) Create thanks_paypal.blade.php file :-

Create thanks_paypal.blade.php file under views/orders folder and make changes as shown in video.

5) Update paypal.blade.php file :-

Update Paypal form with cancel return field that will take the user to cancel page in our E-com website if the user cancels the payment process from Paypal end. So, we need to create cancel page in our website as well.

6) Create cancel_return Route

Create GET route for cancel return page in web.php file like below :-

// Paypal Cancel Page
Route::get(‘/paypal/cancel’,’ProductsController@cancelPaypal’);

7) Create cancelPaypal function

Create cancelPaypal function in ProductsController file that will return to cancel_paypal.blade.php file.

8) Create cancel_paypal.blade.php file :-

Create cancel_paypal.blade.php file under views/orders folder and make changes as shown in video.

9) Update paypal.blade.php file :-

Now update Paypal form in paypal.blade.php file with Live Paypal action instead of sandbox URL.

So create Business Paypal account and follow the above steps to set Return URL so that users will return back to your website after making the payment. Later in future, we will learn IPN and PDT API’s as well. But from next video, we will start working on admin panel to show the orders so that admin can process them.

That’s all for now. Thanks for watching 🙂

source