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'
NETWORK_TOKEN_TYPE =
{
  apple_pay: '2',
  google_pay: '1'
}

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, 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.



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

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



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/element.rb', line 46

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/element.rb', line 60

def capture(money, authorization, options = {})
  trans_id, = split_authorization(authorization)
  options[: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

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



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/active_merchant/billing/gateways/element.rb', line 90

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

  commit('CreditCardCredit', request, money)
end

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



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/element.rb', line 30

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



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/active_merchant/billing/gateways/element.rb', line 75

def refund(money, authorization, options = {})
  trans_id, = split_authorization(authorization)
  options[: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



150
151
152
153
154
155
156
157
# File 'lib/active_merchant/billing/gateways/element.rb', line 150

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



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/active_merchant/billing/gateways/element.rb', line 118

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)


146
147
148
# File 'lib/active_merchant/billing/gateways/element.rb', line 146

def supports_scrubbing?
  true
end

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



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/active_merchant/billing/gateways/element.rb', line 131

def verify(credit_card, options = {})
  request = build_soap_request do |xml|
    xml.CreditCardAVSOnly(xmlns: 'https://transaction.elementexpress.com') do
      add_credentials(xml)
      add_payment_method(xml, credit_card)
      add_transaction(xml, 0, options)
      add_terminal(xml, options)
      add_address(xml, options)
    end
  end

  # send request with the transaction amount set to 0
  commit('CreditCardAVSOnly', request, 0)
end

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



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/active_merchant/billing/gateways/element.rb', line 103

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