spree_mollie_gateway 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +38 -0
- data/README.md +93 -0
- data/Rakefile +6 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +41 -0
- data/app/controllers/spree/mollie_controller.rb +26 -0
- data/app/models/mollie/provider.rb +5 -0
- data/app/models/spree/gateway/mollie_gateway.rb +123 -0
- data/app/models/spree/mollie_transaction.rb +53 -0
- data/app/models/spree/payment/processing_decorator.rb +6 -0
- data/app/models/spree/user_decorator.rb +9 -0
- data/app/views/spree/admin/payments/source_forms/_molliegateway.html.erb +1 -0
- data/app/views/spree/admin/payments/source_views/_molliegateway.html.erb +17 -0
- data/app/views/spree/checkout/payment/_molliegateway.html.erb +12 -0
- data/app/views/spree/shared/_payment.html.erb +22 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20180214133044_create_spree_mollie_transactions.rb +13 -0
- data/db/migrate/20180301084841_add_mollie_customer_id_to_spree_user.rb +5 -0
- data/lib/generators/spree_mollie_gateway/install/install_generator.rb +20 -0
- data/lib/spree_mollie_gateway.rb +6 -0
- data/lib/spree_mollie_gateway/engine.rb +20 -0
- data/lib/spree_mollie_gateway/version.rb +3 -0
- data/spree_mollie_gateway.gemspec +37 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95f98e46f696167e0421b8a551fa7e1fd4469e06
|
4
|
+
data.tar.gz: fb87fee10d481de2e99436bbdf21e83e537a248c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb3d548451752fdc492dd25170fe30bf6ec448528de2d9232420290a5a24d9cf03604cfc8c4fb408800bde298b5f66359e4073a210d7e45bd516645c88361a53
|
7
|
+
data.tar.gz: e27a437e347ea2c2272b47de4328f551b8619b7457fa59dfe616bea9206f5a91e4d37957f7fbcbccfa2d5940c7bf3f79d9a76ee6333ddb2278191e8da1fb89c0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
spree_mollie_gateway (0.1.0)
|
5
|
+
mollie-api-ruby (~> 3.1.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
mollie-api-ruby (3.1.3)
|
12
|
+
rake (10.5.0)
|
13
|
+
rspec (3.7.0)
|
14
|
+
rspec-core (~> 3.7.0)
|
15
|
+
rspec-expectations (~> 3.7.0)
|
16
|
+
rspec-mocks (~> 3.7.0)
|
17
|
+
rspec-core (3.7.1)
|
18
|
+
rspec-support (~> 3.7.0)
|
19
|
+
rspec-expectations (3.7.0)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.7.0)
|
22
|
+
rspec-mocks (3.7.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.7.0)
|
25
|
+
rspec-support (3.7.1)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 1.16)
|
32
|
+
mollie-api-ruby (~> 3.1.3)
|
33
|
+
rake (~> 10.0)
|
34
|
+
rspec (~> 3.0)
|
35
|
+
spree_mollie_gateway!
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
[<img src="https://www.mollie.com/assets/images/mollie/logo-black.svg" width="110">](https://www.mollie.com/)
|
2
|
+
|
3
|
+
Quickly integrate all major payment methods in Spree Commerce, wherever you need them. Simply drop them ready-made into your Spree Commerce webshop with this powerful plugin by Mollie. Mollie is dedicated to making payments better for Spree Commerce.
|
4
|
+
|
5
|
+
> Next level payments, for Spree Commerce
|
6
|
+
|
7
|
+
No need to spend weeks on paperwork or security compliance procedures. No more lost conversions because you don’t support a shopper’s favorite payment method or because they don’t feel safe. We made payments intuitive and safe for merchants and their customers.
|
8
|
+
|
9
|
+
1. [Payment methods](#payment-methods)
|
10
|
+
2. [Features](#features)
|
11
|
+
3. [Requirements](#requirements)
|
12
|
+
4. [Installation](#installation)
|
13
|
+
5. [Configuring Mollie Gateway](#configuring-mollie-gateway)
|
14
|
+
6. [License](#license)
|
15
|
+
|
16
|
+
## Payment methods
|
17
|
+
|
18
|
+
Credit cards:
|
19
|
+
|
20
|
+
* VISA (International)
|
21
|
+
* MasterCard (International)
|
22
|
+
* American Express (International)
|
23
|
+
* Cartes Bancaires (France)
|
24
|
+
* CartaSi (Italy)
|
25
|
+
|
26
|
+
Debit cards:
|
27
|
+
|
28
|
+
* V Pay (International)
|
29
|
+
* Maestro (International)
|
30
|
+
|
31
|
+
Alternative payment methods:
|
32
|
+
|
33
|
+
* iDEAL (Netherlands)
|
34
|
+
* Bancontact (Belgium)
|
35
|
+
* Home'Pay (Belgium)
|
36
|
+
* PayPal (International)
|
37
|
+
* SOFORTbanking (EU)
|
38
|
+
* Belfius (Belgium)
|
39
|
+
* KBC/CBC payment button (Belgium)
|
40
|
+
* SEPA - Credit Transfer (EU)
|
41
|
+
* SEPA - Direct Debit (EU)
|
42
|
+
* Bitcoin (International)
|
43
|
+
* Paysafecard (International)
|
44
|
+
* Gift cards (Netherlands)
|
45
|
+
|
46
|
+
Please go to the [signup page](https://www.mollie.com/signup) to create a new Mollie account and start receiving payments in a couple of minutes. Contact info@mollie.com if you have any questions or comments about this plugin.
|
47
|
+
|
48
|
+
> Our pricing is always per transaction. No startup fees, no monthly fees, and no gateway fees. No hidden fees, period.
|
49
|
+
|
50
|
+
## Features
|
51
|
+
|
52
|
+
* Support for all available Mollie payment methods.
|
53
|
+
* Support for [one-click payments](https://www.mollie.com/en/features/checkout).
|
54
|
+
* Transparent pricing. No startup fees, no monthly fees, and no gateway fees. No hidden fees, period.
|
55
|
+
* Configurable pay outs: daily, weekly, monthly - whatever you prefer.
|
56
|
+
* [Powerful dashboard](https://www.mollie.com/en/features/dashboard) on mollie.com to easily keep track of your payments.
|
57
|
+
* Fast in-house support. You will always be helped by someone who knows our products intimately.
|
58
|
+
* Multiple translations: English and Dutch.
|
59
|
+
* Event log for debugging purposes.
|
60
|
+
|
61
|
+
## Requirements
|
62
|
+
- Spree 3.4.x or higher.
|
63
|
+
- Rails 5.1.x or higher.
|
64
|
+
|
65
|
+
## Installation
|
66
|
+
|
67
|
+
Open your `Gemfile` and add `spree_mollie_gateway`.
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
gem 'spree_mollie_gateway'
|
71
|
+
```
|
72
|
+
|
73
|
+
Install the gem by running `bundle install`.
|
74
|
+
|
75
|
+
Run the installer which takes care of copying migrations:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
bundle exec rails g spree_mollie_gateway:install
|
79
|
+
```
|
80
|
+
|
81
|
+
## Configuring Mollie Gateway
|
82
|
+
|
83
|
+
1. Configure a new payment method (`Spree Admin -> Configurations -> Payment Methods -> New Payment Method`).
|
84
|
+
2. Select `Spree::Gateway::MollieGateway` as a `Provider`.
|
85
|
+
3. Fill in your live / test `API key`.
|
86
|
+
4. Fill in your hostname. Used for generating the webhook URL and redirect URL.
|
87
|
+
5. Select "Front End" in the `Display` selectbox.
|
88
|
+
6. Fill in "Mollie" for the `Name` field.
|
89
|
+
7. Save and you're done!
|
90
|
+
|
91
|
+
## License
|
92
|
+
[GPLv2 (GNU General Public License, version 2) License](http://www.gnu.org/licenses/gpl-2.0.html).
|
93
|
+
Copyright (c) 2018, Mollie B.V.
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Spree
|
2
|
+
module CheckoutWithMollie
|
3
|
+
def update
|
4
|
+
if payment_params_valid? && paying_with_mollie?
|
5
|
+
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
|
6
|
+
payment = @order.payments.last
|
7
|
+
payment.create_transaction!
|
8
|
+
mollie_payment_url = payment.payment_source.payment_url
|
9
|
+
|
10
|
+
redirect_to mollie_payment_url
|
11
|
+
else
|
12
|
+
render :edit
|
13
|
+
end
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
CheckoutController.class_eval do
|
21
|
+
prepend CheckoutWithMollie
|
22
|
+
private
|
23
|
+
|
24
|
+
def payment_method_id_param
|
25
|
+
params[:order][:payments_attributes].first[:payment_method_id]
|
26
|
+
end
|
27
|
+
|
28
|
+
def paying_with_mollie?
|
29
|
+
payment_method = PaymentMethod.find(payment_method_id_param)
|
30
|
+
mollie_payment_method?(payment_method)
|
31
|
+
end
|
32
|
+
|
33
|
+
def payment_params_valid?
|
34
|
+
(params[:state] === 'payment') && params[:order][:payments_attributes]
|
35
|
+
end
|
36
|
+
|
37
|
+
def mollie_payment_method?(payment_method)
|
38
|
+
payment_method.is_a?(Gateway::MollieGateway)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Spree
|
2
|
+
class MollieController < BaseController
|
3
|
+
skip_before_action :verify_authenticity_token, :only => [:update_payment_status]
|
4
|
+
|
5
|
+
# When the user is redirected from Mollie back to the shop, we can check the
|
6
|
+
# mollie transaction status and set the Spree order state accordingly.
|
7
|
+
def validate_payment
|
8
|
+
order = Spree::Order.find_by_number(params[:order_number])
|
9
|
+
payment = order.payments.last
|
10
|
+
mollie = Spree::PaymentMethod.find_by_type('Spree::Gateway::MollieGateway')
|
11
|
+
mollie.update_payment_status(payment)
|
12
|
+
|
13
|
+
redirect_to order.reload.paid? ? order_path(order) : checkout_state_path(:payment)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Mollie might send us information about a transaction through the webhook.
|
17
|
+
# We should update the payment state accordingly.
|
18
|
+
def update_payment_status
|
19
|
+
payment = Spree::Payment.find_by_response_code(params[:id])
|
20
|
+
mollie = Spree::PaymentMethod.find_by_type('Spree::Gateway::MollieGateway')
|
21
|
+
mollie.update_payment_status(payment)
|
22
|
+
|
23
|
+
render json: 'OK'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::MollieGateway < PaymentMethod
|
3
|
+
preference :api_key, :string
|
4
|
+
preference :hostname, :string
|
5
|
+
|
6
|
+
has_many :spree_mollie_transactions, class_name: 'Spree::MollieTransaction'
|
7
|
+
|
8
|
+
def payment_source_class
|
9
|
+
Spree::MollieTransaction
|
10
|
+
end
|
11
|
+
|
12
|
+
def provider_class
|
13
|
+
::Mollie::Provider
|
14
|
+
end
|
15
|
+
|
16
|
+
def source_required?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def available_for_order?(order)
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create a new transaction
|
25
|
+
def create_transaction(money, source, gateway_options)
|
26
|
+
payment = payments.last
|
27
|
+
transaction = ::Mollie::Payment.create(
|
28
|
+
prepare_transaction_params(payment.order, source)
|
29
|
+
)
|
30
|
+
|
31
|
+
invalidate_prev_transactions(payment.id)
|
32
|
+
|
33
|
+
payment.response_code = transaction.id
|
34
|
+
payment.save!
|
35
|
+
|
36
|
+
source.payment_id = transaction.id
|
37
|
+
source.payment_url = transaction.payment_url
|
38
|
+
source.save!
|
39
|
+
|
40
|
+
ActiveMerchant::Billing::Response.new(true, 'Transaction created')
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_customer(user)
|
44
|
+
Mollie::Customer.create(
|
45
|
+
email: user.email,
|
46
|
+
api_key: get_preference(:api_key),
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def prepare_transaction_params(order, source)
|
51
|
+
spree_routes = ::Spree::Core::Engine.routes.url_helpers
|
52
|
+
|
53
|
+
order_number = order.number
|
54
|
+
order_params = {
|
55
|
+
amount: order.total.to_f,
|
56
|
+
description: "Spree Order ID: #{order_number}",
|
57
|
+
redirectUrl: spree_routes.mollie_validate_payment_mollie_url(order_number: order_number, host: get_preference(:hostname)),
|
58
|
+
webhookUrl: spree_routes.mollie_update_payment_status_mollie_url(order_number: order_number, host: get_preference(:hostname)),
|
59
|
+
method: source.payment_method_name,
|
60
|
+
metadata: {
|
61
|
+
order_id: order_number
|
62
|
+
},
|
63
|
+
api_key: get_preference(:api_key),
|
64
|
+
}
|
65
|
+
|
66
|
+
if order.user_id.present?
|
67
|
+
if source.payment_method_name.match(Regexp.union([::Mollie::Method::BITCOIN, ::Mollie::Method::BANKTRANSFER, ::Mollie::Method::GIFTCARD]))
|
68
|
+
order_params.merge! ({
|
69
|
+
billingEmail: order.user.email
|
70
|
+
})
|
71
|
+
end
|
72
|
+
|
73
|
+
# Allow single click payments by passing Mollie customer ID
|
74
|
+
if order.user.mollie_customer_id.present?
|
75
|
+
order_params.merge! ({
|
76
|
+
customerId: order.user.mollie_customer_id
|
77
|
+
})
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
order_params
|
82
|
+
end
|
83
|
+
|
84
|
+
def available_payment_methods
|
85
|
+
::Mollie::Method.all(
|
86
|
+
api_key: get_preference(:api_key),
|
87
|
+
include: 'issuers'
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
def update_payment_status(payment)
|
92
|
+
mollie_transaction_id = payment.response_code
|
93
|
+
transaction = ::Mollie::Payment.get(
|
94
|
+
mollie_transaction_id,
|
95
|
+
api_key: get_preference(:api_key)
|
96
|
+
)
|
97
|
+
|
98
|
+
unless payment.completed?
|
99
|
+
case transaction.status
|
100
|
+
when 'paid'
|
101
|
+
payment.complete! unless payment.completed?
|
102
|
+
payment.order.finalize!
|
103
|
+
payment.order.update_attributes(:state => 'complete', :completed_at => Time.now)
|
104
|
+
when 'cancelled', 'expired', 'failed'
|
105
|
+
payment.failure! unless payment.failed?
|
106
|
+
else
|
107
|
+
logger.debug 'Unhandled Mollie payment state received. Therefore we did not update the payment state.'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
payment.source.update(status: payment.state)
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
def invalidate_prev_transactions(current_payment_id)
|
116
|
+
# Cancel all previous payment which are pending or are still being processed
|
117
|
+
payments.with_state('processing').or(payments.with_state('pending')).where.not(id: current_payment_id).each do |payment|
|
118
|
+
# Set internal payment state to failed
|
119
|
+
payment.failure! unless payment.store_credit?
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Spree
|
2
|
+
class MollieTransaction < Spree::Base
|
3
|
+
belongs_to :payment_method
|
4
|
+
has_many :payment, as: :source
|
5
|
+
|
6
|
+
def actions
|
7
|
+
[]
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_type
|
11
|
+
'mollie_transaction'
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
case payment_method_name
|
16
|
+
when ::Mollie::Method::IDEAL then
|
17
|
+
'iDEAL'
|
18
|
+
when ::Mollie::Method::CREDITCARD then
|
19
|
+
'Credit card'
|
20
|
+
when ::Mollie::Method::MISTERCASH then
|
21
|
+
'Bancontact'
|
22
|
+
when ::Mollie::Method::SOFORT then
|
23
|
+
'SOFORT Banking'
|
24
|
+
when ::Mollie::Method::BANKTRANSFER then
|
25
|
+
'Bank transfer'
|
26
|
+
when ::Mollie::Method::BITCOIN then
|
27
|
+
'Bitcoin'
|
28
|
+
when ::Mollie::Method::PAYPAL then
|
29
|
+
'PayPal'
|
30
|
+
when ::Mollie::Method::KBC then
|
31
|
+
'KBC/CBC Payment Button'
|
32
|
+
when ::Mollie::Method::BELFIUS then
|
33
|
+
'Belfius Pay Button'
|
34
|
+
when ::Mollie::Method::PAYSAFECARD then
|
35
|
+
'paysafecard'
|
36
|
+
when ::Mollie::Method::PODIUMCADEAUKAART then
|
37
|
+
'Podium Cadeaukaart'
|
38
|
+
when ::Mollie::Method::GIFTCARD then
|
39
|
+
'Giftcard'
|
40
|
+
when ::Mollie::Method::INGHOMEPAY then
|
41
|
+
'ING Home\'Pay'
|
42
|
+
else
|
43
|
+
'Mollie'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def details
|
48
|
+
api_key = payment_method.get_preference(:api_key)
|
49
|
+
mollie_payment = ::Mollie::Payment.get(payment_id, api_key: api_key)
|
50
|
+
mollie_payment.attributes
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Spree::User.class_eval do
|
2
|
+
after_create :create_mollie_customer
|
3
|
+
|
4
|
+
def create_mollie_customer
|
5
|
+
mollie_gateway = Spree::PaymentMethod.find_by_type('Spree::Gateway::MollieGateway')
|
6
|
+
mollie_customer = mollie_gateway.create_customer(self)
|
7
|
+
update mollie_customer_id: mollie_customer.id
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<!-- Mollie payments cannot be created manually -->
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if payment.source.present? %>
|
2
|
+
<fieldset data-hook="mollie_payment_source">
|
3
|
+
<legend><%= payment.source.name %></legend>
|
4
|
+
<table class="table table-condensed table-bordered">
|
5
|
+
<% payment.source.details.each do |key, value| %>
|
6
|
+
<tr>
|
7
|
+
<th width="20%"><%= key %></th>
|
8
|
+
<td><%= value %></td>
|
9
|
+
</tr>
|
10
|
+
<% end %>
|
11
|
+
</table>
|
12
|
+
</fieldset>
|
13
|
+
<% else %>
|
14
|
+
<div class="alert alert-danger">
|
15
|
+
<%= Spree.t(:no_mollie_transactions) %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<ul class="list-group">
|
2
|
+
<% payment_method.available_payment_methods.each do |method| %>
|
3
|
+
<div class="radio list-group-item clearfix">
|
4
|
+
|
5
|
+
<label class="pull-left">
|
6
|
+
<%= radio_button("payment_source[#{payment_method.id}]", :payment_method_name, method.id) %>
|
7
|
+
<%= image_tag(method.image['normal']) %>
|
8
|
+
<%= method.description %>
|
9
|
+
</label>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% source = payment.source %>
|
2
|
+
|
3
|
+
<% if source.is_a?(Spree::CreditCard) %>
|
4
|
+
<span class="cc-type">
|
5
|
+
<% unless (cc_type = source.cc_type).blank? %>
|
6
|
+
<%= image_tag "credit_cards/icons/#{cc_type}.png" %>
|
7
|
+
<% end %>
|
8
|
+
<% if source.last_digits %>
|
9
|
+
<%= Spree.t(:ending_in) %> <%= source.last_digits %>
|
10
|
+
<% end %>
|
11
|
+
</span>
|
12
|
+
<br />
|
13
|
+
<span class="full-name"><%= source.name %></span>
|
14
|
+
<% elsif source.is_a?(Spree::MollieTransaction) %>
|
15
|
+
<span class="full-name"><%= source.name %></span>
|
16
|
+
<% else %>
|
17
|
+
<%= content_tag(:span, payment.payment_method.name) %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<span class="payment-amount">(<%= payment.display_amount %>)</span>
|
21
|
+
|
22
|
+
<br />
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "spree_mollie_gateway"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
Spree::Core::Engine.add_routes do
|
2
|
+
resource :mollie, only: [], controller: :mollie do
|
3
|
+
post 'update_payment_status/:order_number', action: :update_payment_status, as: 'mollie_update_payment_status'
|
4
|
+
get 'validate_payment/:order_number', action: :validate_payment, as: 'mollie_validate_payment'
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSpreeMollieTransactions < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :spree_mollie_transactions do |t|
|
4
|
+
t.string :payment_id
|
5
|
+
t.string :payment_method_name
|
6
|
+
t.string :issuer
|
7
|
+
t.string :status
|
8
|
+
t.string :payment_url
|
9
|
+
t.integer :payment_method_id
|
10
|
+
t.integer :user_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SpreeMollieGateway
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
5
|
+
|
6
|
+
def add_migrations
|
7
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_mollie_gateway'
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_migrations
|
11
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
12
|
+
if run_migrations
|
13
|
+
run 'bundle exec rake db:migrate'
|
14
|
+
else
|
15
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mollie-api-ruby'
|
2
|
+
|
3
|
+
module SpreeMollieGateway
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace SpreeMollieGateway
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
def self.activate
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
11
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
12
|
+
end
|
13
|
+
|
14
|
+
Rails.application.config.spree.payment_methods << Spree::Gateway::MollieGateway
|
15
|
+
Spree::PermittedAttributes.source_attributes << :payment_method_name
|
16
|
+
end
|
17
|
+
|
18
|
+
config.to_prepare &method(:activate).to_proc
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "spree_mollie_gateway/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "spree_mollie_gateway"
|
8
|
+
spec.version = SpreeMollieGateway::VERSION
|
9
|
+
spec.authors = ["Vernon de Goede"]
|
10
|
+
spec.email = ["vernon@mollie.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Mollie payments for Spree Commerce.}
|
13
|
+
spec.description = %q{Mollie ayment gateway for Spree Commerce.}
|
14
|
+
spec.homepage = "https://www.mollie.com"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'mollie-api-ruby', '~> 3.1', '>= 3.1.3'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_mollie_gateway
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vernon de Goede
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mollie-api-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 3.1.3
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '3.1'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.1.3
|
75
|
+
description: Mollie ayment gateway for Spree Commerce.
|
76
|
+
email:
|
77
|
+
- vernon@mollie.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- ".travis.yml"
|
85
|
+
- Gemfile
|
86
|
+
- Gemfile.lock
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- app/controllers/spree/checkout_controller_decorator.rb
|
90
|
+
- app/controllers/spree/mollie_controller.rb
|
91
|
+
- app/models/mollie/provider.rb
|
92
|
+
- app/models/spree/gateway/mollie_gateway.rb
|
93
|
+
- app/models/spree/mollie_transaction.rb
|
94
|
+
- app/models/spree/payment/processing_decorator.rb
|
95
|
+
- app/models/spree/user_decorator.rb
|
96
|
+
- app/views/spree/admin/payments/source_forms/_molliegateway.html.erb
|
97
|
+
- app/views/spree/admin/payments/source_views/_molliegateway.html.erb
|
98
|
+
- app/views/spree/checkout/payment/_molliegateway.html.erb
|
99
|
+
- app/views/spree/shared/_payment.html.erb
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- config/routes.rb
|
103
|
+
- db/migrate/20180214133044_create_spree_mollie_transactions.rb
|
104
|
+
- db/migrate/20180301084841_add_mollie_customer_id_to_spree_user.rb
|
105
|
+
- lib/generators/spree_mollie_gateway/install/install_generator.rb
|
106
|
+
- lib/spree_mollie_gateway.rb
|
107
|
+
- lib/spree_mollie_gateway/engine.rb
|
108
|
+
- lib/spree_mollie_gateway/version.rb
|
109
|
+
- spree_mollie_gateway.gemspec
|
110
|
+
homepage: https://www.mollie.com
|
111
|
+
licenses: []
|
112
|
+
metadata:
|
113
|
+
allowed_push_host: https://rubygems.org
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.6.14
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Mollie payments for Spree Commerce.
|
134
|
+
test_files: []
|