I did a simple Ruby gem to allow easy access to PayPal’s NVP APIs recently. It isn’t much at this point in time, though both the Direct Payment and Express Checkout has been coded, only Direct Payment has really been tested. Here’s the writeup directly from the project site at

Installing Ruby-PayPal

A lightweight ruby wrapper for PayPal NVP APIs. To install type the following at the command line:

$ gem install ruby-paypal

Using Ruby-PayPal

It‘s critical that you understand how PayPal works and how the PayPal NVP API works. You should be relatively well-versed in the NVP API Developer Guide and Reference. You should also visit and register yourself with the PayPal Developer Network and get a Sandbox account with in the PayPal Development Central.

Note that this library only supports the API signature method of securing the API credentials.

Direct Payment

To use credit card payment through PayPal, you need to use the DoDirectPayment APIs:

username = <PayPal API username>
password = <PayPal API password>
signature = <PayPal API signature>

ipaddress = '' # can be any IP address
amount = '100.00' # amount paid
card_type = 'VISA' # can be Visa, Mastercard, Amex etc
card_no = '4512345678901234' # credit card number
exp_date = '022010' # expiry date of the credit card
first_name = 'Sau Sheong'
last_name = 'Chang'

paypal =, password, signature) # uses the PayPal sandbox
response = paypal.do_direct_payment_sale(ipaddress, amount, card_type, card_no, exp_date, first_name, last_name)

if response.ack == 'Success' then
   # do your thing

The above code is for a final sale only.

Note that the credit card number is checked against a modulo-10 algorithm (Luhn check) as well as a simple credit card type check. For more information please refer to and

One thought on “Ruby-PayPal

  1. Just recently, nsider sources revealed Amazon has filed a
    patenbt for the double-sided device. When you seek juust a death benefit – beneficiaries are
    guaranteed to have the exact amount depending
    on yoour agreed coverage when the insured die.
    Detesrmine not merely their qualities, but also tthe important figures about them:
    how big is their group, what’s heir average age and income, and thee way much purchasing power they have for
    youir product you’re thinking of selling online.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s