solidus_conekta 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +90 -0
  4. data/Rakefile +21 -0
  5. data/app/assets/javascripts/spree/backend/solidus_conekta.js +2 -0
  6. data/app/assets/javascripts/spree/frontend/conekta.js +635 -0
  7. data/app/assets/javascripts/spree/frontend/easyXDM.min.js +25 -0
  8. data/app/assets/javascripts/spree/frontend/printThis.js +146 -0
  9. data/app/assets/javascripts/spree/frontend/solidus_conekta.js.coffee +63 -0
  10. data/app/assets/javascripts/spree/frontend/utils.js.erb +35 -0
  11. data/app/assets/stylesheets/spree/backend/print.css.sass +12 -0
  12. data/app/assets/stylesheets/spree/backend/solidus_conekta.css +3 -0
  13. data/app/assets/stylesheets/spree/frontend/conekta.css.sass +45 -0
  14. data/app/assets/stylesheets/spree/frontend/solidus_conekta.css +4 -0
  15. data/app/controllers/spree/checkout_controller_decorator.rb +30 -0
  16. data/app/controllers/spree/conekta/payments_controller.rb +16 -0
  17. data/app/models/spree/billing_integration/conekta_gateway/bank.rb +30 -0
  18. data/app/models/spree/billing_integration/conekta_gateway/card.rb +35 -0
  19. data/app/models/spree/billing_integration/conekta_gateway/cash.rb +30 -0
  20. data/app/models/spree/billing_integration/conekta_gateway/monthly_payment.rb +35 -0
  21. data/app/models/spree/billing_integration/conekta_gateway.rb +31 -0
  22. data/app/models/spree/conekta_payment.rb +16 -0
  23. data/app/models/spree/credit_card_decorator.rb +8 -0
  24. data/app/models/spree/line_item_decorator.rb +11 -0
  25. data/app/models/spree/order_decorator.rb +19 -0
  26. data/app/models/spree/payment_decorator.rb +18 -0
  27. data/app/models/spree.rb +5 -0
  28. data/app/overrides/add_conekta_scripts_to_the_checkout.rb +4 -0
  29. data/app/views/spree/admin/payments/_banorte.html.erb +32 -0
  30. data/app/views/spree/admin/payments/_oxxo.html.erb +29 -0
  31. data/app/views/spree/admin/payments/_spei.html.erb +30 -0
  32. data/app/views/spree/admin/payments/source_forms/_conekta.html.erb +3 -0
  33. data/app/views/spree/admin/payments/source_forms/_conekta_card.html.erb +3 -0
  34. data/app/views/spree/admin/payments/source_views/_conekta.html.erb +1 -0
  35. data/app/views/spree/admin/payments/source_views/_conekta_card.html.erb +19 -0
  36. data/app/views/spree/checkout/_conekta_scripts.html.erb +17 -0
  37. data/app/views/spree/checkout/existing_payment/_conekta_card.html.erb +9 -0
  38. data/app/views/spree/checkout/payment/_conekta.html.erb +3 -0
  39. data/app/views/spree/checkout/payment/_conekta_card.html.erb +75 -0
  40. data/app/views/spree/conekta/gateway_options.json.jbuilder +34 -0
  41. data/app/views/spree/conekta/payments/_bank.html.erb +0 -0
  42. data/app/views/spree/conekta/payments/_banorte.html.erb +30 -0
  43. data/app/views/spree/conekta/payments/_card.html.erb +0 -0
  44. data/app/views/spree/conekta/payments/_cash.html.erb +0 -0
  45. data/app/views/spree/conekta/payments/_oxxo.html.erb +36 -0
  46. data/app/views/spree/conekta/payments/_spei.html.erb +28 -0
  47. data/app/views/spree/conekta/payments/show.html.erb +25 -0
  48. data/config/locales/en.yml +26 -0
  49. data/config/locales/es-MX.yml +26 -0
  50. data/config/routes.rb +5 -0
  51. data/db/migrate/20130904161251_create_spree_conekta_payments.rb +9 -0
  52. data/db/migrate/20130904172418_rename_type_column_to_conekta_payment.rb +7 -0
  53. data/db/migrate/20140220160614_add_installments_to_spree_credit_card.rb +5 -0
  54. data/db/migrate/20140509145837_add_payment_method_id_to_spree_conekta_payment.rb +6 -0
  55. data/db/migrate/20140509151116_add_user_id_to_spree_conekta_payment.rb +6 -0
  56. data/lib/generators/solidus_conekta/install/install_generator.rb +31 -0
  57. data/lib/solidus_conekta/engine.rb +40 -0
  58. data/lib/solidus_conekta/factories.rb +6 -0
  59. data/lib/solidus_conekta/version.rb +3 -0
  60. data/lib/solidus_conekta.rb +10 -0
  61. data/lib/spree/conekta/client.rb +36 -0
  62. data/lib/spree/conekta/configuration.rb +25 -0
  63. data/lib/spree/conekta/credit_card.rb +42 -0
  64. data/lib/spree/conekta/credit_card_collection.rb +36 -0
  65. data/lib/spree/conekta/customer.rb +39 -0
  66. data/lib/spree/conekta/exchange.rb +30 -0
  67. data/lib/spree/conekta/fake_response.rb +10 -0
  68. data/lib/spree/conekta/monthly_payment_provider.rb +26 -0
  69. data/lib/spree/conekta/payment_notification_handler.rb +36 -0
  70. data/lib/spree/conekta/payment_source/bank.rb +13 -0
  71. data/lib/spree/conekta/payment_source/card.rb +21 -0
  72. data/lib/spree/conekta/payment_source/cash.rb +13 -0
  73. data/lib/spree/conekta/provider.rb +134 -0
  74. data/lib/spree/conekta/response.rb +14 -0
  75. data/lib/tasks/solidus_conekta_tasks.rake +4 -0
  76. metadata +509 -0
