spree_mollie_gateway 3.0.4 → 4.0.1
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/.travis.yml +16 -2
- data/Appraisals +13 -5
- data/CONTRIBUTING.md +1 -3
- data/Gemfile +1 -1
- data/README.md +4 -3
- data/app/controllers/spree/api/v1/shipments_controller_decorator.rb +3 -1
- data/app/controllers/spree/checkout_controller_decorator.rb +5 -5
- data/app/models/mollie/client_decorator.rb +3 -1
- data/app/models/spree/address_decorator.rb +3 -1
- data/app/models/spree/gateway/mollie_gateway.rb +34 -2
- data/app/models/spree/line_item_decorator.rb +10 -3
- data/app/models/spree/mollie/order_serializer.rb +2 -2
- data/app/models/spree/mollie/payment_state_updater.rb +6 -2
- data/app/models/spree/mollie_payment_source.rb +8 -3
- data/app/models/spree/order_decorator.rb +20 -1
- data/app/models/spree/payment/gateway_options_decorator.rb +3 -1
- data/app/models/spree/payment/processing_decorator.rb +7 -17
- data/app/models/spree/payment_decorator.rb +3 -1
- data/app/models/spree/payment_method_decorator.rb +3 -1
- data/app/models/spree/shipment_decorator.rb +4 -1
- data/app/models/spree/user_decorator.rb +11 -4
- data/app/views/spree/admin/orders/index.html.erb +22 -17
- data/app/views/spree/api/v1/orders/complete.rabl +7 -0
- data/app/views/spree/api/v1/orders/complete.v1.rabl +1 -7
- data/app/views/spree/api/v1/orders/payment.rabl +7 -0
- data/app/views/spree/api/v1/orders/payment.v1.rabl +1 -7
- 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/docs/api/methods.md +0 -15
- data/gemfiles/spree_3_5.gemfile +4 -4
- data/gemfiles/spree_3_6.gemfile +4 -4
- data/gemfiles/spree_3_7.gemfile +8 -0
- data/gemfiles/spree_4_0.gemfile +10 -0
- data/lib/spree_mollie_gateway/factories.rb +1 -0
- data/lib/spree_mollie_gateway/version.rb +1 -1
- data/spree_mollie_gateway.gemspec +15 -14
- metadata +52 -24
- data/gemfiles/spree_3_1.gemfile +0 -8
- data/gemfiles/spree_3_1.gemfile.lock +0 -389
- data/gemfiles/spree_3_2.gemfile +0 -8
- data/gemfiles/spree_3_2.gemfile.lock +0 -394
- data/gemfiles/spree_3_5.gemfile.lock +0 -394
- data/gemfiles/spree_3_6.gemfile.lock +0 -400
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d99dc1316999eb3638366a484c34ac0a957c2c60cc0e5a83c458529d6c5e047
|
4
|
+
data.tar.gz: 250ebd469c3ad54569871f72ae750be6c0eefaa531b586d80b42c15758bb68eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a3d37600816a59d2d5f6e01843fb637ce8fefe015773108c754fc7f6d8d5091207105859843249588bf70a6e5c30749fafc6af8caf9ee5a44c8ef333f3ff14
|
7
|
+
data.tar.gz: 1a6de43b2782619dacb83a8f5d5e071b377a6126523c9c631202bef29a0ca130fb3b03d3b3d9460aba5f8d52b8040153433bbd170bc47190d8eaf1792c4638fe
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
sudo: false
|
2
2
|
dist: trusty
|
3
|
-
|
4
3
|
language: ruby
|
4
|
+
cache: bundler
|
5
5
|
|
6
6
|
rvm:
|
7
|
-
- 2.5.
|
7
|
+
- 2.5.1
|
8
|
+
- 2.6.5
|
9
|
+
|
10
|
+
gemfile:
|
11
|
+
- gemfiles/spree_3_5.gemfile
|
12
|
+
- gemfiles/spree_3_6.gemfile
|
13
|
+
- gemfiles/spree_3_7.gemfile
|
14
|
+
- gemfiles/spree_4_0.gemfile
|
15
|
+
|
16
|
+
# Use legacy bundler (1.x) when using Ruby 2.3.x
|
17
|
+
before_install:
|
18
|
+
- if [ "USE_LEGACY_BUNDLER" != "false" ]; then gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true; fi
|
19
|
+
- if [ "USE_LEGACY_BUNDLER" != "false" ]; then gem install bundler -v '< 2'; fi
|
8
20
|
|
9
21
|
script:
|
10
22
|
- bundle exec rake test_app
|
@@ -16,6 +28,8 @@ deploy:
|
|
16
28
|
on:
|
17
29
|
tags: true
|
18
30
|
repo: mollie/spree-mollie-gateway
|
31
|
+
rvm: 2.5.1
|
32
|
+
gemfile: gemfiles/spree_3_6.gemfile
|
19
33
|
api_key:
|
20
34
|
secure: N3+LevY4HZd57cmwfIy6a+E/wX/jCD9Pnqq41/kr6I6iLIMz5xWoU0iDEZEXGhTWmId5O0zxTl2o3w4PiVkH4Onmufv3oLOONexrJeIF5cx/TdWpY36RycA2euVvOGVYMNWGIhslCern4zc8pOTwGpmm8DD8qPTQAV1JPXzbPEiXkxJX0KYm1Vb6v4GTW0q2ghvqY3fzgNaJKVQoEXVrOaXMd/dJDQRjBzbzfF8V2Z779kfOfV5PV/jqheq4bXQYMDBKQUHuTvRMNx0tF4mGgHANp1AXMS4GVbYNyAQNmyd3QnkJHSdKthTTe6nwQoH7oloY4Dbd89fG7Yx7I/kt2Aip3pHMts+4/oVN6QPqe0xe11TeC6yRhi/357I+DCzIk1aRGJ9lkpGQnM+oB54N0yw+htvsd7WE2ac57ixVG0ni39IQciQJ4p3aJzho8z3ui3CNj0p3Y4B4moEIJ3JV3Gg+TEXbzViu9G8j7YIlqw0OpGaaczavfuRSTYkE0QKA4BSqGOG+qsY8ArdvW3KgVohSxHzFR6ubhgT81JvzF6hpS7h7PalOUKA5cr7ha/dB0qL1PYNU6xHQFWiM/ILW5eF6ttQDgzA294U8FoRykG6T9swdVZA5Vd6DZafcu6ofqgyRFGQXzlhq/Hdkocb2W60l5BR4BSq4uoIvmMHXd+8=
|
21
35
|
|
data/Appraisals
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
-
appraise 'spree-3-2' do
|
2
|
-
gem 'spree', '~> 3.2.0'
|
3
|
-
end
|
4
|
-
|
5
1
|
appraise 'spree-3-5' do
|
2
|
+
ENV['USE_LEGACY_BUNDLER'] = 'true'
|
3
|
+
|
6
4
|
gem 'spree', '~> 3.5.0'
|
7
5
|
end
|
8
6
|
|
9
7
|
appraise 'spree-3-6' do
|
10
|
-
gem 'spree', '~> 3.6.
|
8
|
+
gem 'spree', '~> 3.6.5'
|
11
9
|
end
|
10
|
+
|
11
|
+
appraise 'spree-3-7' do
|
12
|
+
gem 'spree', '~> 3.7.2'
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise 'spree-4-0' do
|
16
|
+
gem 'spree', '~> 4.0.3'
|
17
|
+
gem 'spree_api', '~> 4.0.3'
|
18
|
+
gem 'rails', '~> 6.0.0'
|
19
|
+
end
|
data/CONTRIBUTING.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
|
-
In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
|
4
|
-
|
5
3
|
Here are some ways *you* can contribute:
|
6
4
|
|
7
5
|
* by using prerelease versions
|
@@ -25,4 +23,4 @@ Starting point:
|
|
25
23
|
* Submit your pull request
|
26
24
|
|
27
25
|
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
28
|
-
[2]: https://github.com/mollie/spree-mollie-gateway/issues
|
26
|
+
[2]: https://github.com/mollie/spree-mollie-gateway/issues
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,7 @@ Please go to the [signup page](https://www.mollie.com/signup) to create a new Mo
|
|
37
37
|
* Allow returning customers to <a href="https://www.mollie.com/en/features/checkout" title="One-click payments">use their previous payment details</a> and pay instantly.
|
38
38
|
|
39
39
|
## Requirements
|
40
|
-
- Spree 3.
|
40
|
+
- Spree 3.5 or newer.
|
41
41
|
|
42
42
|
## Installation
|
43
43
|
|
@@ -84,7 +84,7 @@ If you wish to learn more about our API, please visit the [Mollie API Documentat
|
|
84
84
|
Want to help us make our API client even better? We take [pull requests](https://github.com/mollie/mollie-api-ruby/pulls?utf8=%E2%9C%93&q=is%3Apr), sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. [Check out our vacancies](https://jobs.mollie.com/) or [get in touch](mailto:recruitment@mollie.com).
|
85
85
|
|
86
86
|
## License
|
87
|
-
[BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). Copyright (c) 2014-
|
87
|
+
[BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). Copyright (c) 2014-2019, Mollie B.V.
|
88
88
|
|
89
89
|
## Support
|
90
90
|
Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20-612 88 55
|
@@ -97,7 +97,6 @@ Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20
|
|
97
97
|
+ [More information about SOFORT Banking via Mollie](https://www.mollie.com/en/payments/sofort/)
|
98
98
|
+ [More information about SEPA Bank transfer via Mollie](https://www.mollie.com/en/payments/bank-transfer/)
|
99
99
|
+ [More information about SEPA Direct debit via Mollie](https://www.mollie.com/en/payments/direct-debit/)
|
100
|
-
+ [More information about Bitcoin via Mollie](https://www.mollie.com/en/payments/bitcoin/)
|
101
100
|
+ [More information about PayPal via Mollie](https://www.mollie.com/en/payments/paypal/)
|
102
101
|
+ [More information about KBC/CBC Payment Button via Mollie](https://www.mollie.com/en/payments/kbc-cbc/)
|
103
102
|
+ [More information about Belfius Direct Net via Mollie](https://www.mollie.com/en/payments/belfius)
|
@@ -106,3 +105,5 @@ Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20
|
|
106
105
|
+ [More information about Gift cards via Mollie](https://www.mollie.com/en/payments/gift-cards)
|
107
106
|
+ [More information about EPS via Mollie](https://www.mollie.com/en/payments/eps)
|
108
107
|
+ [More information about Giropay via Mollie](https://www.mollie.com/en/payments/giropay)
|
108
|
+
+ [More information about Apple Pay via Mollie](https://www.mollie.com/en/payments/apple-pay)
|
109
|
+
+ [More information about Przelewy24 via Mollie](https://www.mollie.com/en/payments/przelewy24)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Spree::Api::V1::
|
1
|
+
module Spree::Api::V1::ShipmentsControllerDecorator
|
2
2
|
def ship
|
3
3
|
unless @shipment.tracking.present?
|
4
4
|
# We should enforce entering tracking details, otherwise shipments cannot
|
@@ -10,3 +10,5 @@ Spree::Api::V1::ShipmentsController.class_eval do
|
|
10
10
|
respond_with(@shipment, default_template: :show)
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
Spree::Api::V1::ShipmentsController.prepend(Spree::Api::V1::ShipmentsControllerDecorator)
|
@@ -20,11 +20,7 @@ module Spree
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
prepend CheckoutWithMollie
|
25
|
-
|
26
|
-
private
|
27
|
-
|
23
|
+
module CheckoutControllerDecorator
|
28
24
|
def payment_method_id_param
|
29
25
|
params[:order][:payments_attributes].first[:payment_method_id]
|
30
26
|
end
|
@@ -38,4 +34,8 @@ module Spree
|
|
38
34
|
(params[:state] === 'payment') && params[:order][:payments_attributes]
|
39
35
|
end
|
40
36
|
end
|
37
|
+
|
38
|
+
CheckoutController.prepend(CheckoutWithMollie)
|
39
|
+
CheckoutController.prepend(CheckoutControllerDecorator)
|
40
|
+
|
41
41
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Mollie::
|
1
|
+
module Mollie::ClientDecorator
|
2
2
|
attr_accessor :version_strings
|
3
3
|
|
4
4
|
def initialize(api_key = nil)
|
@@ -11,3 +11,5 @@ Mollie::Client.class_eval do
|
|
11
11
|
add_version_string OpenSSL::OPENSSL_VERSION.split(' ').slice(0, 2).join '/'
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
Mollie::Client.prepend(Mollie::ClientDecorator)
|
@@ -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)
|
@@ -1,12 +1,17 @@
|
|
1
|
-
Spree::
|
1
|
+
module Spree::LineItemDecorator
|
2
|
+
extend Spree::DisplayMoney
|
2
3
|
money_methods :discount_amount, :vat_amount
|
3
4
|
|
4
5
|
def discount_amount
|
5
|
-
adjustments.non_tax.sum(:amount).abs
|
6
|
+
adjustments.eligible.non_tax.sum(:amount).abs
|
6
7
|
end
|
7
8
|
|
8
9
|
def vat_amount
|
9
|
-
adjustments.tax.sum(:amount).abs
|
10
|
+
adjustments.eligible.tax.sum(:amount).abs
|
11
|
+
end
|
12
|
+
|
13
|
+
def mollie_identifier
|
14
|
+
"#{id}-#{variant.sku}"
|
10
15
|
end
|
11
16
|
|
12
17
|
def vat_rate
|
@@ -23,3 +28,5 @@ Spree::LineItem.class_eval do
|
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
31
|
+
|
32
|
+
Spree::LineItem.prepend(Spree::LineItemDecorator)
|
@@ -97,7 +97,7 @@ module Spree
|
|
97
97
|
|
98
98
|
def serialize_address(address)
|
99
99
|
{
|
100
|
-
streetAndNumber: address[:address1],
|
100
|
+
streetAndNumber: [address[:address1], address[:address2]].join(" "),
|
101
101
|
city: address[:city],
|
102
102
|
postalCode: address[:zip],
|
103
103
|
country: address[:country],
|
@@ -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:
|
196
|
+
sku: line.mollie_identifier
|
197
197
|
}
|
198
198
|
end
|
199
199
|
end
|
@@ -28,8 +28,12 @@ module Spree
|
|
28
28
|
@spree_payment.source.update(status: @spree_payment.state)
|
29
29
|
else
|
30
30
|
MollieLogger.debug("Unhandled Mollie payment state received: #{@mollie_order.status}. Therefore we did not update the payment state.")
|
31
|
-
@spree_payment.order.
|
31
|
+
unless @spree_payment.order.paid_or_authorized?
|
32
|
+
@spree_payment.order.update_attributes(state: 'payment', completed_at: nil)
|
33
|
+
end
|
32
34
|
end
|
35
|
+
|
36
|
+
@spree_payment.order.update_with_updater!
|
33
37
|
end
|
34
38
|
|
35
39
|
private
|
@@ -48,7 +52,7 @@ module Spree
|
|
48
52
|
|
49
53
|
def transition_to_failed!
|
50
54
|
@spree_payment.failure! unless @spree_payment.failed?
|
51
|
-
@spree_payment.order.
|
55
|
+
@spree_payment.order.update(state: 'payment', completed_at: nil) unless @spree_payment.order.paid_or_authorized?
|
52
56
|
MollieLogger.debug("Mollie order is #{@mollie_order.status} and will be marked as failed")
|
53
57
|
end
|
54
58
|
|
@@ -27,8 +27,6 @@ module Spree
|
|
27
27
|
'SOFORT Banking'
|
28
28
|
when ::Mollie::Method::BANKTRANSFER then
|
29
29
|
'Bank transfer'
|
30
|
-
when ::Mollie::Method::BITCOIN then
|
31
|
-
'Bitcoin'
|
32
30
|
when ::Mollie::Method::PAYPAL then
|
33
31
|
'PayPal'
|
34
32
|
when ::Mollie::Method::KBC then
|
@@ -51,8 +49,15 @@ module Spree
|
|
51
49
|
'Klarna Slice it'
|
52
50
|
when ::Mollie::Method::KLARNAPAYLATER then
|
53
51
|
'Klarna Pay Later'
|
52
|
+
when ::Mollie::Method::PRZELEWY24 then
|
53
|
+
'Przelewy24'
|
54
|
+
when ::Mollie::Method::APPLEPAY then
|
55
|
+
'Apple Pay'
|
56
|
+
# As of May 1st 2019, Bitcoin is no longer supported.
|
57
|
+
when 'bitcoin' then
|
58
|
+
'Bitcoin'
|
54
59
|
else
|
55
|
-
'Mollie'
|
60
|
+
'Mollie (Unknown method)'
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
Spree::
|
1
|
+
module Spree::OrderDecorator
|
2
|
+
extend Spree::DisplayMoney
|
2
3
|
money_methods :order_adjustment_total, :shipping_discount
|
3
4
|
|
4
5
|
# Make sure the order confirmation is delivered when the order has been paid for.
|
@@ -26,10 +27,26 @@ Spree::Order.class_eval do
|
|
26
27
|
consider_risk
|
27
28
|
end
|
28
29
|
|
30
|
+
def is_paid_with_mollie?
|
31
|
+
payments.any? && payments.last&.payment_method&.type == 'Spree::Gateway::MollieGateway'
|
32
|
+
end
|
33
|
+
|
34
|
+
def send_confirmation_email!
|
35
|
+
if !confirmation_delivered? && (paid? || authorized?)
|
36
|
+
deliver_order_confirmation_email
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
29
40
|
def mollie_order
|
30
41
|
Spree::Mollie::Order.new(self)
|
31
42
|
end
|
32
43
|
|
44
|
+
def successful_payment
|
45
|
+
paid? || payments.any? {|p| p.after_pay_method? && p.authorized?}
|
46
|
+
end
|
47
|
+
|
48
|
+
alias paid_or_authorized? successful_payment
|
49
|
+
|
33
50
|
def authorized?
|
34
51
|
payments.last.authorized?
|
35
52
|
end
|
@@ -42,3 +59,5 @@ Spree::Order.class_eval do
|
|
42
59
|
order_adjustment_total.abs > 0
|
43
60
|
end
|
44
61
|
end
|
62
|
+
|
63
|
+
Spree::Order.prepend(Spree::OrderDecorator)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Spree::Payment::
|
1
|
+
module Spree::Payment::GatewayOptionsDecorator
|
2
2
|
def hash_methods
|
3
3
|
%i[
|
4
4
|
email
|
@@ -17,3 +17,5 @@ Spree::Payment::GatewayOptions.class_eval do
|
|
17
17
|
]
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
Spree::Payment::GatewayOptions.prepend(Spree::Payment::GatewayOptionsDecorator)
|
@@ -1,9 +1,10 @@
|
|
1
|
-
Spree::Payment::
|
2
|
-
|
1
|
+
module Spree::Payment::ProcessingDecorator
|
2
|
+
|
3
|
+
def process!
|
3
4
|
if payment_method.is_a? Spree::Gateway::MollieGateway
|
4
5
|
process_with_mollie
|
5
6
|
else
|
6
|
-
|
7
|
+
super
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
@@ -11,30 +12,17 @@ Spree::Payment::Processing.module_eval do
|
|
11
12
|
if payment_method.is_a? Spree::Gateway::MollieGateway
|
12
13
|
cancel_with_mollie
|
13
14
|
else
|
14
|
-
|
15
|
+
super
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
def cancel_with_spree
|
21
|
-
response = payment_method.cancel(response_code)
|
22
|
-
handle_response(response, :void, :failure)
|
23
|
-
end
|
24
|
-
|
25
21
|
def cancel_with_mollie
|
26
22
|
response = payment_method.cancel(transaction_id)
|
27
23
|
handle_response(response, :void, :failure)
|
28
24
|
end
|
29
25
|
|
30
|
-
def process_with_spree
|
31
|
-
if payment_method && payment_method.auto_capture?
|
32
|
-
purchase!
|
33
|
-
else
|
34
|
-
authorize!
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
26
|
def process_with_mollie
|
39
27
|
amount ||= money.money
|
40
28
|
started_processing!
|
@@ -46,3 +34,5 @@ Spree::Payment::Processing.module_eval do
|
|
46
34
|
handle_response(response, :started_processing, :failure)
|
47
35
|
end
|
48
36
|
end
|
37
|
+
|
38
|
+
Spree::Payment.include(Spree::Payment::ProcessingDecorator)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Spree::
|
1
|
+
module Spree::PaymentDecorator
|
2
2
|
def transaction_id
|
3
3
|
if payment_method.is_a? Spree::Gateway::MollieGateway
|
4
4
|
source.transaction_id
|
@@ -37,3 +37,5 @@ Spree::Payment.class_eval do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
Spree::Payment.prepend(Spree::PaymentDecorator)
|