Class: ActiveMerchant::Billing::ElementGateway

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

Constant Summary collapse

SERVICE_TEST_URL =
'https://certservices.elementexpress.com/express.asmx'
SERVICE_LIVE_URL =
'https://services.elementexpress.com/express.asmx'

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 = {}) ⇒ ElementGateway

Returns a new instance of ElementGateway.



20
21
22
23
# File 'lib/active_merchant/billing/gateways/element.rb', line 20

def initialize(options={})
  requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version)
  super
end

Instance Method Details

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



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_merchant/billing/gateways/element.rb', line 41

def authorize(money, payment, options={})
  request = build_soap_request do |xml|
    xml.CreditCardAuthorization(xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_payment_method(xml, payment)
      add_transaction(xml, money, options)
      add_terminal(xml, options)
      add_address(xml, options)
    end
  end

  commit('CreditCardAuthorization', request, money)
end

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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/element.rb', line 55

def capture(money, authorization, options={})
  trans_id, _ = split_authorization(authorization)
  options.merge!({trans_id: trans_id})

  request = build_soap_request do |xml|
    xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_transaction(xml, money, options)
      add_terminal(xml, options)
    end
  end

  commit('CreditCardAuthorizationCompletion', request, money)
end

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/element.rb', line 25

def purchase(money, payment, options={})
  action = payment.is_a?(Check) ? 'CheckSale' : 'CreditCardSale'

  request = build_soap_request do |xml|
    xml.send(action, xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_payment_method(xml, payment)
      add_transaction(xml, money, options)
      add_terminal(xml, options)
      add_address(xml, options)
    end
  end

  commit(action, request, money)
end

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/element.rb', line 70

def refund(money, authorization, options={})
  trans_id, _ = split_authorization(authorization)
  options.merge!({trans_id: trans_id})

  request = build_soap_request do |xml|
    xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_transaction(xml, money, options)
      add_terminal(xml, options)
    end
  end

  commit('CreditCardReturn', request, money)
end

#scrub(transcript) ⇒ Object



124
125
126
127
128
129
130
131
# File 'lib/active_merchant/billing/gateways/element.rb', line 124

def scrub(transcript)
  transcript.
    gsub(%r((<AccountToken>).+?(</AccountToken>))i, '\1[FILTERED]\2').
    gsub(%r((<CardNumber>).+?(</CardNumber>))i, '\1[FILTERED]\2').
    gsub(%r((<CVV>).+?(</CVV>))i, '\1[FILTERED]\2').
    gsub(%r((<AccountNumber>).+?(</AccountNumber>))i, '\1[FILTERED]\2').
    gsub(%r((<RoutingNumber>).+?(</RoutingNumber>))i, '\1[FILTERED]\2')
end

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



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/active_merchant/billing/gateways/element.rb', line 100

def store(payment, options = {})
  request = build_soap_request do |xml|
    xml.PaymentAccountCreate(xmlns: 'https://services.elementexpress.com') do
      add_credentials(xml)
      add_payment_method(xml, payment)
      (xml, payment, options[:payment_account_reference_number] || SecureRandom.hex(20))
      add_address(xml, options)
    end
  end

  commit('PaymentAccountCreate', request, nil)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/active_merchant/billing/gateways/element.rb', line 120

def supports_scrubbing?
  true
end

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



113
114
115
116
117
118
# File 'lib/active_merchant/billing/gateways/element.rb', line 113

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



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/element.rb', line 85

def void(authorization, options={})
  trans_id, trans_amount = split_authorization(authorization)
  options.merge!({trans_id: trans_id, trans_amount: trans_amount, reversal_type: 'Full'})

  request = build_soap_request do |xml|
    xml.CreditCardReversal(xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_transaction(xml, trans_amount, options)
      add_terminal(xml, options)
    end
  end

  commit('CreditCardReversal', request, trans_amount)
end