Can't get ActiveMerchant to apply amount in dollars for CyberSource

8 views
Skip to first unread message

TimBooher

unread,
Jul 1, 2008, 8:49:23 PM7/1/08
to Active Merchant
Since cybersource measures in dollars, is there an
elegant way to covert in my amount. Per the peepcode, I am loading an
amount in cents, so I multiply my amount by 100, this naturally works
but then I have a total amount in my reports in the thousands. I can
divide again by 100, but I am sure there is a better way.

I can't seem to set this in options, such as:

config.to_prepare do
OrderTransaction.gateway =
ActiveMerchant::Billing::CyberSourceGateway.new(
:login => 'mylogin',
:password => 'mypasssword',
:test => true,
:vat_reg_number => 'your VAT registration number',
# sets the states/provinces where you have a physical presense for
tax purposes
:nexus => "GA OH",
# don‘t want to use AVS so continue processing even if AVS would
have failed
:ignore_avs => true,
# don‘t want to use CVV so continue processing even if CVV would
have failed
:ignore_cvv => true,
:money_format => :dollars
)

end

then i have do things like
def save_order
user = User.find(session[:user_id])
int_gender = user.gender
if not_assigned?(int_gender, params[:health_approval])
flash[:notice] = 'You must answer all consent questions'
redirect_to :action => 'consent'
else
amount = @cart.total_price/100
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
desc = 'test'
@order = Order.new(:user_id => usr_id,
:amount => amount,
:description => desc)
if @order.save
redirect_to :action => :payment, :id => @order.id
else # something went wrong
redirect_to_index(@order.errors,1)
end
end
end

Cody Fauser

unread,
Jul 1, 2008, 9:25:32 PM7/1/08
to activem...@googlegroups.com
ActiveMerchant requires the amount to be passed to the gateway in
cents no matter what the format is for the underlying gateway. This
means that you would give authorize() or purchase() the amount in
cents, just like in the PeepCode PDF. ActiveMerchant does the right
thing when communicating with the gateway.

--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

TimBooher

unread,
Jul 3, 2008, 7:12:47 AM7/3/08
to Active Merchant
Thanks! you are correct and everything works just fine.

tim
Reply all
Reply to author
Forward
0 new messages