solidus_oxxo_pay 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/app/controllers/spree/conekta_oxxo_controller.rb +2 -0
- data/app/helpers/spree/base_helper_decorator.rb +8 -4
- data/app/models/spree/conekta_oxxo_payment.rb +48 -34
- data/app/models/spree/payment_method/conekta_oxxo.rb +2 -0
- data/app/policies/payment_oxxo_policy.rb +3 -1
- data/app/views/spree/api/source_views/_conektaoxxo.json.jbuilder +1 -0
- data/app/views/spree/conekta/payments/_conekta_oxxo.html.erb +17 -13
- data/app/views/spree/conekta_oxxo/receipt.html.erb +2 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20181121200357_create_conekta_oxxo_payments.rb +2 -0
- data/lib/generators/solidus_oxxo_pay/install/install_generator.rb +2 -0
- data/lib/solidus_oxxo_pay.rb +2 -0
- data/lib/solidus_oxxo_pay/engine.rb +5 -1
- data/lib/solidus_oxxo_pay/factories.rb +2 -0
- data/lib/solidus_oxxo_pay/version.rb +3 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948805a97162f094d5c1fd6582e17be907b2c72b238822e3305020dec9054afd
|
4
|
+
data.tar.gz: 296dbdbe258a176534c35bca3dc04b6455d6b6b767babb5ef849c955909a1175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb074c36374c87dca424bb320f4a4de8ac7c39810cc342056c0fc8c96860a36396d4b173a7b94acd65e8ff60ec56cef45ec069055c89faa1fe54f6654e6c484
|
7
|
+
data.tar.gz: 3a979d9916105c36d2fd3b665374ebe7507ca2b71687a697326aeccabe3a5ed42a5e98896247a62cf02203b9a95aa7b1b30b672b25f33553c83a93c8fa5f467d
|
data/Rakefile
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spree::BaseHelper
|
2
4
|
def conekta_oxxo_receipt(order = nil)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
order_oxxo_payments = order&.payments&.
|
6
|
+
where(source_type: 'Spree::ConektaOxxoPayment')
|
7
|
+
if order_oxxo_payments.any?
|
8
|
+
response_code = order_oxxo_payments.last&.response_code
|
9
|
+
render partial: 'spree/conekta/payments/conekta_oxxo',
|
10
|
+
locals: { order: order, response_code: response_code }
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
@@ -1,20 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spree
|
2
4
|
class ConektaOxxoPayment < Spree::PaymentSource
|
3
5
|
attr_accessor :server, :test_mode, :api_key
|
4
6
|
|
5
|
-
def authorize(
|
6
|
-
|
7
|
-
|
8
|
-
::Conekta.api_version = "2.0.0"
|
7
|
+
def authorize(_money, source, _gateway_options)
|
8
|
+
Conekta.api_key = api_key
|
9
|
+
Conekta.api_version = '2.0.0'
|
9
10
|
|
10
|
-
order = Spree::Order.find_by(number:
|
11
|
+
order = Spree::Order.find_by(number: source.number)
|
11
12
|
|
12
13
|
begin
|
13
|
-
response =
|
14
|
-
|
14
|
+
response = Conekta::Order.create(payload(order))
|
15
|
+
source.update_attribute :conekta_order_id, response.id
|
15
16
|
ActiveMerchant::Billing::Response.new(true, 'Orden creada satisfactoriamente', {}, parse_response(response))
|
16
|
-
rescue ::Conekta::Error =>
|
17
|
-
ActiveMerchant::Billing::Response.new(false,
|
17
|
+
rescue ::Conekta::Error => e
|
18
|
+
ActiveMerchant::Billing::Response.new(false, e.details.map(&:message).join(', '))
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -51,46 +52,59 @@ module Spree
|
|
51
52
|
end
|
52
53
|
|
53
54
|
private
|
55
|
+
|
54
56
|
def payload(order)
|
55
57
|
{
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
],
|
69
|
-
line_items: order_line_items(order),
|
70
|
-
shipping_lines: shipping_lines(order),
|
71
|
-
shipping_contact: {
|
72
|
-
address: {
|
73
|
-
street1: order.ship_address.address1,
|
74
|
-
postal_code: order.ship_address.zipcode,
|
75
|
-
country: 'mx'
|
76
|
-
}
|
58
|
+
currency: 'MXN',
|
59
|
+
customer_info: {
|
60
|
+
name: order.ship_address.full_name,
|
61
|
+
email: order.email,
|
62
|
+
phone: order.ship_address.phone
|
63
|
+
},
|
64
|
+
charges: [
|
65
|
+
{
|
66
|
+
payment_method: {
|
67
|
+
type: 'oxxo_cash'
|
68
|
+
}
|
77
69
|
}
|
70
|
+
],
|
71
|
+
line_items: order_line_items(order),
|
72
|
+
shipping_lines: shipping_lines(order),
|
73
|
+
shipping_contact: {
|
74
|
+
address: {
|
75
|
+
street1: order.ship_address.address1,
|
76
|
+
postal_code: order.ship_address.zipcode,
|
77
|
+
country: 'MX'
|
78
|
+
}
|
79
|
+
}
|
78
80
|
}
|
79
81
|
end
|
80
82
|
|
81
83
|
def order_line_items(order)
|
82
|
-
order.line_items.map
|
84
|
+
order.line_items.map do |li|
|
85
|
+
{
|
86
|
+
name: li.product.name,
|
87
|
+
unit_price: (li.price * 100).to_i,
|
88
|
+
quantity: li.quantity
|
89
|
+
}
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
def parse_response(response)
|
86
94
|
{
|
87
|
-
|
88
|
-
|
95
|
+
authorization: response.charges.first.payment_method.reference,
|
96
|
+
conekta_order_id: response.id
|
89
97
|
}
|
90
98
|
end
|
91
99
|
|
92
100
|
def shipping_lines(order)
|
93
|
-
order.shipments.map
|
101
|
+
order.shipments.map do |s|
|
102
|
+
{
|
103
|
+
id: s.id,
|
104
|
+
carrier: s.shipping_method.name,
|
105
|
+
amount: (s.cost * 100).to_i
|
106
|
+
}
|
107
|
+
end
|
94
108
|
end
|
95
109
|
end
|
96
110
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class PaymentOxxoPolicy
|
2
4
|
attr_reader :payment
|
3
5
|
|
@@ -8,7 +10,7 @@ class PaymentOxxoPolicy
|
|
8
10
|
def process(options)
|
9
11
|
return unless options[:status].eql?('paid')
|
10
12
|
|
11
|
-
payment.complete if (options[:amount].to_i/100 - payment.amount).abs < 0.01
|
13
|
+
payment.complete if (options[:amount].to_i / 100 - payment.amount).abs < 0.01
|
12
14
|
payment.order.updater.update
|
13
15
|
end
|
14
16
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# frozen_string_literal: true
|
@@ -1,29 +1,33 @@
|
|
1
|
-
<div class=
|
2
|
-
<div class=
|
3
|
-
<div class=
|
4
|
-
<div class=
|
1
|
+
<div class='opps'>
|
2
|
+
<div class='opps-header'>
|
3
|
+
<div class='opps-info'>
|
4
|
+
<div class='opps-brand'>
|
5
5
|
<%= image_tag 'oxxopay_brand.png', alt: 'OXXOPay', class: 'summary-oxxo-image' %>
|
6
6
|
</div>
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
<div class='opps-ammount'>
|
9
|
+
<h3 class='opps-title'>Monto a pagar</h3>
|
9
10
|
<h2><%= order.display_total %> <sup>MXN</sup></h2>
|
10
11
|
<p>OXXO cobrará una comisión adicional al momento de realizar el pago.</p>
|
11
12
|
</div>
|
12
13
|
</div>
|
13
|
-
|
14
|
-
|
15
|
-
<
|
14
|
+
|
15
|
+
<div class='opps-reference'>
|
16
|
+
<h3 class='opps-reference-title'>Referencia</h3>
|
17
|
+
<h1 class='opps-reference'><%= response_code&.scan(/.{1,4}/)&.join('-') %></h1>
|
16
18
|
</div>
|
17
19
|
</div>
|
18
|
-
|
20
|
+
|
21
|
+
<div class='opps-instructions'>
|
19
22
|
<h3>Instrucciones</h3>
|
20
|
-
|
21
|
-
|
23
|
+
|
24
|
+
<ol class='steps-list'>
|
25
|
+
<li>Acude a la tienda OXXO más cercana. <a href='https://www.google.com.mx/maps/search/oxxo/' target='_blank'>Encuéntrala aquí</a>.</li>
|
22
26
|
<li>Indica en caja que quieres realizar un pago de <strong>OXXOPay</strong>.</li>
|
23
27
|
<li>Dicta al cajero el número de referencia en esta ficha para que tecleé directamete en la pantalla de venta.</li>
|
24
28
|
<li>Realiza el pago correspondiente con dinero en efectivo.</li>
|
25
29
|
<li>Al confirmar tu pago, el cajero te entregará un comprobante impreso. <strong>En el podrás verificar que se haya realizado correctamente.</strong> Conserva este comprobante de pago.</li>
|
26
30
|
</ol>
|
27
|
-
<div class=
|
31
|
+
<div class='opps-footnote'>Al completar estos pasos recibirás un correo confirmando tu pago.</div>
|
28
32
|
</div>
|
29
33
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
|
-
<%= stylesheet_link_tag '
|
3
|
+
<%= stylesheet_link_tag 'spree/frontend/solidus_oxxo_pay', media: 'all', 'data-turbolinks-track': 'false' %>
|
4
4
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">
|
5
5
|
</head>
|
6
6
|
<body>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
</body>
|
9
9
|
<script type="text/javascript" charset="utf-8">
|
10
10
|
document.addEventListener('DOMContentLoaded', function () {
|
11
|
-
|
11
|
+
window.print();
|
12
12
|
});
|
13
13
|
</script>
|
14
14
|
</html>
|
data/config/routes.rb
CHANGED
data/lib/solidus_oxxo_pay.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SolidusOxxoPay
|
2
4
|
class Engine < Rails::Engine
|
3
5
|
require 'spree/core'
|
4
6
|
isolate_namespace Spree
|
5
7
|
engine_name 'solidus_oxxo_pay'
|
6
8
|
|
9
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
10
|
+
|
7
11
|
# use rspec for tests
|
8
12
|
config.generators do |g|
|
9
13
|
g.test_framework :rspec
|
@@ -11,7 +15,7 @@ module SolidusOxxoPay
|
|
11
15
|
|
12
16
|
initializer 'spree_payment_network.register.payment_methods' do |app|
|
13
17
|
app.config.spree.payment_methods << Spree::PaymentMethod::ConektaOxxo
|
14
|
-
app.config.assets.precompile += %w(
|
18
|
+
app.config.assets.precompile += %w(oxxopay_brand.png)
|
15
19
|
end
|
16
20
|
|
17
21
|
def self.activate
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_oxxo_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magmalabs
|
@@ -48,16 +48,16 @@ dependencies:
|
|
48
48
|
name: deface
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '0'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: conekta
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- app/policies/payment_oxxo_policy.rb
|
276
276
|
- app/views/spree/admin/payments/source_forms/_conektaoxxo.html.erb
|
277
277
|
- app/views/spree/admin/payments/source_views/_conektaoxxo.html.erb
|
278
|
+
- app/views/spree/api/source_views/_conektaoxxo.json.jbuilder
|
278
279
|
- app/views/spree/checkout/payment/_conektaoxxo.html.erb
|
279
280
|
- app/views/spree/checkout/payment_label/_conektaoxxo_label.html.erb
|
280
281
|
- app/views/spree/conekta/payments/_conekta_oxxo.html.erb
|