I managed to achieve this quite easily by following these steps:
, , Paymill, . , . , .
script:
require 'rubygems'
require 'active_merchant'
require 'json'
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::PaymillGateway.new(
:public_key => 'MY_PAYMILL_PUBLIC_KEY',
:private_key => 'MY_PAYMILL_PRIVATE_KEY')
gateway.default_currency = 'USD'
amount = 1000
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '5500000000000004',
:month => '8',
:year => Time.now.year+1,
:verification_value => '000')
if credit_card.valid?
response = gateway.purchase(amount, credit_card)
if response.success?
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
else
raise StandardError, response.message
end
end