PayPal integration Ruby on Rails - ruby-on-rails

I've seen posts that you should use ActiveMerchant for PayPal integration, but I also found this on the PayPal website.I'm struggling with placing what in which file, since I'm totally new to RoR. So I was trying to integrate the PayPal, but am not sure where to place which code.
Should I use active merchant for PayPal integration, or is the Rest-API the best choice. I want people to fill out their username, pay and when successful they receive digital content. So there should be a call with a result and the username.
Do you have a link, step by step, at least including which code I should place in which file, so I get the basics of RoR better.

Standard PayPal Integration with Rails app Active Merchant gem :
step 1:
-> add 'gem activemerchant' in  gem file
-> bundle install
step 2:
-> Go to "www.developer.paypal.com" and create an account(also known as Merchant Account) with US address details.
-> It will create two dummy test account for buyer and seller(alias facilitator) in "sandbox.paypal.com".
  Ex: 
     Seller account  --->  naveengoud-facilitator#gmail.com
     Buyer account  --->  naveengoud-buyer#gmail.com
      
-> To see test accounts details Click on "Dashboard -> Accounts"
-> Now set the password for both test accounts by clicking on profile link
step 3:
-> Go to seller account(i.e, facilitator) profile details and copy the API Credentials i.e, Username, password and signature
  Ex:
    Username:  naveengoud-facilitator_api1.gamil.com
    Password:   VSPALJ5ALA5YY9YJ
    Signature:   AVLslxW5UGzEpaDPEK4Oril7Xo4IAYjdWHD25HhS8a8kqPYO4FjFhd6A
-> Set these API Credentials in "config/environments/development.rb" as follows, add the below code with API credentials
  config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test    
        ::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(
             login: "merchant_api1.gotealeaf.com",
            password: "2PWPEUKZXAYE7ZHR",
            signature: "AFcWxV21C7fd0v3bYYYRCpSSRl31A-dRI5VpyF4A9emruhNYzlM8poc0"
        )
     end
step 4:
-> From here onward follow the Rails cast 145 episode(http://railscasts.com/episodes/145-integrating-active-merchant)

I found the PayPal API documentation to be quite confusing. Also, my application requirements were not satisfied through the API, so I ended up with a rather simple solution.
The solution mainly consists of two components:
PayPal buttons, which I generate on PayPal website and copy the HTML to my website
PayPal IPN notifications, for which I have a simple handler on my website
This is how the whole solution works in detail
For the user to make payments, I use the PayPal Buttons. For this, you just login to your PayPal business account and generate HTML code for buttons which you can copy and paste into your website.
The user can click on these buttons, they will be redirected to PayPal website, they make payments and have a button to come back to your website.
When the transaction is done (either success or failure), PayPal will inform you via PayPal IPN Notifications. I have implemented an IPN handler on my website, which was quite easy to do.
By the time the user returns to my website, in most cases, I would have already got the IPN notification, hence I can show them a success message.
In case the IPN got delayed, I tell the users that it will take a couple more minutes to update their balance and use AJAX to keep querying the server for updates.
Here are some useful references:
PayPal Buttons
Rail Casts on PayPal IPN
If you need, you can also dynamically generate the buttons via the Button Manager API gem

This link will help you to get better understanding on integration of Basic Checkout, Charge Credit Cards and Recurring Payments with paypal in Ruby On Rails application
http://www.gotealeaf.com/blog/basic-paypal-checkout-processing-in-rails
You can find solutions for following concepts,
1) Basic Checkout
2) Charge Credit Cards
3) Recurring Payments

Look at this for rails integration:
https://github.com/nov/paypal-express see the example and wiki
but also here, more in general (less related to Rails):
https://github.com/tc/paypal_adaptive
https://github.com/fnando/paypal-recurring
-

Related

Stripe Error - Known test bank accounts cannot be used in live mode. Payout Set up for rails app

