Search code examples
ruby-on-railspaypalactivemerchant

PayPal express / Active Merchant - not displaying line items or cart total?


I'm trying to set up a PayPal express checkout using active merchant but I'm running into problems. I've followed a tutorial and I can get to the "choose a way to pay" form on paypal but there are no items or prices displayed.

Here's a screenshot. http://i39.tinypic.com/35mircz.png

Why is not displaying a price or any items even though I'm passing them in? Here is the code I'm using to setup_purchase.

@product = Product.find(params[:product_id])

setup_response = gateway.setup_purchase(200,
  :ip                => request.remote_ip,
  :items => [{:name => "Tickets", :quantity => 22, :description => "Tickets for 232323", :amount => 10}],
  :return_url        => url_for(:action => 'confirm', :only_path => false),
  :cancel_return_url => url_for(:action => 'index', :only_path => false)
)

redirect_to gateway.redirect_url_for(setup_response.token)

Any help would be greatly appreciated. Alex


Solution

  • Your problem lies with your quantities and pricing - if you output setup_response after it does the call with something like

    logger.debug setup_response
    

    And check the log, you'll see that it's probably complaining that the price in the items is not matching up to the amount you're passing (the first value).

    At the moment, you have a quantity of 22, with each 'amount' being 10. 10*22 = 220, and since you're only putting in 200 in the first value, you're mis-matching them. Fix that and you should be good to go.