Class: ActiveMerchant::Billing::EbanxGateway

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

Constant Summary collapse

CARD_BRAND =
{
  visa: 'visa',
  master: 'master_card',
  american_express: 'amex',
  discover: 'discover',
  diners_club: 'diners'
}
URL_MAP =
{
  purchase: 'direct',
  authorize: 'direct',
  capture: 'capture',
  refund: 'refund',
  void: 'cancel',
  store: 'token'
}
HTTP_METHOD =
{
  purchase: :post,
  authorize: :post,
  capture: :get,
  refund: :post,
  void: :get,
  store: :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

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

Returns a new instance of EbanxGateway.



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

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

Instance Method Details

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



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

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)
  add_address(post, options)
  add_customer_responsible_person(post, payment, options)
  post[:payment][:creditcard][:auto_capture] = false

  commit(:authorize, post)
end

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



72
73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 72

def capture(money, authorization, options={})
  post = {}
  add_integration_key(post)
  post[:hash] = authorization
  post[:amount] = amount(money)

  commit(:capture, post)
end

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



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

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)
  add_address(post, options)
  add_customer_responsible_person(post, payment, options)

  commit(:purchase, post)
end

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



81
82
83
84
85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 81

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)
end

#scrub(transcript) ⇒ Object



120
121
122
123
124
125
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 120

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

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



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

def store(credit_card, options={})
  post = {}
  add_integration_key(post)
  add_payment_details(post, credit_card)
  post[:country] = customer_country(options)

  commit(:store, post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 116

def supports_scrubbing?
  true
end

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



109
110
111
112
113
114
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 109

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



92
93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/ebanx.rb', line 92

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

  commit(:void, post)
end