I'm trying to setup the payout process for the merchants on my site, but for some reason when I use Stripe Test bank details I get with the error of "Known test bank accounts cannot be used in live mode". I'm using the development client ID for testing obviously, so not sure why am I end up with this error. :( Any ideas would be very welcome! Thanks.
The activation form expects real information about a real business. This means that even if you're testing, you might want to create a real account with real details and that's what Stripe asks for here.
Since you're only testing the OAuth flow and don't want to activate your account you should ignore the form entirely. When testing with your Development client id ca_XXXXX there should be a link at the top of the form called "Skip this account form". This links lets you bypass the activation form (which would be required in production) and finish the connection with the platform.

Grails PayPal plugin response notification

I have been trying to integrate PayPal payment with a test application I am developing. If successful, I am thinking of leveraging this on my other projects.
So far, I have been able to add the plugin, configure it for Test environment and able to complete a transaction end to end. However, I have a small issue that I want some help or clarification about. Please follow the series of images below for more details:
Button on merchant application (grails application)
Payment page on PayPal test site
Here is the paypal confirmation page for transaction:
After making the payment above, I got a successful message on paypal test site. But when I check the logs and database, there is no notification sent to the grails application at this stage. The payment transaction is still in PENDING state:
Now, when I click on the "Return to merchant" link on the paypal confirmation page, then I redirected to my grails application with a SUCCESS message:
So, the PayPal "SUCCESS" response is sent to the grails/merchant application only after the user hits that link "Return to merchant site". In real life, the users might not want to return to the merchant site everytime. Seeing the confirmation message on PayPal site, they might assume that the transaction is done and may be PayPal does the payment too. But, how do we let the merchant site i.e the grails application know that the PayPal has already shown the user a confirmation message? So that, the user doesn't have to return to merchant site after seeing the Successful message?
UPDATE:
I have tried the IPN simulator upon your advice. I am not quite sure and able to understand how I can send an IPN message to my localhost application. When I tried giving my localhost or 127.0.0.1 on the IPN simulator configuration on my sandbox account, it throws error saying unable to reach the server. I am sure many developers must have tried this using local development machine, but unable to find any resource which gives the steps to use IPN simulator or IPN sandbox response for a localhost development instancE.
You cannot rely on PDT
you have to use IPN
where PayPal send a notification to a page on your website where you have to authenticate, verify several possible issues and save the transaction details
See here fore more info
IPN
Not sure if it written at that link, but you have also to enable such function from your Paypal account indicating the target page on your website.

PayPal Sandbox - CreateBillingAgreement call returns Internal Error (10001)

I'd appreciate any help with this, I've run around in circles trying all sorts of combinations with the PayPal Api - but I'm hitting a brick wall on this one.
I'm looking to call the CreateBillingAgreement method but each time I do it fails and reports a 10001 'internal error' from paypal in the response.
I have a valid token and I'm using version 84.0. I've successfully called SetupExpressCheckout and DoExpressCheckout, both of which succeed and the payment goes through. I'm setting up a future payment / pre-authorisation on the SetupExpressCheckout and the user agrees to that no problems.
​Do I need to change settings on the merchant in the sandbox? Am I calling things in the wrong order maybe? (SetExpress, GetExpress, DoExpress, CreateBilling)?
​I'm looking to use this billing agreement to allow a reference transaction in the future. I'm having a test account 'pay' using paypal and not forwarding any credit card details, the payment is for a digital service with no delivery (no shipping is set, no addresses or delivery costs are involved). The overall goal is to provide a one-click re-order button, whereby no details need to be entered by the customer.
I'm using the C# api in asp.net 4, or more specifically I've created Service References from the paypal sandbox wsdl and I'm using those in asp.net.
​Any and all help is appreciated - thanks.
​Russell.
You don't need to call CreateBillingAgreement if you're specifying billingtype MerchantInitiatedBilling in your SetExpressCheckout and DoExpressCheckoutPayment API call. CreateBillingAgreement is only necessary if you don't want to call DoExpressCheckoutPayment.
If MerchantInitiatedBilling is set, DoExpressCheckoutPayment will already return a billing agreement ID, which you can use in DoReferenceTransaction.
I don't have access to an example at hand, but will update this post as soon as I've found one for you.

Magento - PayPal IPN configuration

I have set up a web shop using Magento (v. 1.5) and one of my payment options is PayPal standard payments. Everything works fine so far but now I would like to trigger a script on another server by using the IPN URL from PayPal when a payment is received.
The PayPal account is also used for other web platforms and it has the correct IPN URL for the script already set up in the account configuration. However, the Magento module seems to overwrite this URL and always sets it to "http://myshop.com/paypal/ipn/" when someone buys something in the Magento shop.
My problem is that I can not find any possibilities to change this behaviour in Magento itself. The backend module configuration offers nothing in that direction and I also looked into the IPN model and controller files in the core directories (Mage/Paypal/controllers/IpnController.php and Mage/Paypal/Model/Ipn.php).
It has to be possible to change the IPN URL but I'm out of ideas at this point... so I'd be very thankful for any helpful hints!
The IPN notification URL is set in Mage_Paypal_Model_Standard::getStandardCheckoutFormFields:
$api->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
The function is called by Mage_Paypal_Block_Standard_Redirect, so you can override either the model or the block to change/remove the URL. But keep in mind that Magento needs the IPN notification to update order status etc.

Setting up Paypal account in Substruct

I am new to both paypal and substruct. I trying to integrate paypal with 'Substruct'. The problem I am facing is that the payment status codes are not being updated in the admin panel.
All of them are on Hold even when paypal sandbox successfully confirmed the orders. From the web somebody suggested that the 'notify_url' needs to be set in the confirm order form
Paypal documention says the same as well.
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
What value should I provide to the notify_url so that the webserver on my machine is notified. BTW my webserver is behind a LAN.
check the substruct documentation # http://code.google.com/p/substruct/wiki/PayPal

Resources