Class: ActiveMerchant::Billing::SageGateway

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

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Constructor Details

#initialize(options = {}) ⇒ SageGateway

Creates a new SageGateway

The gateway requires that a valid login and password be passed in the options hash.

Options

  • :login - The Sage Payment Solutions Merchant ID Number.

  • :password - The Sage Payment Solutions Merchant Key Number.


22
23
24
25
# File 'lib/active_merchant/billing/gateways/sage.rb', line 22

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

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object

Performs an authorization transaction

Parameters

  • money - The amount to be authorized as an integer value in cents.

  • credit_card - The CreditCard object to be used as the funding source for the transaction.

  • options - A hash of optional parameters.

    • :order_id - A unique reference for this order. (maximum of 20 characters).

    • :email - The customer's email address

    • :customer - The Customer Number for Purchase Card Level II Transactions

    • :billing_address - The customer's billing address as a hash of address information.

      • :address1 - The billing address street

      • :city - The billing address city

      • :state - The billing address state

      • :country - The 2 digit ISO billing address country code

      • :zip - The billing address zip code

      • :phone - The billing address phone number

      • :fax - The billing address fax number

    • :shipping_address - The customer's shipping address as a hash of address information.

      • :name - The name at the shipping address

      • :address1 - The shipping address street

      • :city - The shipping address city

      • :state - The shipping address state code

      • :country - The 2 digit ISO shipping address country code

      • :zip - The shipping address zip code

    • :tax - The tax amount for the transaction as an Integer value in cents. Maps to Sage T_tax.

    • :shipping - The shipping amount for the transaction as an Integer value in cents. Maps to Sage T_shipping.


53
54
55
# File 'lib/active_merchant/billing/gateways/sage.rb', line 53

def authorize(money, credit_card, options = {})
  bankcard.authorize(money, credit_card, options)
end

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

Captures authorized funds.

Parameters

  • money - The amount to be authorized as an integer value in cents. Sage doesn't support changing the capture amount, so the full amount of the initial transaction will be captured.

  • reference - The authorization reference string returned by the original transaction's Response#authorization.


106
107
108
# File 'lib/active_merchant/billing/gateways/sage.rb', line 106

def capture(money, reference, options = {})
  bankcard.capture(money, reference, options)
end

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


123
124
125
126
# File 'lib/active_merchant/billing/gateways/sage.rb', line 123

def credit(money, source, options = {})
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, source, options)
end

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

Performs a purchase, which is essentially an authorization and capture in a single operation.

Parameters

  • money - The amount to be authorized as an integer value in cents.

  • source - The CreditCard or Check object to be used as the funding source for the transaction.

  • options - A hash of optional parameters.

    • :order_id - A unique reference for this order. (maximum of 20 characters).

    • :email - The customer's email address

    • :customer - The Customer Number for Purchase Card Level II Transactions

    • :billing_address - The customer's billing address as a hash of address information.

      • :address1 - The billing address street

      • :city - The billing address city

      • :state - The billing address state

      • :country - The 2 digit ISO billing address country code

      • :zip - The billing address zip code

      • :phone - The billing address phone number

      • :fax - The billing address fax number

    • :shipping_address - The customer's shipping address as a hash of address information.

      • :name - The name at the shipping address

      • :address1 - The shipping address street

      • :city - The shipping address city

      • :state - The shipping address state code

      • :country - The 2 digit ISO shipping address country code

      • :zip - The shipping address zip code

    • :tax - The tax amount for the transaction as an integer value in cents. Maps to Sage T_tax.

    • :shipping - The shipping amount for the transaction as an integer value in cents. Maps to Sage T_shipping.

Additional options in the options hash for when using a Check as the funding source

  • :originator_id - 10 digit originator. If not provided, Sage will use the default Originator ID for the specific customer type.

  • :addenda - Transaction addenda.

  • :ssn - The customer's Social Security Number.

  • :drivers_license_state - The customer's drivers license state code.

  • :drivers_license_number - The customer's drivers license number.

  • :date_of_birth - The customer's date of birth as a Time or Date object or a string in the format mm/dd/yyyy.


92
93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/sage.rb', line 92

def purchase(money, source, options = {})
  if card_brand(source) == "check"
    virtual_check.purchase(money, source, options)
  else
    bankcard.purchase(money, source, options)
  end
end

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

Performs a refund transaction.

Parameters

  • money - The amount to be authorized as an integer value in cents.

  • source - The CreditCard or Check object to be used as the target for the refund.


134
135
136
137
138
139
140
# File 'lib/active_merchant/billing/gateways/sage.rb', line 134

def refund(money, source, options = {})
  if card_brand(source) == "check"
    virtual_check.refund(money, source, options)
  else
    bankcard.refund(money, source, options)
  end
end

#store(credit_card, options = {}) ⇒ Object

Stores a credit card in the Sage vault.

Parameters

  • credit_card - The CreditCard object to be stored.


147
148
149
# File 'lib/active_merchant/billing/gateways/sage.rb', line 147

def store(credit_card, options = {})
  vault.store(credit_card, options)
end

#unstore(identification, options = {}) ⇒ Object

Deletes a stored card from the Sage vault.

Parameters

  • identification - The 'GUID' identifying the stored card.


156
157
158
# File 'lib/active_merchant/billing/gateways/sage.rb', line 156

def unstore(identification, options = {})
  vault.unstore(identification, options)
end

#void(reference, options = {}) ⇒ Object

Voids a prior transaction. Works for both CreditCard and Check transactions.

Parameters

  • reference - The authorization reference string returned by the original transaction's Response#authorization.


115
116
117
118
119
120
121
# File 'lib/active_merchant/billing/gateways/sage.rb', line 115

def void(reference, options = {})
  if reference.split(";").last == "virtual_check"
    virtual_check.void(reference, options)
  else
    bankcard.void(reference, options)
  end
end