Ruby on rails 我已经在ruby中集成了cybersource支付网关,但我想与rails集成
cybersource支付网关与ruby集成,运行良好。但我想与RubyonRails集成。是否可以与ruby on rails集成?您可以使用 范例Ruby on rails 我已经在ruby中集成了cybersource支付网关,但我想与rails集成,ruby-on-rails,Ruby On Rails,cybersource支付网关与ruby集成,运行良好。但我想与RubyonRails集成。是否可以与ruby on rails集成?您可以使用 范例 require 'active_merchant' # Use the TrustCommerce test servers ActiveMerchant::Billing::Base.mode = :test gateway = ActiveMerchant::Billing::CyberSourceGateway.new(
require 'active_merchant'
# Use the TrustCommerce test servers
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::CyberSourceGateway.new(
:login => 'TestMerchant',
:password => 'password')
# ActiveMerchant accepts all amounts as Integer values in cents
amount = 1000 # $10.00
# The card verification value is also known as CVV2, CVC2, or CID
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '4242424242424242',
:month => '8',
:year => Time.now.year+1,
:verification_value => '000')
# Validating the card automatically detects the card type
if credit_card.validate.empty?
# Capture $10 from the credit card
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
您可以使用
范例
require 'active_merchant'
# Use the TrustCommerce test servers
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::CyberSourceGateway.new(
:login => 'TestMerchant',
:password => 'password')
# ActiveMerchant accepts all amounts as Integer values in cents
amount = 1000 # $10.00
# The card verification value is also known as CVV2, CVC2, or CID
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '4242424242424242',
:month => '8',
:year => Time.now.year+1,
:verification_value => '000')
# Validating the card automatically detects the card type
if credit_card.validate.empty?
# Capture $10 from the credit card
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