Integrating Paypal in Rails Application (Part-2)

Paypal Integration in Rails (continued)

Now, When the user is redirected to the method paypal_url , defined in the model file (order.rb) there we will give the html variables in which we will connect our application to the paypal sandbox site for dummy transaction.

In this method we will pass in the required parameters by paypal to handle our transactions.

But before that we need to know about NGROK

NGROK allows us to expose the localhost web server running on our machine to the internet. Its like making our web application live. Now to redirect the users back to our website with the payment notifications generated by PayPal, we need to tunnel our localhost web server with ngrok. NGROK creates a URL for our web application which we can use to launch our website. Steps to use NGROK are as follows :

After that go to the directory from your console where you have installed NGROK and run this command

$ ./ngrok http 3000

This will start your NGROK server and it will provide you with a URL. Now we will use this URL further Now we are done with installing NGROK and will move further to the payment_url method defined in order.rb model file.

Here we will send some parameters to the paypal which includes the name,address,invoice of the buyer, return and notify URLs where the user will be redirected after successful transaction and a hash which contains the array of products present in the cart.

Here return_url contains our NGROK url where the users will be redirected where you may display the order receipt of the buyer's order. And notify_url is the URL where paypal will send all the payment notifications in the form of parameters which contains several useful things like transaction ID, status etc. In this hook method we will update our order table with transaction ID, status and notification params like this :

Here your order table's attributes will get updated and you have successfully save all the transaction parameters to your order table which you can use in your order receipt page to display all the order information. Hope these blogs will help you to integrate paypal successfully with your rails application.

0 Comment(s)

Comment on it

AttachFiles,Zip etc

RecordFrom Desktop

RecordFrom Webcam

Preview

Enter captcha to proceed

Unable to start Java!! Mr. Nerd figure out why...

We have detected you are using Google Chrome and might be unable to use the Java plugin from this browser. Starting with Version 42 (released April 2015), Chrome has disabled the standard way in which browsers support plugins. More info

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Chrome Version Support

Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).

Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.

Unable to start Java!! Mr. Nerd figure out why..

We have detected that Java plugin is not installed/enabled on your browser. Unfortunately some of our below listed tools require Java plugin:

Desktop recorder.

Error Screen capture.

Time Tracker.

To use our product please click on the link to install/Detect Java plugin.

You have exceeded the maximum number of characters allowed for a comment without sign in.Either enter Content Or Record

Your Post will be visible in the listing once it has been approved by the administrator.