ActiveMerchat是Shopify电子商务系统的提取(extractio)。它发展了RubyoRails网络应用程序的用途,能够作为一个Rails插件实现无缝集成,当然它也可以单独作为一个Ruby库使用。
ActiveMerchat自创建以后就被用于现在Ruby应用程序中,用来处理金融交易。
下面程序示例展示了如何使用个人信用卡购买东西的过程:
require 'active_merchat'# Use the TrustCommerce test serversActiveMerchat::Billig::Base.mode = :testgateway = ActiveMerchat::Billig::TrustCommerceGateway.ew( :logi => 'TestMerchat', :password => 'password')# ActiveMerchat accepts all amouts as Iteger values i cetsamout = 1000 # $10.00# The card verificatio value is also kow as CVV2, CVC2, or CIDcredit_card = ActiveMerchat::Billig::CreditCard.ew( :first_ame => 'Bob', :last_ame => 'Bobse', :umber => '4242424242424242', :moth => '8', :year => Time.ow.year+1, :verificatio_value => '000')# Validatig the card automatically detects the card typeif credit_card.validate.empty? # Capture $10 from the credit card respose = gateway.purchase(amout, credit_card) if respose.success? puts "Successfully charged $#{spritf("%.2f", amout / 100)} to the credit card #{credit_card.display_umber}" else raise StadardError, respose.message eded
评论