Module: MerbMerchant::Billing::BeanstreamCore

Included in:
BeanstreamGateway, BeanstreamInteracGateway
Defined in:
lib/merb_merchant/billing/gateways/beanstream/beanstream_core.rb

Constant Summary collapse

URL =
'https://www.beanstream.com/scripts/process_transaction.asp'
TRANSACTIONS =
{
  :authorization  => 'PA',
  :purchase       => 'P',
  :capture        => 'PAC',
  :credit         => 'R',
  :void           => 'VP',
  :check_purchase => 'D',
  :check_credit   => 'C',
  :void_purchase  => 'VP',
  :void_credit    => 'VR'
}
CVD_CODES =
{
  '1' => 'M',
  '2' => 'N',
  '3' => 'I',
  '4' => 'S',
  '5' => 'U',
  '6' => 'P'
}
AVS_CODES =
{
  '0' => 'R',
  '5' => 'I',
  '9' => 'I'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/merb_merchant/billing/gateways/beanstream/beanstream_core.rb', line 33

def self.included(base)
  base.default_currency = 'CAD'

  # The countries the gateway supports merchants from as 2 digit ISO country codes
  base.supported_countries = ['CA']

  # The card types supported by the payment gateway
  base.supported_cardtypes = [:visa, :master, :american_express]

  # The homepage URL of the gateway
  base.homepage_url = 'http://www.beanstream.com/'

  # The name of the gateway
  base.display_name = 'Beanstream.com'
end

Instance Method Details

#capture(money, authorization, options = {}) ⇒ Object



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

def capture(money, authorization, options = {})
  reference, amount, type = split_auth(authorization)
  
  post = {}
  add_amount(post, money)
  add_reference(post, reference)
  add_transaction_type(post, :capture)
  commit(post)
end

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



70
71
72
73
74
75
76
77
# File 'lib/merb_merchant/billing/gateways/beanstream/beanstream_core.rb', line 70

def credit(money, source, options = {})
  post = {}
  reference, amount, type = split_auth(source)
  add_reference(post, reference)
  add_transaction_type(post, credit_action(type))
  add_amount(post, money)
  commit(post)
end

#initialize(options = {}) ⇒ Object

Only :login is required by default, which is the merchant’s merchant ID. If you’d like to perform void, capture or credit transactions then you’ll also need to add a username and password to your account under administration -> account settings -> order settings -> Use username/password validation



54
55
56
57
58
# File 'lib/merb_merchant/billing/gateways/beanstream/beanstream_core.rb', line 54

def initialize(options = {})
  requires!(options, :login)
  @options = options
  super
end