Below is my class. I'm trying to pass the values (all strings) from a
record object to no avail. Literals are working fine with identical
data. I've commented out the card_data that doesn't work. Can anyone
clue me on what might be wrong?
TIA
class PaymentsController < ApplicationController
active_scaffold :payment do |config|
actions.exclude :delete, :show, :search
nested.shallow_delete = true
end
def checkout(record)
# ActiveMerchant accepts all amounts as Integer values in cents
# $10.00
amount = 1999
#This doesn't work
# card_data = {
# :first_name => @record.first_name,
# :last_name => @record.last_name,
# :number => @record.card_number,
# :month => @record.month,
# :year => @record.year,
# :verification_value => @record.verification_value
# }
# This works
card_data = {
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '4242424242424242',
:month => '8',
:year => '2012',
:verification_value => '123'
}
# The card verification value is also known as CVV2, CVC2, or CID
credit_card = ActiveMerchant::Billing::CreditCard.new(card_data)
if credit_card.valid?
# Authorize for the amount
response = gateway.authorize(amount, credit_card)
if response.success?
result = "Successfully authorised #{sprintf("%.2f", amount /
100)} to the credit card #{credit_card.display_number}"
else
raise StandardError, response.message
end
end
end
def before_create_save(record)
record.result = checkout(record)
end
def before_update_save(record)
record.result = checkout(record)
end
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---