Module: ActiveMerchant::Billing::BeanstreamCore

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

Constant Summary collapse

RECURRING_URL =
'https://www.beanstream.com/scripts/recurring_billing.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'
}
PERIODS =
{
  :days   => 'D',
  :weeks  => 'W',
  :months => 'M',
  :years  => 'Y'
}
PERIODICITIES =
{
  :daily     => [:days, 1],
  :weekly    => [:weeks, 1],
  :biweekly  => [:weeks, 2],
  :monthly   => [:months, 1],
  :bimonthly => [:months, 2],
  :yearly    => [:years, 1]
}
RECURRING_OPERATION =
{
  :update => 'M',
  :cancel => 'C'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 62

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', 'US']

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

  # The homepage URL of the gateway
  base.homepage_url = 'http://www.beanstream.com/'
  base.live_url = 'https://www.beanstream.com/scripts/process_transaction.asp'

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

Instance Method Details

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



89
90
91
92
93
94
95
96
97
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 89

def capture(money, authorization, options = {})
  reference, _, _ = 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



108
109
110
111
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 108

def credit(money, source, options = {})
  ActiveMerchant.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



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

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

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



99
100
101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 99

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