Class: Spree::ConektaOxxoPayment

Inherits:
PaymentSource
  • Object
show all
Defined in:
app/models/spree/conekta_oxxo_payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'app/models/spree/conekta_oxxo_payment.rb', line 5

def api_key
  @api_key
end

#serverObject

Returns the value of attribute server.



5
6
7
# File 'app/models/spree/conekta_oxxo_payment.rb', line 5

def server
  @server
end

#test_modeObject

Returns the value of attribute test_mode.



5
6
7
# File 'app/models/spree/conekta_oxxo_payment.rb', line 5

def test_mode
  @test_mode
end

Instance Method Details

#actionsObject



42
43
44
# File 'app/models/spree/conekta_oxxo_payment.rb', line 42

def actions
  %w(void)
end

#authorize(_money, source, _gateway_options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/spree/conekta_oxxo_payment.rb', line 7

def authorize(_money, source, _gateway_options)
  Conekta.api_key = api_key
  Conekta.api_version = '2.0.0'

  order = Spree::Order.find_by(number: source.number)

  begin
    response = Conekta::Order.create(payload(order))
    source.update_attribute :conekta_order_id, response.id
    ActiveMerchant::Billing::Response.new(true, 'Orden creada satisfactoriamente', {}, parse_response(response))
  rescue ::Conekta::Error => e
    ActiveMerchant::Billing::Response.new(false, e.details.map(&:message).join(', '))
  end
end

#cc_typeObject



34
35
36
# File 'app/models/spree/conekta_oxxo_payment.rb', line 34

def cc_type
  'N/A'
end

#gateway_customer_profile_idObject



46
47
48
# File 'app/models/spree/conekta_oxxo_payment.rb', line 46

def gateway_customer_profile_id
  user_id
end

#gateway_payment_profile_idObject



50
51
52
# File 'app/models/spree/conekta_oxxo_payment.rb', line 50

def gateway_payment_profile_id
  id
end

#last_digitsObject



38
39
40
# File 'app/models/spree/conekta_oxxo_payment.rb', line 38

def last_digits
  'N/A'
end

#monthObject



26
27
28
# File 'app/models/spree/conekta_oxxo_payment.rb', line 26

def month
  payment_method.updated_at.month
end

#nameObject



22
23
24
# File 'app/models/spree/conekta_oxxo_payment.rb', line 22

def name
  'Oxxo Pay'
end

#yearObject



30
31
32
# File 'app/models/spree/conekta_oxxo_payment.rb', line 30

def year
  payment_method.updated_at.year
end