Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 933
Alex Fox Avatar asked Feb 13 '12 12:02

Alex Fox


2 Answers

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.

like image 86
Wakeuphate Avatar answered Sep 23 '22 04:09

Wakeuphate


I have encountered the same issue and have finally found the reason, and it is unbelievably stupid. Are you ready?

There is a mismatch between the total price you specified (200) and the sum of your items (22*10=220). If you change your quantity to 20, it will work. Paypal requires that the sum of your items' cost would equal the total price you specify. I have no idea how I realised this.

like image 42
lior Avatar answered Sep 20 '22 04:09

lior