solidus_nexio 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61f3fcbac26957d33c4b2ee7180cd2281321eab0f24830fcfc8d6fb5efc60c6e
4
- data.tar.gz: 10f8e6f1442cb03b3a3df79d6e19ac9ede054c802d8c7836371c6dc65966816a
3
+ metadata.gz: 2d42e6c9bd11c430df53a34790fb27135858dfe7778993d92ac498852c4c644c
4
+ data.tar.gz: 42f80e061a67fe362189b09574a088c00dca9a9c955d2b81d60185642a8604cb
5
5
  SHA512:
6
- metadata.gz: 94b0ba895640b8d7d490968a5e8a40a172a178a091c22cb8c6bc9f295fe90c39541d717e9ba1eeb011bafac195b3926e47bda6ae2cb4f67f3852421e157110d4
7
- data.tar.gz: b2aa9cea065f1f41cbc24672bf80af58b6f300e6b59bc33f1f489d3e8909693b444c48f17465ae3a82b029b8ab7b8793f6e09a280a2aed86d047a757d1dc67d8
6
+ metadata.gz: a5f82c368b378841a8e8e5fe9aa7471a53ad6d09d79ba34a6a76441fccfb0286ef3581b449da21db5bcb3756e54744c810706fa18e56774cf1ade446be4a6213
7
+ data.tar.gz: 3c9c578fc6846c9add3f4e8d68c063fa2fa57eec71a362f3d5c1e0d343572c9adb3b59d07a6d6c6d19972af09dd5a95b83484ef48872a57172df3306751846b7
@@ -18,6 +18,14 @@ module SolidusNexio
18
18
  gateway.generate_token(options)
19
19
  end
20
20
 
21
+ def purchase(money, payment, options = {})
22
+ super(money, payment, add_transaction_options(options))
23
+ end
24
+
25
+ def authorize(money, payment, options = {})
26
+ super(money, payment, add_transaction_options(options))
27
+ end
28
+
21
29
  def store(options)
22
30
  card_attrs = options[:card]
23
31
  .slice(:encrypted_number, :number, :name, :month, :year)
@@ -37,5 +45,13 @@ module SolidusNexio
37
45
  def gateway_class
38
46
  ActiveMerchant::Billing::NexioGateway
39
47
  end
48
+
49
+ def add_transaction_options(options)
50
+ result = options.slice(:currency, :billing_address, :shipping_address)
51
+ if options[:originator].is_a?(::Spree::Payment) && options[:originator].order
52
+ result.merge!(SolidusNexio::NexioData.purchase(options[:originator].order))
53
+ end
54
+ result
55
+ end
40
56
  end
41
57
  end
@@ -20,6 +20,14 @@ module SolidusNexio
20
20
  acc
21
21
  end
22
22
 
23
+ def purchase(order)
24
+ acc = { customer: {} }
25
+ add_order_data(acc, order)
26
+ add_order_cart(acc, order)
27
+ add_customer_data(acc, order)
28
+ acc
29
+ end
30
+
23
31
  private
24
32
 
25
33
  def add_order_data(acc, order)
@@ -53,6 +61,10 @@ module SolidusNexio
53
61
  }
54
62
  end
55
63
 
64
+ def add_order_cart(acc, order)
65
+ acc[:order][:line_items] = order.line_items.map { |line_item| line_item_data(line_item) }
66
+ end
67
+
56
68
  def line_item_data(line_item)
57
69
  {
58
70
  id: line_item.id,
@@ -64,8 +76,8 @@ module SolidusNexio
64
76
 
65
77
  if SolidusSupport.combined_first_and_last_name_in_address?
66
78
  def address_to_name(address)
67
- parts = address.name.split(' ')
68
- { first_name: parts[0], last_name: parts[1..-1].join(' ') }
79
+ name = Spree::Address::Name.new(address.name)
80
+ { first_name: name.first_name, last_name: name.last_name }
69
81
  end
70
82
  else
71
83
  def address_to_name(address)
@@ -0,0 +1,11 @@
1
+ <% id = payment_method.id %>
2
+
3
+ <fieldset class="no-border-bottom" data-payment-method-id="<%= id %>">
4
+ <div class="field" data-hook="previous_cards">
5
+ <% if previous_cards.any? %>
6
+ <% previous_cards.each do |card| %>
7
+ <label><%= radio_button_tag :card, card.id, card == previous_cards.first %> <%= card.display_number %><br /></label>
8
+ <% end %>
9
+ <% end %>
10
+ </div>
11
+ </fieldset>
@@ -0,0 +1,23 @@
1
+ <fieldset data-hook="credit_card">
2
+ <legend align="center"><%= payment.payment_method.name %></legend>
3
+
4
+ <div class="row">
5
+ <div class="alpha six columns">
6
+ <dl>
7
+ <dt><%= I18n.t("spree.identifier") %>:</dt>
8
+ <dd><%= payment.number %></dd>
9
+
10
+ <% if payment.source.is_a?(Spree::CreditCard) %>
11
+ <dt><%= Spree::CreditCard.human_attribute_name(:cc_type) %>:</dt>
12
+ <dd><%= payment.source.cc_type %></dd>
13
+
14
+ <dt><%= Spree::CreditCard.human_attribute_name(:name) %>:</dt>
15
+ <dd><%= payment.source.name %></dd>
16
+
17
+ <dt><%= Spree::CreditCard.human_attribute_name(:last_digits) %>:</dt>
18
+ <dd><%= payment.source.last_digits %></dd>
19
+ <% end %>
20
+ </dl>
21
+ </div>
22
+ </div>
23
+ </fieldset>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusNexio
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = SolidusNexio::VERSION
8
8
  spec.authors = %w[Whitespectre]
9
9
  spec.email = %w[hello@whitespectre.com]
10
+ spec.licenses = %w[MIT]
10
11
 
11
12
  spec.summary = 'Solidus integration with Nexio'
12
13
  spec.homepage = 'https://github.com/jalkoby/solidus_nexio'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_nexio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Whitespectre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,6 +101,7 @@ files:
101
101
  - app/models/solidus_nexio/payment_method.rb
102
102
  - app/services/solidus_nexio/nexio_data.rb
103
103
  - app/views/spree/admin/payments/source_forms/_nexio_own_form.html.erb
104
+ - app/views/spree/admin/payments/source_views/_nexio_own_form.html.erb
104
105
  - app/views/spree/checkout/existing_payment/_nexio_own_form.html.erb
105
106
  - app/views/spree/checkout/payment/_nexio_own_form.html.erb
106
107
  - app/views/spree/shared/_nexio_own_form.html.erb
@@ -112,7 +113,8 @@ files:
112
113
  - lib/tasks/solidus_nexio_tasks.rake
113
114
  - solidus_nexio.gemspec
114
115
  homepage: https://github.com/jalkoby/solidus_nexio
115
- licenses: []
116
+ licenses:
117
+ - MIT
116
118
  metadata:
117
119
  homepage_uri: https://github.com/jalkoby/solidus_nexio
118
120
  source_code_uri: https://github.com/jalkoby/solidus_nexio