Module: ActiveMerchant::Billing::BeanstreamCore

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

Constant Summary collapse

URL =
'https://www.beanstream.com/scripts/process_transaction.asp'
SECURE_PROFILE_URL =
'https://www.beanstream.com/scripts/payment_profile.asp'
SP_SERVICE_VERSION =
'1.1'
TRANSACTIONS =
{
  :authorization  => 'PA',
  :purchase       => 'P',
  :capture        => 'PAC',
  :refund         => 'R',
  :void           => 'VP',
  :check_purchase => 'D',
  :check_refund   => 'C',
  :void_purchase  => 'VP',
  :void_refund    => 'VR'
}
PROFILE_OPERATIONS =
{
  :new => 'N',
  :modify => 'M'
}
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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 40

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



67
68
69
70
71
72
73
74
75
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 67

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



86
87
88
89
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 86

def credit(money, source, options = {})
  deprecated Gateway::CREDIT_DEPRECATION_MESSAGE
  refund(money, source, options)
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 refund 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



61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 61

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

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



77
78
79
80
81
82
83
84
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 77

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