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'
TRANSACTION_API =
'/createShopifyTransaction.php'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

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.



29
30
31
32
# File 'lib/active_merchant/billing/gateways/swipe_checkout.rb', line 29

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



36
37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/swipe_checkout.rb', line 36

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