Integrating Paypal payments with Rails

240 views
Skip to first unread message

Mingding Han

unread,
Mar 22, 2012, 10:05:43 AM3/22/12
to Singapore Ruby Brigade
Hey folks, I would like to ask for feedback and advice on implementing
payments via Paypal in Rails, specifically recurring payments.

Background: I'm currently using the paypal-recurring gem (https://
github.com/fnando/paypal-recurring), which works wonderfully, but the
Paypal page that my user is taken to only allows payment from Paypal
accounts - i.e. the user must either log in to Paypal, or sign up for
a new account with a credit card. This approach uses Paypal's
ExpressCheckout functionality, which provides an API to integrate
recurring payments.

Now, Paypal has a Website Payment Standard, which is essentially a
form with hidden elements and which accepts direct credit card
payments - they also help you customise your own "BUY NOW" buttons.
However there doesn't seem to be an API to support this (http://
stackoverflow.com/questions/9523376/api-differences-between-paypal-
express-checkout-and-website-payment-standard,
http://stackoverflow.com/questions/8992244/paypal-express-checkout-subscription-using-credit-card-payment).

I need a simple solution for logged-in users to pay by credit-card
only, that has a callback mechanism to inform my app once a user has
paid, so that I can redirect them back to an appropriate view with the
updated payment status. Doing my best to search for workarounds, but I
thought of asking the experienced SRB folks here too - I'm sure some
of you have gone down this path before.

Of course, if there's a much simpler alternative approach to payments
(ActiveMerchant hmm?) that solves my problem above, please holler!
Next beer at SRB meetup will be on me :D

cheers,
Mingding

Tay Ray Chuan

unread,
Mar 22, 2012, 10:20:55 AM3/22/12
to singap...@googlegroups.com
I recall doing this in django/python. Use a html template with the
required form elements. That shouldn't be too hard, you could get it
from the paypal site. Things like:

- amount
- merchant id

etc.

Definitely not as nice as using a gem, but it would work.

Note that your site will be notified of a successful Express payment
with the "return url" (can't remember the term). Of course, you can't
rely on that, so you'll also need to set up an IPN thingie.

Hopefully this points you in the right direction.

--
Cheers,
Ray Chuan

> --
> You received this message because you are subscribed to the Google Groups "Singapore Ruby Brigade" group.
> To post to this group, send email to singap...@googlegroups.com.
> To unsubscribe from this group, send email to singapore-rb...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/singapore-rb?hl=en.
>

elisha

unread,
Mar 23, 2012, 1:36:31 PM3/23/12
to Singapore Ruby Brigade
I vaguely remember a startup roots intern managed to do something like
that. But I could be wrong.

On Mar 22, 10:05 pm, Mingding Han <hanm...@gmail.com> wrote:
> Hey folks, I would like to ask for feedback and advice on implementing
> payments via Paypal in Rails, specifically recurring payments.
>
> Background: I'm currently using the paypal-recurring gem (https://
> github.com/fnando/paypal-recurring), which works wonderfully, but the
> Paypal page that my user is taken to only allows payment from Paypal
> accounts - i.e. the user must either log in to Paypal, or sign up for
> a new account with a credit card. This approach uses Paypal's
> ExpressCheckout functionality, which provides an API to integrate
> recurring payments.
>
> Now, Paypal has a Website Payment Standard, which is essentially a
> form with hidden elements and which accepts direct credit card
> payments - they also help you customise your own "BUY NOW" buttons.
> However there doesn't seem to be an API to support this (http://
> stackoverflow.com/questions/9523376/api-differences-between-paypal-
> express-checkout-and-website-payment-standard,http://stackoverflow.com/questions/8992244/paypal-express-checkout-su...).

Ashish Puliyel

unread,
Mar 23, 2012, 2:26:39 PM3/23/12
to singap...@googlegroups.com
Yup. This method works. It's can get a bit messy, but it works.

It gets more complicated when cards expire, or you need to handle upgrades or changes to the subscription, but the basic principle is the same. It's a HTML form with a bunch of hidden fields.

You do have to model your billing system to match paypal's recurring payment cycle logic, of course.

But basically, users use a from on your site and make a post request to paypal - where they authorize the payment. They are they redirected to a URL you specify on your site, (and a different url if they cancel), and you'll get an IPN message from paypal anything from a few seconds to 30 minutes later (instant... yeah right), which you have to acknowledge, otherwise you'll get another one.

We've been using this setup at for Docubuzz.com for a few years now.

A
--
+65 98568742
http://www.puliyel.com

Jason Ong

unread,
Mar 23, 2012, 8:29:50 PM3/23/12
to singap...@googlegroups.com
Sounds like a gem waiting to be written?
Cheers,
JasonOng

---
web: http://bit.ly/jasonong
Reply all
Reply to author
Forward
0 new messages