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::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

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] ||= '0.2.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(identifier, money, options = {}) ⇒ Object



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

def capture(identifier, money, 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(identifier, money, options) ⇒ Object



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

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

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

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

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



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

def store(creditcard, options = {})
  post = {}
  add_payment_source(post, creditcard, options)
  post[:name] = options[:name]
  post[:email] = options[:email]

  path = if options[:customer]
    "customers/#{CGI.escape(options[:customer])}"
  else
    'customers'
  end

  commit(:post, path, post)
end

#unstore(customer_id, options = {}) ⇒ Object



73
74
75
# File 'lib/active_merchant/billing/gateways/conekta.rb', line 73

def unstore(customer_id, options = {})
  commit(:delete, "customers/#{CGI.escape(customer_id)}", nil)
end