Class: ActiveMerchant::Billing::SwipeCheckoutGateway

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

Constant Summary collapse

TRANSACTION_APPROVED_MSG =
'Transaction approved'
TRANSACTION_DECLINED_MSG =
'Transaction declined'
LIVE_URLS =
{
  'NZ' => 'https://api.swipehq.com',
  'CA' => 'https://api.swipehq.ca'
}
TRANSACTION_API =
'/createShopifyTransaction.php'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

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

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ SwipeCheckoutGateway

Swipe Checkout requires the merchant’s email and API key for authorization. This can be found under Settings > API Credentials after logging in to your Swipe Checkout merchant console at merchant.swipehq.[com|ca]

:region determines which Swipe URL is used, this can be one of “NZ” or “CA”. Currently Swipe Checkout has New Zealand and Canadian domains (swipehq.com and swipehq.ca respectively). Merchants must use the region that they signed up in for authentication with their merchant ID and API key to succeed.



32
33
34
35
# File 'lib/active_merchant/billing/gateways/swipe_checkout.rb', line 32

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

Instance Method Details

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

Transfers funds immediately. Note that Swipe Checkout only supports purchase at this stage



39
40
41
42
43
44
45
46
47
# File 'lib/active_merchant/billing/gateways/swipe_checkout.rb', line 39

def purchase(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_customer_data(post, creditcard, options)
  add_amount(post, money, options)

  commit('sale', money, post)
end