spree_mollie_gateway 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b16e49392bd3a160b2d95e61bea9144eb0a0dbe6ae90fd1c0538a5c0044fbb2a
4
- data.tar.gz: 06a98f8d219b1ac08234e7a47f2b573fd6a36de87007014d6f597532e3aabfd5
3
+ metadata.gz: 785a4f3e96e91da89386b6e7f12d9916303c00dcfb4acc8e0e6cdefefc184274
4
+ data.tar.gz: 9cb65667775353fb1ab80197c1163f7a9c7ed6611602ec42d8ec51c043cb894e
5
5
  SHA512:
6
- metadata.gz: b2966a823fec59efdaa8286329e4df43b25a414e51f7b8b38098b4402880c9fd77088056924e1f668e722f7f335ecf06abd32d9e38d8c6f2859a0c523df156fd
7
- data.tar.gz: 1b946e26dc6053ac1a8a9662fbfe3cdcc16f189e90fa34f1fb0c7c124400ec7912e052dd8b3696d0d6760892a7867a01a14172d7697e8e1cb82879d169b527ad
6
+ metadata.gz: bed74ed98aab91919c41988214901c60b87c990c1a099d9ba5e7df47cfc7204f5567de1ecf0c6630681a13065f9b4915f22eece38e8122d364748a3c0ca9094c
7
+ data.tar.gz: e5ec9096cb268de67b1b61f90e1b6ba9ac56b721a84ce478955c878b819571dfd77a7afebe45a34640807076468740d7cefd5a0cd86a644f949d31608ef9f621
data/.gitignore CHANGED
@@ -14,3 +14,5 @@ Gemfile.lock
14
14
  *.gem
15
15
  spec/dummy
16
16
  .bundle/
