Class: ActiveMerchant::Billing::SageGateway

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

Defined Under Namespace

Classes: SageVault

Constant Summary collapse

TRANSACTIONS =
{
  :purchase           => '01',
  :authorization      => '02',
  :capture            => '11',
  :void               => '04',
  :credit             => '06',
  :refund             => '10'
}
SOURCE_CARD =
"bankcard"
SOURCE_ECHECK =
"virtual_check"

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, 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, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ SageGateway

Returns a new instance of SageGateway.



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

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

Instance Method Details

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



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

def authorize(money, credit_card, options = {})
  post = {}
  add_credit_card(post, credit_card)
  add_transaction_data(post, money, options)
  commit(:authorization, post, SOURCE_CARD)
end

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

The money amount is not used. The entire amount of the initial authorization will be captured.



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

def capture(money, reference, options = {})
  post = {}
  add_reference(post, reference)
  commit(:capture, post, SOURCE_CARD)
end

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



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

def credit(money, payment_method, options = {})
  post = {}
  if card_brand(payment_method) == "check"
    source = SOURCE_ECHECK
    add_check(post, payment_method)
    add_check_customer_data(post, options)
  else
    source = SOURCE_CARD
    add_credit_card(post, payment_method)
  end
  add_transaction_data(post, money, options)
  commit(:credit, post, source)
end

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



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/active_merchant/billing/gateways/sage.rb', line 35

def purchase(money, payment_method, options = {})
  post = {}
  if card_brand(payment_method) == "check"
    source = SOURCE_ECHECK
    add_check(post, payment_method)
    add_check_customer_data(post, options)
  else
    source = SOURCE_CARD
    add_credit_card(post, payment_method)
  end
  add_transaction_data(post, money, options)
  commit(:purchase, post, source)
end

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



78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/sage.rb', line 78

def refund(money, reference, options={})
  post = {}
  add_reference(post, reference)
  add_transaction_data(post, money, options)
  commit(:refund, post, SOURCE_CARD)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
   force_utf8(transcript).
    gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
    gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
    gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
    gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
    gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2').
    gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2').
    gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2')
end

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



85
86
87
# File 'lib/active_merchant/billing/gateways/sage.rb', line 85

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



89
90
91
# File 'lib/active_merchant/billing/gateways/sage.rb', line 89

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

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



57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/sage.rb', line 57

def void(reference, options = {})
  post = {}
  add_reference(post, reference)
  source = reference.split(";").last
  commit(:void, post, source)
end