Class: ActiveMerchant::Billing::EbanxGateway

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

Constant Summary collapse

TAGS =
['Spreedly']
URL_MAP =
{
  purchase: 'direct',
  authorize: 'direct',
  capture: 'capture',
  refund: 'refund',
  void: 'cancel',
  store: 'token',
  inquire: 'query',
  verify: 'verifycard'
}
HTTP_METHOD =
{
  purchase: :post,
  authorize: :post,
  capture: :get,
  refund: :post,
  void: :get,
  store: :post,
  inquire: :get,
  verify: :post
}

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?, #test?

Methods included from Versionable

#fetch_version, included

Methods included from CreditCardFormatting

#expdate, #format, #strftime_yyyymm

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ EbanxGateway

Returns a new instance of EbanxGateway.



39
40
41
42
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 39

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

Instance Method Details

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



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

def authorize(money, payment, options = {})
  post = { payment: {} }
  add_integration_key(post)
  add_operation(post)
  add_invoice(post, money, options)
  add_customer_data(post, payment, options)
  add_card_or_token(post, payment, options)
  add_address(post, options)
  add_customer_responsible_person(post, payment, options)
  add_additional_data(post, options)
  add_stored_credentials(post, options)
  post[:payment][:creditcard][:auto_capture] = false

  commit(:authorize, post, options)
end

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



75
76
77
78
79
80
81
82
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 75

def capture(money, authorization, options = {})
  post = {}
  add_integration_key(post)
  post[:hash] = authorization
  post[:amount] = amount(money) if options[:include_capture_amount].to_s == 'true'

  commit(:capture, post, options)
end

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



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

def inquire(authorization, options = {})
  post = {}
  add_integration_key(post)
  add_authorization(post, authorization)

  commit(:inquire, post, options)
end

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



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

def purchase(money, payment, options = {})
  post = { payment: {} }
  add_integration_key(post)
  add_operation(post)
  add_invoice(post, money, options)
  add_customer_data(post, payment, options)
  add_card_or_token(post, payment, options)
  add_address(post, options)
  add_customer_responsible_person(post, payment, options)
  add_additional_data(post, options)
  add_stored_credentials(post, options)

  commit(:purchase, post, options)
end

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



84
85
86
87
88
89
90
91
92
93
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 84

def refund(money, authorization, options = {})
  post = {}
  add_integration_key(post)
  add_operation(post)
  add_authorization(post, authorization)
  post[:amount] = amount(money)
  post[:description] = options[:description]

  commit(:refund, post, options)
end

#scrub(transcript) ⇒ Object



140
141
142
143
144
145
146
147
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 140

def scrub(transcript)
  transcript.
    gsub(/(integration_key\\?":\\?")(\w*)/, '\1[FILTERED]').
    gsub(/(card_number\\?":\\?")(\d*)/, '\1[FILTERED]').
    gsub(/(card_cvv\\?":\\?")(\d*)/, '\1[FILTERED]').
    gsub(/(network_token_pan\\?":\\?")(\d*)/, '\1[FILTERED]').
    gsub(/(network_token_cryptogram\\?":\\?")([\w+=\/]*)/, '\1[FILTERED]')
end

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



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

def store(credit_card, options = {})
  post = {}
  add_integration_key(post)
  customer_country(post, options)
  add_payment_type(post, options)
  post[:creditcard] = payment_details(credit_card)

  commit(:store, post, options)
end

#supports_network_tokenization?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 132

def supports_network_tokenization?
  true
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 136

def supports_scrubbing?
  true
end

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



113
114
115
116
117
118
119
120
121
122
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 113

def verify(credit_card, options = {})
  post = {}
  add_integration_key(post)
  add_payment_type(post, options)
  customer_country(post, options)
  post[:card] = payment_details(credit_card)
  post[:device_id] = options[:device_id] if options[:device_id]

  commit(:verify, post, options)
end

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



95
96
97
98
99
100
101
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 95

def void(authorization, options = {})
  post = {}
  add_integration_key(post)
  add_authorization(post, authorization)

  commit(:void, post, options)
end