17
+
18
+ gemfiles/*.lock
@@ -87,8 +87,40 @@ module Spree
87
87
  end
88
88
 
89
89
  # Create a new Mollie refund
90
- def credit(_credit_cents, _payment_id, _options)
91
- ActiveMerchant::Billing::Response.new(false, 'Refunding Mollie orders is not yet supported in Spree. Please refund your order via Mollie Dashboard')
90
+ def credit(credit_cents, payment_id, options)
91
+ order = options[:originator].try(:payment).try(:order)
92
+ payment = options[:originator].try(:payment)
93
+ reimbursement = options[:originator].try(:reimbursement)
94
+ order_number = order.try(:number)
95
+ order_currency = order.try(:currency)
96
+ MollieLogger.debug("Starting refund for order #{order_number}")
97
+
98
+ begin
99
+ if reimbursement
100
+ mollie_order = ::Mollie::Order.get(payment.source.payment_id, {api_key: get_preference(:api_key)})
101
+ mollie_order_refund_lines = reimbursement.return_items.map do |ri|
102
+ line = mollie_order.lines.detect {|line| line.sku == ri.inventory_unit.line_item.mollie_identifier}
103
+ {id: line.id, quantity: ri.inventory_unit.line_item.quantity} if line
104
+ end.compact
105
+ mollie_order.refund!({lines: mollie_order_refund_lines, api_key: get_preference(:api_key)})
106
+ else
107
+ ::Mollie::Payment::Refund.create(
108
+ payment_id: payment_id,
109
+ amount: {
110
+ value: format_money(::Spree::Money.new(credit_cents / 100.0).money),
111
+ currency: order_currency
112
+ },
113
+ description: "Refund Spree Order ID: #{order_number}",
114
+ api_key: get_preference(:api_key)
115
+ )
116
+ end
117
+
118
+ MollieLogger.debug("Successfully refunded #{order.display_total} for order #{order_number}")
119
+ ActiveMerchant::Billing::Response.new(true, 'Refund successful')
120
+ rescue ::Mollie::Exception => e
121
+ MollieLogger.debug("Refund failed for order #{order_number}: #{e.message}")
122
+ ActiveMerchant::Billing::Response.new(false, 'Refund unsuccessful')
123
+ end
92
124
  end
93
125
 
94
126
  def authorize(*_args)
@@ -2,11 +2,15 @@ Spree::LineItem.class_eval do
2
2
  money_methods :discount_amount, :vat_amount
3
3
 
4
4
  def discount_amount
5
- adjustments.non_tax.sum(:amount).abs
5
+ adjustments.eligible.non_tax.sum(:amount).abs
6
6
  end
7
7
 
8
8
  def vat_amount
9
- adjustments.tax.sum(:amount).abs
9
+ adjustments.eligible.tax.sum(:amount).abs
10
+ end
11
+
12
+ def mollie_identifier
13
+ "#{id}-#{variant.sku}"
10
14
  end
11
15
 
12
16
  def vat_rate
@@ -193,7 +193,7 @@ module Spree
193
193
  value: format_money(line.display_vat_amount.money)
194
194
  },
195
195
  vatRate: line.vat_rate * 100,
196
- sku: "#{line.id}-#{line.variant.sku}"
196
+ sku: line.mollie_identifier
197
197
  }
198
198
  end
199
199
  end
@@ -49,6 +49,10 @@ module Spree
49
49
  'Klarna Slice it'
50
50
  when ::Mollie::Method::KLARNAPAYLATER then
51
51
  'Klarna Pay Later'
52
+ when ::Mollie::Method::PRZELEWY24 then
53
+ 'Przelewy24'
54
+ when ::Mollie::Method::APPLEPAY then
55
+ 'Apple Pay'
52
56
  # As of May 1st 2019, Bitcoin is no longer supported.
53
57
  when 'bitcoin' then
54
58
  'Bitcoin'
@@ -9,7 +9,14 @@
9
9
  <%= method.description %>
10
10
  </label>
11
11
 
12
- <%= select_tag "#{prefix}[issuer]", options_for_select(method.issuers.collect {|p| [p['name'], p['id']]}), {class: 'form-control js-mollie-issuers mollie-issuer-list', disabled: true, prompt: 'Select an issuer', data: {method: method.id}} if method.issuers.present? %>
12
+ <%= select_tag "#{prefix}[issuer]",
13
+ options_for_select(method.issuers.collect {|p| [p['name'], p['id']]}),
14
+ {
15
+ class: 'form-control js-mollie-issuers mollie-issuer-list',
16
+ disabled: true,
17
+ prompt: t('mollie-gateway.issuers.select'),
18
+ data: {method: method.id}
19
+ } if method.issuers.present? %>
13
20
  </div>
14
21
  <% end %>
15
22
  </ul>
@@ -0,0 +1,4 @@
1
+ de:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Wählen Sie einen Bearbeiter
@@ -0,0 +1,4 @@
1
+ en:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Select an issuer
@@ -0,0 +1,4 @@
1
+ es:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Seleccione un emisor
@@ -0,0 +1,4 @@
1
+ fr:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Sélectionner un émetteur
@@ -0,0 +1,4 @@
1
+ it:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Seleziona una Banca
@@ -0,0 +1,4 @@
1
+ nl:
2
+ mollie-gateway:
3
+ issuers:
4
+ select: Selecteer uw bank
@@ -1,3 +1,3 @@
1
1
  module SpreeMollieGateway
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_mollie_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vernon de Goede
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_backend
@@ -356,6 +356,12 @@ files:
356
356
  - app/views/spree/shared/_payment.html.erb
357
357
  - bin/console
358
358
  - bin/setup
359
+ - config/locales/de.yml
360
+ - config/locales/en.yml
361
+ - config/locales/es.yml
362
+ - config/locales/fr.yml
363
+ - config/locales/it.yml
364
+ - config/locales/nl.yml
359
365
  - config/routes.rb
360
366
  - db/migrate/20180214133044_create_spree_mollie_payment_sources.rb
361
367
  - db/migrate/20180301084841_add_mollie_customer_id_to_spree_user.rb
@@ -393,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
399
  - !ruby/object:Gem::Version
394
400
  version: '0'
395
401
  requirements: []
396
- rubygems_version: 3.0.3
402
+ rubygems_version: 3.0.4
397
403
  signing_key:
398
404
  specification_version: 4
399
405
  summary: Mollie payments for Spree Commerce.