Module: ActiveMerchant::Billing::BeanstreamCore

Includes:
Empty
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'
}
STATES =
{
  'ALBERTA' => 'AB',
  'BRITISH COLUMBIA' => 'BC',
  'MANITOBA' => 'MB',
  'NEW BRUNSWICK' => 'NB',
  'NEWFOUNDLAND AND LABRADOR' => 'NL',
  'NOVA SCOTIA' => 'NS',
  'ONTARIO' => 'ON',
  'PRINCE EDWARD ISLAND' => 'PE',
  'QUEBEC' => 'QC',
  'SASKATCHEWAN' => 'SK',
  'NORTHWEST TERRITORIES' => 'NT',
  'NUNAVUT' => 'NU',
  'YUKON' => 'YT',
  'ALABAMA' => 'AL',
  'ALASKA' => 'AK',
  'ARIZONA' => 'AZ',
  'ARKANSAS' => 'AR',
  'CALIFORNIA' => 'CA',
  'COLORADO' => 'CO',
  'CONNECTICUT' => 'CT',
  'DELAWARE' => 'DE',
  'FLORIDA' => 'FL',
  'GEORGIA' => 'GA',
  'HAWAII' => 'HI',
  'IDAHO' => 'ID',
  'ILLINOIS' => 'IL',
  'INDIANA' => 'IN',
  'IOWA' => 'IA',
  'KANSAS' => 'KS',
  'KENTUCKY' => 'KY',
  'LOUISIANA' => 'LA',
  'MAINE' => 'ME',
  'MARYLAND' => 'MD',
  'MASSACHUSETTS' => 'MA',
  'MICHIGAN' => 'MI',
  'MINNESOTA' => 'MN',
  'MISSISSIPPI' => 'MS',
  'MISSOURI' => 'MO',
  'MONTANA' => 'MT',
  'NEBRASKA' => 'NE',
  'NEVADA' => 'NV',
  'NEW HAMPSHIRE' => 'NH',
  'NEW JERSEY' => 'NJ',
  'NEW MEXICO' => 'NM',
  'NEW YORK' => 'NY',
  'NORTH CAROLINA' => 'NC',
  'NORTH DAKOTA' => 'ND',
  'OHIO' => 'OH',
  'OKLAHOMA' => 'OK',
  'OREGON' => 'OR',
  'PENNSYLVANIA' => 'PA',
  'RHODE ISLAND' => 'RI',
  'SOUTH CAROLINA' => 'SC',
  'SOUTH DAKOTA' => 'SD',
  'TENNESSEE' => 'TN',
  'TEXAS' => 'TX',
  'UTAH' => 'UT',
  'VERMONT' => 'VT',
  'VIRGINIA' => 'VA',
  'WASHINGTON' => 'WA',
  'WEST VIRGINIA' => 'WV',
  'WISCONSIN' => 'WI',
  'WYOMING' => 'WY'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 130

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://api.na.bambora.com/scripts/process_transaction.asp'

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

Instance Method Details

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



157
158
159
160
161
162
163
164
165
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 157

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

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



176
177
178
179
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 176

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



152
153
154
155
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 152

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

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



167
168
169
170
171
172
173
174
# File 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb', line 167

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