07 - charging a credit card.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 32 行

RB
32
字号
require 'rubygems'require 'payment/authorize_net'transaction = Payment::AuthorizeNet.new(  :login           => 'username',  :transaction_key => 'my_key',  :amount          => '49.95',  :card_number     => '4012888818888',  :expiration      => '0310',  :first_name      => 'John',  :last_name       => 'Doe')#---begin  transaction.submit  puts "Card processed successfully: #{transaction.authorization}"rescue Payment::PaymentError  puts "Card was rejected: #{transaction.error_message}"end# Card was rejected: The merchant login ID or password is invalid # or the account is inactive.#---login: usernametransaction_key: my_key#---payment = Payment::AuthorizeNet	.new(:prefs => "#{RAILS_ROOT}/config/payment.yml")payment.amount = 20payment.card_number = 'bogus'payment.submit rescue "That didn't work"#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?