Created
December 25, 2013 12:21
-
-
Save keikubo/8122781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_merchant' | |
ActiveMerchant::Billing::Base.mode = :test | |
gateway = ActiveMerchant::Billing::WebpayGateway.new(:login => 'test_secret_eHn4TTgsGguBcW764a2KA8Yd') | |
amount = 10000 # 100 yen | |
credit_card = ActiveMerchant::Billing::CreditCard.new( | |
:first_name => 'Kei', | |
:last_name => 'Kubo', | |
:number => '4242424242424242', | |
:month => '8', | |
:year => Time.now.year+1, | |
:verification_value => '000') | |
if credit_card.valid? | |
response = gateway.purchase(amount, credit_card) | |
if response.success? | |
puts "Charged #{sprintf("%.2f", amount / 100)} yen to #{credit_card.display_number}." | |
else | |
raise StandardError, response.message | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment