ruby on rails - ActiveMerchant: Send item details to paypal url -


i trying integrate paypal-express-checkout rails 4 app using active merchant gem. have redirected paypal not able send item details (only amount passed paypal).

here did:

total_amount = cart_items.sum(:amount)  items = [] cart_items.each_with_index |item, index|   items << {       "l_paymentrequest_0_name#{index+1}" => item.product_name,       "l_paymentrequest_0_amt#{index+1}" => to_cents(item.amount),       "l_paymentrequest_0_qty#{index+1}" => item.quantity   } end  response = express_gateway.setup_purchase(total_amount,                                           :items             => items,                                           :return_url        => new_order_url,                                           :cancel_return_url => root_url ) redirect_to express_gateway.redirect_url_for(response.token) 

and happened:

enter image description here

i have checked response error cannot find any:

(byebug) response #<activemerchant::billing::paypalexpressresponse:0x00000112831748 @params={"timestamp"=>"2015-07-17t12:43:53z", "ack"=>"success", "correlation_id"=>"7cd013c59c176", "version"=>"72", "build"=>"17403434", "token"=>"ec-94a59640dj829313s", "timestamp"=>"2015-07-17t12:43:53z", "ack"=>"success", "correlationid"=>"7cd013c59c176", "version"=>"72", "build"=>"17403434", "token"=>"ec-94a59640dj829313s"}, @message="success", @success=true, @test=true, @authorization=nil, @fraud_review=false, @error_code=nil, @emv_authorization=nil, @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, @cvv_result={"code"=>nil, "message"=>nil}> 

note "message"=>nil, , @message="success",

can please suggest doing wrong.

after going through code, found solution problem leads problem: "the totals of cart item amounts not match order amounts."

what did:

total_amount = cart_items.sum(:amount)  # item must in [{}, {}] format items = [] cart_items.each |item|   items << {       :name => item.product_name.to_s,       :amount => to_cents(item.amount),       :quantity => item.quantity   } end  response = express_gateway.setup_purchase(total_amount,                                       :items             => items,                                       :return_url        => new_order_url,                                       :cancel_return_url => root_url ) redirect_to express_gateway.redirect_url_for(response.token) 

here, total_amount in dollar , amount in cent. have changed currency total_amount cent still no work. don't know how paypal calculates total amount quantity , amount.

actually happened:

when checked value total_amount , calculated_total_amount_from_each_item, there saw no problem total_amount , calculated amount.

enter image description here enter image description here

still original question has not been solved. can 1 suggest me right direction.

after googling problems, found out this issue in github. in order paypal work 1 must include shipping, tax , handling option in setup_purchase function. issue , solution. did solved problems.


Comments