Ryan
unread,Jun 27, 2008, 10:34:02 AM6/27/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Active Merchant
Hi,
I have been developing a shopping cart with Active Merchant utilizing
PayPal as a gateway. I seem to have run into a problem with the
purchase amount. In both PayPal express and using the PayPal gateway
the purchase amount gets its decimal point moved two places to the
left. 200.00 becomes 2.00. I can't seem to figure out the solution. I
have included part of my code where BILL_AMOUNT is the purchase priced
passed to PayPal (I set it to a static value for testing). Perhaps I
need to format the value I am passing in a different way?
Any help or suggestions are appreciated.
Ryan
class PurchaseController < ApplicationController
include SslRequirement
ssl_required :index, :credit
before_filter :load_card
filter_parameter_logging :creditcard
# This amount will INCORRECTLY equal 5.12 once processed
BILL_AMOUNT = 512.00
# This amount will CORRECTLY equal 512.00 once processed BUT has
extra zeros added on
#BILL_AMOUNT = 51200.00
def index
#@totalamount = session[:pricetopay]
@totalamount = BILL_AMOUNT
@piecetitle = session[:itemtitle]
end
# Use the DirectPayment API
def credit
render :action => 'index' and return unless @creditcard.valid?
@response = paypal_gateway.purchase(BILL_AMOUNT, @creditcard,
:ip => request.remote_ip)
if @response.success?
@purchase = Purchase.create(:response => @response)
redirect_to :action => "complete", :id => @purchase
else
paypal_error(@response)
end
end