Class: ActiveMerchant::Billing::ConektaGateway

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

Constant Summary

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

Returns a new instance of ConektaGateway


13
14
15
16
17
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 13

def initialize(options = {})
  requires!(options, :key)
  options[:version] ||= '1.0.0'
  super
end

Instance Method Details

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


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

def authorize(money, payment_source, options = {})
  post = {}

  add_order(post, money, options)
  add_payment_source(post, payment_source, options)
  add_details_data(post, options)

  post[:capture] = false
  commit(:post, "charges", post)
end

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


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

def capture(money, identifier, options = {})
  post = {}

  post[:order_id] = identifier
  add_order(post, money, options)

  commit(:post, "charges/#{identifier}/capture", post)
end

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


19
20
21
22
23
24
25
26
27
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 19

def purchase(money, payment_source, options = {})
  post = {}

  add_order(post, money, options)
  add_payment_source(post, payment_source, options)
  add_details_data(post, options)

  commit(:post, 'charges', post)
end

#refund(money, identifier, options) ⇒ Object


49
50
51
52
53
54
55
56
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 49

def refund(money, identifier, options)
  post = {}

  post[:order_id] = identifier
  add_order(post, money, options)

  commit(:post, "charges/#{identifier}/refund", post)
end

#scrub(transcript) ⇒ Object


67
68
69
70
71
72
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 67

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((&?card%5Bnumber%5D=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?card%5Bcvc%5D=)[^&]*)i, '\1[FILTERED]')
end

#supports_scrubbingObject


63
64
65
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 63

def supports_scrubbing
  true
end

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


58
59
60
61
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 58

def void(identifier, options = {})
  post = {}
  commit(:post, "charges/#{identifier}/void", post)
end