@@ -0,0 +1,18 @@
1
+ module Spree
2
+ Payment.class_eval do
3
+ def payment_method_source
4
+ payment_method.options[:source_method]
5
+ end
6
+
7
+ def self.find_by_order_number(order_number)
8
+ Spree::Payment.joins(:order)
9
+ .where(state: 'pending', spree_orders: {
10
+ number: order_number
11
+ }).readonly(false).last
12
+ end
13
+
14
+ def self.capture_by_order_number(order_number)
15
+ Spree::Payment.find_by_order_number(order_number.split('-')[0]).try(:capture!)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ def self.table_name_prefix
3
+ 'spree_'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(virtual_path: 'spree/checkout/_payment',
2
+ name: 'conekta_scripts',
3
+ insert_after: '[data-hook="buttons"]',
4
+ partial: 'spree/checkout/conekta_scripts')
@@ -0,0 +1,32 @@
1
+ <%- @order_details = @order.last_payment_details.params %>
2
+
3
+ <table class='print' id='conekta_banorte'>
4
+ <thead>
5
+ <tr>
6
+ <th class='title' colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
7
+ </tr>
8
+ <tr>
9
+ <th> <%= t('conekta.banorte.service_number') %> </th>
10
+ <th> <%= t('conekta.banorte.reference') %> </th>
11
+ </tr>
12
+ </thead>
13
+ <tfoot>
14
+ <tr>
15
+ <td colspan='2'> <%= raw t('conekta.banorte.payment_message') %> </td>
16
+ </tr>
17
+ </tfoot>
18
+ <tbody>
19
+ <tr>
20
+ <td class='align-center'> <%= @order_details['banorte']['service_number'] %> </td>
21
+ <td class='align-center'> <%= @order_details['banorte']['reference'] %> </td>
22
+ </tr>
23
+ <tr>
24
+ <td class='align-right'> <%= t('conekta.total') %> </td>
25
+ <td class='align-center'><%= money(@order.total) %></td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
29
+
30
+ <a id='pbutton' href='#' class='icon-print' onclick='printDoc("#conekta_banorte")'>
31
+ <%= t('conekta.cash.print_payment_form') %>
32
+ </a>
@@ -0,0 +1,29 @@
1
+ <%- @order_details = @order.last_payment_details.params %>
2
+
3
+ <table class='print' id='conekta_oxxo'>
4
+ <thead>
5
+ <tr>
6
+ <th class='title' colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
7
+ </tr>
8
+ <tr>
9
+ <th> <%= t('conekta.oxxo.bar_code') %> </th>
10
+ </tr>
11
+ </thead>
12
+ <tfoot>
13
+ <tr>
14
+ <td colspan='2'> <%= raw t('conekta.oxxo.payment_message') %> </td>
15
+ </tr>
16
+ </tfoot>
17
+ <tbody>
18
+ <tr>
19
+ <td class='align-center'>
20
+ <%= image_tag(@order_details['oxxo']['barcode_url']) %>
21
+ <div><%= @order_details['oxxo']['barcode'] %></div>
22
+ </td>
23
+ </tr>
24
+ </tbody>
25
+ </table>
26
+
27
+ <a id='pbutton' href='#' class='icon-print' onclick='printDoc("#conekta_oxxo")'>
28
+ <%= t('conekta.oxxo.print_payment_form') %>
29
+ </a>
@@ -0,0 +1,30 @@
1
+ <%- @order_details = @order.last_payment_details.params %>
2
+
3
+ <table class='print' id='conekta_spei'>
4
+ <thead>
5
+ <tr>
6
+ <th class='title' colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
7
+ </tr>
8
+ <tr>
9
+ <th> <%= t('conekta.spei.clabe') %> </th>
10
+ </tr>
11
+ </thead>
12
+ <tfoot>
13
+ <tr>
14
+ <td colspan='2'> <%= raw t('conekta.spei.payment_message') %> </td>
15
+ </tr>
16
+ </tfoot>
17
+ <tbody>
18
+ <tr>
19
+ <td class='align-center'> <%= @order_details['spei']['receiving_account_number'] %> </td>
20
+ </tr>
21
+ <tr>
22
+ <td class='align-right'> <%= t('conekta.total') %> </td>
23
+ <td class='align-center'><%= money(@order.total) %></td>
24
+ </tr>
25
+ </tbody>
26
+ </table>
27
+
28
+ <a id='pbutton' href='#' class='icon-print' onclick='printDoc("#conekta_spei")'>
29
+ <%= t('conekta.cash.print_payment_form') %>
30
+ </a>
@@ -0,0 +1,3 @@
1
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
2
+ <%= hidden_field param_prefix, 'first_name', :value => @order.billing_firstname %>
3
+ <%= hidden_field param_prefix, 'last_name', :value => @order.billing_lastname %>
@@ -0,0 +1,3 @@
1
+ <div>
2
+ <strong>You cannot charge payments with Conekta through the admin backend at this time.</strong>
3
+ </div>
@@ -0,0 +1 @@
1
+ <%= render partial: @order.last_payment_source %>
@@ -0,0 +1,19 @@
1
+ <fieldset data-hook="credit_card">
2
+ <legend align="center"><%= Spree.t(:credit_card) %></legend>
3
+
4
+ <div class="row">
5
+ <div class="alpha six columns">
6
+ <dl>
7
+ <dt><%= Spree.t(:card_type) %>:</dt>
8
+ <dd><%= payment.source.cc_type %></dd>
9
+
10
+ <dt><%= Spree.t(:card_number) %>:</dt>
11
+ <dd><%= payment.source.display_number %></dd>
12
+
13
+ <dt><%= Spree.t(:expiration) %>:</dt>
14
+ <dd><%= payment.source.month %>/<%= payment.source.year %></dd>
15
+ </dl>
16
+ </div>
17
+ </div>
18
+
19
+ </fieldset>
@@ -0,0 +1,17 @@
1
+ <% unless Rails.env.test? %>
2
+ <script type="text/javascript">
3
+ $(function() {
4
+ $('#card_month').on('change', function(e){
5
+ $('#conekta_month').val($(this).val());
6
+ });
7
+
8
+ $('#card_year').on('change', function(e){
9
+ $('#conekta_year').val($(this).val());
10
+ });
11
+
12
+ var gatewayOptions = JSON.parse("<%= escape_javascript render(template: 'spree/conekta/gateway_options.json').html_safe %>");
13
+
14
+ spreeConekta = new Spree.Conekta($('#checkout_form_payment'), gatewayOptions);
15
+ });
16
+ </script>
17
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <tr id="<%= dom_id(wallet_payment_source, 'spree')%>" class="<%= cycle('even', 'odd') %>">
2
+ <td><%= wallet_payment_source.payment_source.name %></td>
3
+ <td><%= wallet_payment_source.payment_source.display_number %></td>
4
+ <td><%= wallet_payment_source.payment_source.month %></td>
5
+ <td><%= wallet_payment_source.payment_source.year %></td>
6
+ <td>
7
+ <%= radio_button_tag "order[wallet_payment_source_id]", wallet_payment_source.id, default, class: "existing-cc-radio" %>
8
+ </td>
9
+ </tr>
@@ -0,0 +1,3 @@
1
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
2
+ <%= hidden_field param_prefix, 'first_name', :value => @order.billing_firstname %>
3
+ <%= hidden_field param_prefix, 'last_name', :value => @order.billing_lastname %>
@@ -0,0 +1,75 @@
1
+ <%= image_tag 'credit_cards/credit_card.gif', :id => 'credit-card-image' %>
2
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
3
+
4
+
5
+ <p class="field">
6
+ <%= label_tag "name_on_card_#{payment_method.id}", Spree.t(:name_on_card) %><span class="required">*</span><br />
7
+ <%= text_field_tag "#{param_prefix}[name]",
8
+ "#{@order.billing_firstname} #{@order.billing_lastname}",
9
+ { id: "name_on_card_#{payment_method.id}",
10
+ data: { conekta: 'card[name]' } } %>
11
+ </p>
12
+
13
+ <p class="field" data-hook="card_number">
14
+ <%= label_tag "card_number", Spree.t(:card_number) %><span class="required">*</span><br />
15
+ <% options_hash = Rails.env.production? ? {autocomplete: 'off'} : {} %>
16
+ <%= text_field_tag "#{param_prefix}[number]",
17
+ '',
18
+ options_hash.merge(:id => 'card_number',
19
+ class: 'required cardNumber',
20
+ size: 19,
21
+ maxlength: 19,
22
+ autocomplete: "off",
23
+ data: { conekta: 'card[number]' }) %>
24
+ &nbsp;
25
+ <span id="card_type" style="display:none;">
26
+ ( <span id="looks_like" ><%= Spree.t(:card_type_is) %> <span id="type"></span></span>
27
+ <span id="unrecognized"><%= Spree.t(:unrecognized_card_type) %></span>
28
+ )
29
+ </span>
30
+ </p>
31
+
32
+ <p class="field" data-hook="card_expiration">
33
+ <%= label_tag "card_month", Spree.t(:expiration) %><span class="required">*</span><br />
34
+ <%= select_month(Date.today,
35
+ { prefix: param_prefix, field_name: 'month', use_month_numbers: true },
36
+ class: 'required',
37
+ id: "card_month",
38
+ data: { conekta: 'card[exp_month]' }) %>
39
+
40
+ <%= select_year(Date.today,
41
+ { prefix: param_prefix, field_name: 'year', start_year: Date.today.year, end_year: Date.today.year + 15 },
42
+ class: 'required',
43
+ id: "card_year",
44
+ data: { conekta: 'card[exp_year]' }) %>
45
+ </p>
46
+
47
+ <p class="field" data-hook="card_code">
48
+ <%= label_tag "card_code", Spree.t(:card_code) %><span class="required">*</span><br />
49
+ <%= text_field_tag "#{param_prefix}[verification_value]",
50
+ '',
51
+ options_hash.merge(id: 'card_code',
52
+ class: 'required cardCode',
53
+ size: 5,
54
+ data: { conekta: 'card[cvc]' } ) %>
55
+ <%= link_to "(#{Spree.t(:what_is_this)})", spree.cvv_path, target: '_blank', "data-hook" => "cvv_link", id: "cvv_link" %>
56
+ </p>
57
+
58
+ <% if payment_method.with_installments? %>
59
+ <p class="field">
60
+ <%= label_tag "installments_number_#{payment_method.id}", t('conekta.installments_number') %>
61
+ <%= select_tag "#{param_prefix}[installments_number]", options_for_select(Spree::Conekta.configuration.installment_options, Spree::Conekta.configuration.installment_default), data: { conekta: 'monthly_installments' } %>
62
+ </p>
63
+ <% end %>
64
+
65
+ <%= hidden_field_tag "conekta_month", Date.today.month, data: { conekta: 'card[exp_month]' } %>
66
+ <%= hidden_field_tag "conekta_year", Date.today.year, data: { conekta: 'card[exp_year]' } %>
67
+
68
+ <%= hidden_field_tag "#{param_prefix}[conekta_response]", '' %>
69
+ <%= hidden_field_tag "#{param_prefix}[gateway_payment_profile_id]", '', :id => "gateway_payment_profile_id" %>
70
+
71
+ <script type="text/javascript">
72
+ $(function() {
73
+ Conekta.setPublishableKey('<%= payment_method.preferred_public_auth_token %>');
74
+ });
75
+ </script>
@@ -0,0 +1,34 @@
1
+ json.description('Spree Order')
2
+ json.amount(@order.display_total.cents)
3
+ json.currency(Spree::Config[:currency])
4
+ json.reference_id(@order.number)
5
+
6
+ json.details do
7
+ json.name(@order.name)
8
+ json.phone(@order.bill_address.phone)
9
+ json.email(@order.email)
10
+
11
+ json.billing_address do
12
+ json.email(@order.email)
13
+ json.street1(@order.bill_address.address1)
14
+ json.street2(@order.bill_address.address2)
15
+ json.city(@order.bill_address.city)
16
+ json.state(@order.bill_address.state)
17
+ json.country(@order.bill_address.country)
18
+ json.zip(@order.bill_address.zipcode)
19
+
20
+ json.line_items(@order.line_items.map(&:to_conekta))
21
+
22
+ json.shipment do
23
+ json.price(@order.shipments.sum(:cost))
24
+ json.address do
25
+ json.street1(@order.ship_address.address1)
26
+ json.street2(@order.ship_address.address2)
27
+ json.city(@order.ship_address.city)
28
+ json.state(@order.ship_address.state)
29
+ json.country(@order.ship_address.country)
30
+ json.zip(@order.ship_address.zipcode)
31
+ end
32
+ end
33
+ end
34
+ end
File without changes
@@ -0,0 +1,30 @@
1
+ <h1><%= t('conekta.banorte.payment_title') %></h1>
2
+
3
+ <table id='conekta_banorte' class='payment-information'>
4
+ <thead>
5
+ <tr>
6
+ <th colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
7
+ </tr>
8
+ <tr>
9
+ <th> <%= t('conekta.banorte.service_number') %> </th>
10
+ <th> <%= t('conekta.banorte.reference') %> </th>
11
+ </tr>
12
+ </thead>
13
+ <tfoot>
14
+ <tr>
15
+ <td colspan='2'> <%= raw t('conekta.banorte.payment_message') %> </td>
16
+ </tr>
17
+ </tfoot>
18
+ <tbody>
19
+ <tr>
20
+ <td class='align-center'> <%= @order_details['payment_method']['service_number'] %> </td>
21
+ <td class='align-center'> <%= @order_details['payment_method']['reference'] %> </td>
22
+ </tr>
23
+ <tr>
24
+ <td class='align-right' colspan='2'>
25
+ <b><%= t('conekta.total') %></b>
26
+ <%= @order.display_total.to_html %>
27
+ </td>
28
+ </tr>
29
+ </tbody>
30
+ </table>
File without changes
File without changes
@@ -0,0 +1,36 @@
1
+ <img class='conekta-oxxo' src='https://s3.amazonaws.com/pagalo/oxxo_logo.png'></img>
2
+ <h1 id='oxxo-title'><%= t("conekta.oxxo.payment_title") %></h1>
3
+
4
+ <table id='conekta_oxxo' class='payment-information'>
5
+ <thead>
6
+ <tr>
7
+ <th colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
8
+ </tr>
9
+ <tr>
10
+ <th colspan='2'> <%= t('conekta.oxxo.bar_code') %> </th>
11
+ </tr>
12
+ </thead>
13
+ <tfoot>
14
+ <tr>
15
+ <td colspan='2'> <%= raw t('conekta.oxxo.payment_message') %> </td>
16
+ </tr>
17
+ </tfoot>
18
+ <tbody>
19
+ <tr>
20
+ <td class='align-center' id='barcode'>
21
+ <%= image_tag(@order_details['payment_method']['barcode_url']) %>
22
+ <div><%= @order_details['payment_method']['barcode'] %></div>
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td class='align-right'>
27
+ <b><%= t('conekta.total') %></b>
28
+ <% if @order.currency != 'MXN' %>
29
+ <%= Spree::Conekta::Exchange.new(@order.total, @order.currency).amount_exchanged %> MXN
30
+ <% else %>
31
+ <%= @order.display_total.to_html%>
32
+ <% end%>
33
+ </td>
34
+ </tr>
35
+ </tbody>
36
+ </table>
@@ -0,0 +1,28 @@
1
+ <h1><%= t('conekta.spei.payment_title') %></h1>
2
+
3
+ <table id='conekta_spei' class='payment-information'>
4
+ <thead>
5
+ <tr>
6
+ <th colspan='2'> <%= t('conekta.order_number', number: @order.number) %> </th>
7
+ </tr>
8
+ <tr>
9
+ <th> <%= t('conekta.spei.clabe') %> </th>
10
+ </tr>
11
+ </thead>
12
+ <tfoot>
13
+ <tr>
14
+ <td colspan='2'> <%= raw t('conekta.spei.payment_message') %> </td>
15
+ </tr>
16
+ </tfoot>
17
+ <tbody>
18
+ <tr>
19
+ <td class='align-center'> <%= @order_details['payment_method']['receiving_account_number'] %> </td>
20
+ </tr>
21
+ <tr>
22
+ <td class='align-right' colspan='2'>
23
+ <b><%= t('conekta.total') %></b>
24
+ <%= @order.display_total.to_html %>
25
+ </td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
@@ -0,0 +1,25 @@
1
+ <section id='order-payment'>
2
+ <header class='order-title'>
3
+ <div class='logos'>
4
+ <img class='conekta-brand' src='https://s3.amazonaws.com/conekta/v5/img/conekta-brand.png' alt='Conekta'></img>
5
+ </div>
6
+
7
+ <h2 class='payment-title'><%= t('conekta.title') %></h2>
8
+ </header>
9
+
10
+ <div class='order-body'>
11
+ <%= render partial: @order.last_payment_source %>
12
+ </div>
13
+
14
+ <footer class='order-footer'>
15
+ <%= button_tag t('conekta.print_payment_form'), id: 'print-payment', class: 'icon-print' %>
16
+ </footer>
17
+ </section>
18
+
19
+ <script type="text/javascript">
20
+ $(document).ready(function() {
21
+ $('#print-payment').click(function(){
22
+ window.print();
23
+ });
24
+ });
25
+ </script>
@@ -0,0 +1,26 @@
1
+ en:
2
+ conekta:
3
+ additional_steps_warning: Additional steps to complete your payment
4
+ card:
5
+ processing_order: Processing order please wait
6
+ oxxo:
7
+ bar_code: Barcode
8
+ next_step: Next step
9
+ payment_message: Print this form and take it to the nearest OXXO to make your payment.
10
+ payment_title: Payment through OXXO
11
+ print_payment_form: Print payment form
12
+ title: Payment information
13
+ total: Total
14
+ banorte:
15
+ payment_title: Banorte deposit
16
+ service_number: Service Number
17
+ reference: Reference
18
+ payment_message: Give this reference number at any Banorte bank.
19
+ spei:
20
+ payment_title: SPEI
21
+ clabe: CLABE
22
+ reference: Reference
23
+ payment_message: Use this CLABE to make a SPEI transfer.
24
+ order_number: 'Order Number: %{number}'
25
+ total: 'Total:'
26
+ installments_number: 'Installments Number'
@@ -0,0 +1,26 @@
1
+ es-MX:
2
+ conekta:
3
+ additional_steps_warning: Pasos adicionales para completar su pago
4
+ card:
5
+ processing_order: Procesando su pago espere un momento
6
+ oxxo:
7
+ bar_code: Código de barras
8
+ payment_message: Imprime este formulario y preséntalo en el Oxxo mas cercano para realizar tu pago.
9
+ payment_title: Pago a través de Oxxo
10
+ total: Total
11
+ banorte:
12
+ payment_title: Depósito en ventanilla Banorte
13
+ service_number: Número de servicio
14
+ reference: Referencia
15
+ payment_message: 'Presente este número de referencia en cualquier sucursal: <strong> Banorte </strong>'
16
+ spei:
17
+ payment_title: SPEI
18
+ clabe: CLABE
19
+ reference: Referencia
20
+ payment_message: Usa esta CLABE para hacer una transferencia SPEI.
21
+ title: Información de pago
22
+ next_step: Siguiente paso
23
+ order_number: 'Número de orden: %{number}'
24
+ print_payment_form: Imprimir ficha de pago
25
+ total: 'Total a pagar:'
26
+ installments_number: 'Meses sin intereses'
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :conekta do
3
+ resources :payments, only: [:create, :show]
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class CreateSpreeConektaPayments < SolidusSupport::Migration[4.2]
2
+ def change
3
+ create_table :spree_conekta_payments do |t|
4
+ t.string :type
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class RenameTypeColumnToConektaPayment < SolidusSupport::Migration[4.2]
2
+ def change
3
+ rename_column :spree_conekta_payments, :type, :payment_type
4
+ add_column :spree_conekta_payments, :first_name, :string
5
+ add_column :spree_conekta_payments, :last_name, :string
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class AddInstallmentsToSpreeCreditCard < SolidusSupport::Migration[4.2]
2
+ def change
3
+ add_column :spree_credit_cards, :installments_number, :integer
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddPaymentMethodIdToSpreeConektaPayment < SolidusSupport::Migration[4.2]
2
+ def change
3
+ add_column :spree_conekta_payments, :payment_method_id, :integer
4
+ add_index :spree_conekta_payments, :payment_method_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddUserIdToSpreeConektaPayment < SolidusSupport::Migration[4.2]
2
+ def change
3
+ add_column :spree_conekta_payments, :user_id, :integer
4
+ add_index :spree_conekta_payments, :user_id
5
+ end
6
+ end
@@ -0,0 +1,31 @@
1
+ module SolidusConekta
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, type: :boolean, default: false
6
+
7
+ def add_javascripts
8
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "\n//= require spree/frontend/solidus_conekta\n"
9
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "\n//= require spree/backend/solidus_conekta\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', "\n *= require spree/frontend/solidus_conekta\n", before: /\*\//, verbose: true
14
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', "\n *= require spree/backend/solidus_conekta\n", before: /\*\//, verbose: true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=solidus_conekta'
19
+ end
20
+
21
+ def run_migrations
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
23
+ if run_migrations
24
+ run 'bundle exec rake db:migrate'
25
+ else
26
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ module SolidusConekta
2
+ class Engine < ::Rails::Engine
3
+ require 'spree'
4
+
5
+ engine_name 'solidus_conekta'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ if Rails.version >= '3.1'
15
+ initializer :assets do |config|
16
+ Rails.application.config.assets.precompile += %w( solidus_conekta.js )
17
+ end
18
+ end
19
+
20
+ def self.activate
21
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
22
+ Rails.env.production? ? require(c) : load(c)
23
+ end
24
+ end
25
+
26
+ initializer "spree.gateway.payment_methods", after: "spree.register.payment_methods" do |app|
27
+ app.config.spree.payment_methods << Spree::BillingIntegration::ConektaGateway
28
+ app.config.spree.payment_methods << Spree::BillingIntegration::ConektaGateway::Cash
29
+ app.config.spree.payment_methods << Spree::BillingIntegration::ConektaGateway::Card
30
+ app.config.spree.payment_methods << Spree::BillingIntegration::ConektaGateway::Bank
31
+ app.config.spree.payment_methods << Spree::BillingIntegration::ConektaGateway::MonthlyPayment
32
+ end
33
+
34
+ initializer 'solidus_conekta.assets.precompile' do |app|
35
+ app.config.assets.precompile += %w( spree/backend/print.css )
36
+ end
37
+
38
+ config.to_prepare &method(:activate).to_proc
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'solidus_conekta/factories'
6
+ end
@@ -0,0 +1,3 @@
1
+ module SolidusConekta
2
+ VERSION = '1.1'
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'solidus_core'
2
+ require 'solidus_backend'
3
+ require 'solidus_frontend'
4
+ require 'solidus_support'
5
+ require 'nokogiri'
6
+ require 'typhoeus/adapters/faraday'
7
+ require 'faraday'
8
+ require 'faraday_middleware'
9
+ require 'solidus_conekta/engine'
10
+ require 'spree/conekta/configuration'