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 +4 -4
- data/.gitignore +2 -0
- data/app/models/spree/gateway/mollie_gateway.rb +34 -2
- data/app/models/spree/line_item_decorator.rb +6 -2
- data/app/models/spree/mollie/order_serializer.rb +1 -1
- data/app/models/spree/mollie_payment_source.rb +4 -0
- data/app/views/spree/checkout/payment/_molliegateway.html.erb +8 -1
- data/config/locales/de.yml +4 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/es.yml +4 -0
- data/config/locales/fr.yml +4 -0
- data/config/locales/it.yml +4 -0
- data/config/locales/nl.yml +4 -0
- data/lib/spree_mollie_gateway/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785a4f3e96e91da89386b6e7f12d9916303c00dcfb4acc8e0e6cdefefc184274
|
4
|
+
data.tar.gz: 9cb65667775353fb1ab80197c1163f7a9c7ed6611602ec42d8ec51c043cb894e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed74ed98aab91919c41988214901c60b87c990c1a099d9ba5e7df47cfc7204f5567de1ecf0c6630681a13065f9b4915f22eece38e8122d364748a3c0ca9094c
|
7
|
+
data.tar.gz: e5ec9096cb268de67b1b61f90e1b6ba9ac56b721a84ce478955c878b819571dfd77a7afebe45a34640807076468740d7cefd5a0cd86a644f949d31608ef9f621
|
data/.gitignore
CHANGED
@@ -87,8 +87,40 @@ module Spree
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# Create a new Mollie refund
|
90
|
-
def credit(
|
91
|
-
|
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
|
@@ -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]",
|
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>
|
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.
|
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-
|
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.
|
402
|
+
rubygems_version: 3.0.4
|
397
403
|
signing_key:
|
398
404
|
specification_version: 4
|
399
405
|
summary: Mollie payments for Spree Commerce.
|