Class: ActiveMerchant::Billing::S5Gateway

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

Constant Summary collapse

SUPPORTED_TRANSACTIONS =
{
  'sale'      => 'CC.DB',
  'authonly'  => 'CC.PA',
  'capture'   => 'CC.CP',
  'refund'    => 'CC.RF',
  'void'      => 'CC.RV',
  'store'     => 'CC.RG'
}

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?, #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 = {}) ⇒ S5Gateway

Returns a new instance of S5Gateway.



25
26
27
28
# File 'lib/active_merchant/billing/gateways/s5.rb', line 25

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

Instance Method Details

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



50
51
52
53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/s5.rb', line 50

def authorize(money, payment, options={})
  request = build_xml_request do |xml|
    add_payment(xml, money, 'authonly', options)
    (xml, payment)
    add_customer(xml, payment, options)
    add_recurrence_mode(xml, options)
  end

  commit(request)
end

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



61
62
63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/s5.rb', line 61

def capture(money, authorization, options={})
  request = build_xml_request do |xml|
    add_identification(xml, authorization)
    add_payment(xml, money, 'capture', options)
  end

  commit(request)
end

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



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/s5.rb', line 30

def purchase(money, payment, options={})
  request = build_xml_request do |xml|
    add_payment(xml, money, 'sale', options)
    (xml, payment)
    add_customer(xml, payment, options)
    add_recurrence_mode(xml, options)
  end

  commit(request)
end

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



41
42
43
44
45
46
47
48
# File 'lib/active_merchant/billing/gateways/s5.rb', line 41

def refund(money, authorization, options={})
  request = build_xml_request do |xml|
    add_identification(xml, authorization)
    add_payment(xml, money, 'refund', options)
  end

  commit(request)
end

#scrub(transcript) ⇒ Object



101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/s5.rb', line 101

def scrub(transcript)
  transcript.
    gsub(%r((pwd=).+?(/>))i, '\1[FILTERED]\2').
    gsub(%r((<Number>).+?(</Number>))i, '\1[FILTERED]\2').
    gsub(%r((<Verification>).+?(</Verification>))i, '\1[FILTERED]\2')
end

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



79
80
81
82
83
84
85
86
87
# File 'lib/active_merchant/billing/gateways/s5.rb', line 79

def store(payment, options = {})
  request = build_xml_request do |xml|
    xml.Payment(code: SUPPORTED_TRANSACTIONS["store"])
    (xml, payment)
    add_customer(xml, payment, options)
  end

  commit(request)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/active_merchant/billing/gateways/s5.rb', line 97

def supports_scrubbing?
  true
end

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



89
90
91
92
93
94
# File 'lib/active_merchant/billing/gateways/s5.rb', line 89

def verify(credit_card, options={})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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



70
71
72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/s5.rb', line 70

def void(authorization, options={})
  request = build_xml_request do |xml|
    add_identification(xml, authorization)
    add_payment(xml, nil, 'void', options)
  end

  commit(request)
end