Class: ActiveMerchant::Billing::BeanstreamGateway

Inherits:
Gateway
  • Object
show all
Includes:
BeanstreamCore
Defined in:
lib/active_merchant/billing/gateways/beanstream.rb

Overview

This class implements the Canadian Beanstream payment gateway. It is also named TD Canada Trust Online Mart payment gateway. To learn more about the specification of Beanstream gateway, please read the OM_Direct_Interface_API.pdf, which you can get from your Beanstream account or get from me by email.

Supported transaction types by Beanstream:

  • P - Purchase

  • PA - Pre Authorization

  • PAC - Pre Authorization Completion

Notes

  • Recurring billing is not yet implemented.

  • Adding of order products information is not implemented.

  • Ensure that country and province data is provided as a code such as “CA”, “US”, “QC”.

  • login is the Beanstream merchant ID, username and password should be enabled in your Beanstream account and passed in using the :user and :password options.

  • Test your app with your true merchant id and test credit card information provided in the api pdf document.

Example authorization (Beanstream PA transaction type):

 twenty = 2000
 gateway = BeanstreamGateway.new(
   :login => '100200000',
   :user => 'xiaobozz',
   :password => 'password'
 )

 credit_card = CreditCard.new(
   :number => '4030000010001234',
   :month => 8,
   :year => 2011,
   :first_name => 'xiaobo',
   :last_name => 'zzz',
   :verification_value => 137
 )
 response = gateway.authorize(twenty, credit_card,
   :order_id => '1234',
   :billing_address => {
     :name => 'xiaobo zzz',
     :phone => '555-555-5555',
     :address1 => '1234 Levesque St.',
     :address2 => 'Apt B',
     :city => 'Montreal',
     :state => 'QC',
     :country => 'CA',
     :zip => 'H2C1X8'
   },
   :email => '[email protected]',
   :subtotal => 800,
   :shipping => 100,
   :tax1 => 100,
   :tax2 => 100,
   :custom => 'reference one'
 )

Constant Summary

Constants included from BeanstreamCore

ActiveMerchant::Billing::BeanstreamCore::AVS_CODES, ActiveMerchant::Billing::BeanstreamCore::CVD_CODES, ActiveMerchant::Billing::BeanstreamCore::TRANSACTIONS, ActiveMerchant::Billing::BeanstreamCore::URL

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods included from BeanstreamCore

#capture, #credit, included, #initialize

Methods inherited from Gateway

#card_brand, card_brand, inherited, #initialize, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #retry_exceptions, #ssl_post

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 61

def authorize(money, credit_card, options = {})
  post = {}
  add_amount(post, money)
  add_invoice(post, options)
  add_credit_card(post, credit_card)        
  add_address(post, options)
  add_transaction_type(post, :authorization)
  commit(post)
end

#interacObject



91
92
93
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 91

def interac
  @interac ||= BeanstreamInteracGateway.new(@options)
end

#purchase(money, source, options = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 71

def purchase(money, source, options = {})
  post = {}
  add_amount(post, money) 
  add_invoice(post, options)
  add_source(post, source)
  add_address(post, options)
  add_transaction_type(post, purchase_action(source))
  commit(post)
end

#void(authorization, options = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 81

def void(authorization, options = {})
  reference, amount, type = split_auth(authorization)
  
  post = {}
  add_reference(post, reference)
  add_original_amount(post, amount)
  add_transaction_type(post, void_action(type))
  commit(post)
end