views:

136

answers:

1

I'm trying to create an ultra simple paypal custom integration with rails. I'm following Ryan Bates Railscast #141 on this subject and I've simplified it even further. If you have experience with super simple paypal integration, any advice would be appreciated!

I'm attempting to pass everything through my account model. A proof-of-concept.

def paypal_url(return_url)
  values = {
    :business => '[email protected]',
    :cmd => '_cart',
    :upload => 1,
    :return => return_url,
    :invoice => 2,
    :amount => 7,
    :item_name => 'Membership',
    :item_number => 1,
    :quantity => 1 
  }

  "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end 

and of course I create a link:

<%= link_to "Checkout", @account.paypal_url(accounts_path) %>

The Paypal detects an error: "Your shopping cart is empty", which is strange because I can see everything my model passes in the URL:

https://www.sandbox.paypal.com/cgi-bin/webscr?amount=7&amp;[email protected]&amp;cmd=_cart&amp;invoice=&amp;item_name=Barcoden+Membership&amp;item_number=1&amp;quantity=1&amp;return=/accounts&amp;upload=1
A: 

To answer we need to have a closer look at your code.

But perhaps this can help you: A Testable PayPal IPN with Rails 2.3

Dmytrii Nagirniak