⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 07 - charging a credit card.rb

📁 O Reilly Ruby Cookbook source code
💻 RB
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -