spree_cod_payment 1.0.0 → 2.0.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 +4 -4
- data/LICENSE.md +8 -0
- data/README.md +29 -16
- data/app/models/spree/payment_method/cod_payment.rb +50 -49
- data/app/models/spree/payment_method/payment_method_decorator.rb +15 -0
- data/app/views/spree/admin/shipping_methods/_cod_form.html.erb +14 -0
- data/app/views/spree/checkout/payment/_cod_payment.html.erb +3 -0
- data/config/locales/el.yml +12 -3
- data/config/locales/en.yml +13 -2
- data/db/migrate/20250601165042_add_cod_fee_to_shipping_methods.rb +5 -0
- data/lib/generators/spree_cod_payment/install/install_generator.rb +1 -1
- data/lib/spree_cod_payment/engine.rb +11 -11
- data/lib/spree_cod_payment/version.rb +3 -7
- data/lib/spree_cod_payment.rb +1 -3
- metadata +39 -34
- data/.gitignore +0 -23
- data/.rspec +0 -3
- data/.rubocop.yml +0 -24
- data/.travis.yml +0 -37
- data/Gemfile +0 -13
- data/LICENSE +0 -21
- data/app/helpers/.gitkeep +0 -0
- data/app/models/spree/order_decorator.rb +0 -15
- data/app/models/spree/payment_decorator.rb +0 -46
- data/app/models/spree/payment_method_decorator.rb +0 -11
- data/app/models/spree/shipment_decorator.rb +0 -23
- data/app/models/spree_cod_payment/configuration.rb +0 -8
- data/app/serializers/.gitkeep +0 -0
- data/app/services/.gitkeep +0 -0
- data/bin/rails +0 -8
- data/spree_cod_payment.gemspec +0 -30
- /data/{CONTRIBUTING.md → app/views/spree/admin/payment_methods/_cod_payment.html.erb} +0 -0
- /data/app/{assets/.gitkeep → views/spree/admin/payment_methods/descriptions/_cod_payment.html.erb} +0 -0
- /data/app/{controllers/.gitkeep → views/spree/admin/spree/checkout/payment/_cod_payment.html.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d25a1abf3beee54bf63e0615806cee61e6e16cafd00343461ad4da8080aab2e6
|
4
|
+
data.tar.gz: e88b35135b5b56cc504e498219dde8d9578a4a6e3334a2259fe5baf8780fabff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ec29309d7427c93640504090e417b593436e9a384b30b3f46b90776b477985812f5389e0445a3d3fbe3b6091c4f5c356bbbcba20d9e9dc4d56a313aca1003dc
|
7
|
+
data.tar.gz: a1caa0ac4ef2c83a0052e189b89e6305ca26e3fbf8894a5fe1e43b51ac8c2378e6a56fd6cd50d435abf44d51156e9bf22a1e1023cb8f684e602f343d5398eaa5
|
data/LICENSE.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all
|
6
|
+
copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,35 +1,48 @@
|
|
1
1
|
# SpreeCodPayment
|
2
2
|
|
3
|
-
[
|
3
|
+
This is a Cash On Delivery Payment extension for [Spree Commerce](https://spreecommerce.org), an open source e-commerce platform built with Ruby on Rails. Adds Cash on Delivery (COD) payment method to Spree stores.
|
4
4
|
|
5
|
-
|
5
|
+
[](https://badge.fury.io/rb/spree_cod_payment)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
1. Add this extension to your Gemfile with this line:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
bundle add spree_cod_payment
|
13
13
|
```
|
14
14
|
|
15
|
-
2. Install the
|
15
|
+
2. Install the migrations:
|
16
16
|
|
17
|
-
```
|
18
|
-
bundle install
|
17
|
+
```sh
|
18
|
+
bundle exec rake railties:install:migrations FROM=spree_cod_payment
|
19
19
|
```
|
20
20
|
|
21
|
-
3.
|
21
|
+
3. Run the migrations:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
bundle exec rails db:migrate
|
25
|
+
```
|
26
|
+
|
27
|
+
4. Restart your server
|
22
28
|
|
23
29
|
If your server was running, restart it so that it can find the assets properly.
|
24
30
|
|
25
|
-
##
|
31
|
+
## Developing
|
26
32
|
|
27
|
-
|
33
|
+
1. Create a dummy app
|
28
34
|
|
29
|
-
```
|
30
|
-
bundle
|
31
|
-
bundle exec rake
|
32
|
-
```
|
35
|
+
```bash
|
36
|
+
bundle update
|
37
|
+
bundle exec rake test_app
|
38
|
+
```
|
39
|
+
|
40
|
+
2. Add your new code
|
41
|
+
3. Run tests
|
42
|
+
|
43
|
+
```bash
|
44
|
+
bundle exec rspec
|
45
|
+
```
|
33
46
|
|
34
47
|
When testing your applications integration with this extension you may use it's factories.
|
35
48
|
Simply add this require statement to your spec_helper:
|
@@ -38,14 +51,14 @@ Simply add this require statement to your spec_helper:
|
|
38
51
|
require 'spree_cod_payment/factories'
|
39
52
|
```
|
40
53
|
|
41
|
-
## Releasing
|
54
|
+
## Releasing a new version
|
42
55
|
|
43
56
|
```shell
|
44
57
|
bundle exec gem bump -p -t
|
45
58
|
bundle exec gem release
|
46
59
|
```
|
47
60
|
|
48
|
-
For more options please see [gem-release
|
61
|
+
For more options please see [gem-release README](https://github.com/svenfuchs/gem-release)
|
49
62
|
|
50
63
|
## Contributing
|
51
64
|
|
@@ -53,4 +66,4 @@ If you'd like to contribute, please take a look at the
|
|
53
66
|
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
|
54
67
|
pull request.
|
55
68
|
|
56
|
-
Copyright (c)
|
69
|
+
Copyright (c) 2025 OlympusOne, released under the New BSD License
|
@@ -1,50 +1,51 @@
|
|
1
1
|
module Spree
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
2
|
+
class PaymentMethod::CodPayment < Spree::PaymentMethod
|
3
|
+
def method_type
|
4
|
+
type.demodulize.underscore
|
5
|
+
end
|
6
|
+
|
7
|
+
def default_name
|
8
|
+
Spree.t(:cod_payment_method)
|
9
|
+
end
|
10
|
+
|
11
|
+
def source_required?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def auto_capture?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def actions
|
20
|
+
%w[capture void]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Indicates whether its possible to capture the payment
|
24
|
+
def can_capture?(payment)
|
25
|
+
payment.pending? && payment.order.shipped?
|
26
|
+
end
|
27
|
+
|
28
|
+
# Indicates whether its possible to void the payment.
|
29
|
+
def can_void?(payment)
|
30
|
+
!payment.void?
|
31
|
+
end
|
32
|
+
|
33
|
+
def capture(*)
|
34
|
+
simulated_successful_billing_response
|
35
|
+
end
|
36
|
+
|
37
|
+
def cancel(*)
|
38
|
+
simulated_successful_billing_response
|
39
|
+
end
|
40
|
+
|
41
|
+
def credit(*)
|
42
|
+
simulated_successful_billing_response
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def simulated_successful_billing_response
|
48
|
+
ActiveMerchant::Billing::Response.new(true, '', {}, {})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spree
|
2
|
+
module PaymentMethodDecorator
|
3
|
+
def available_for_order?(order)
|
4
|
+
return cod_payment? && super if order.shipping_method&.cod?
|
5
|
+
|
6
|
+
!cod_payment? && super
|
7
|
+
end
|
8
|
+
|
9
|
+
def cod_payment?
|
10
|
+
method_type == 'cod_payment'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Spree::PaymentMethod.prepend Spree::PaymentMethodDecorator
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="card mb-4">
|
2
|
+
<div class="card-header">
|
3
|
+
<h5 class="card-title">
|
4
|
+
<%= Spree.t(:cod) %>
|
5
|
+
</h5>
|
6
|
+
</div>
|
7
|
+
<div class="card-body">
|
8
|
+
<div class="custom-control custom-checkbox">
|
9
|
+
<%= f.check_box :cod, class: 'custom-control-input' %>
|
10
|
+
<%= f.label :cod, class: 'custom-control-label font-weight-semibold' %>
|
11
|
+
<%= f.error_message_on :cod %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</div>
|
data/config/locales/el.yml
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
+
---
|
1
2
|
el:
|
3
|
+
activerecord:
|
4
|
+
attributes:
|
5
|
+
spree/shipping_method:
|
6
|
+
cod: Με αντικαταβολή
|
2
7
|
spree:
|
3
|
-
|
4
|
-
|
5
|
-
|
8
|
+
cod: Αντικαταβολή
|
9
|
+
cod_payment_method: Αντικαταβολή
|
10
|
+
storefront:
|
11
|
+
checkout:
|
12
|
+
cod_payment_method:
|
13
|
+
title: Αντικαταβολή
|
14
|
+
description: Θα πληρώσετε την παραγγελία σας με μετρητά κατά την παράδοση στη διεύθυνσή σας.
|
data/config/locales/en.yml
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
---
|
1
2
|
en:
|
2
|
-
|
3
|
-
|
3
|
+
activerecord:
|
4
|
+
attributes:
|
5
|
+
spree/shipping_method:
|
6
|
+
cod: Cash on Delivery
|
7
|
+
spree:
|
8
|
+
cod: Cash on Delivery
|
9
|
+
cod_payment_method: Cash on Delivery
|
10
|
+
storefront:
|
11
|
+
checkout:
|
12
|
+
cod_payment_method:
|
13
|
+
title: Cash on Delivery
|
14
|
+
description: You will pay for your order in cash when it is delivered to your address.
|
@@ -10,7 +10,7 @@ module SpreeCodPayment
|
|
10
10
|
def run_migrations
|
11
11
|
run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
12
12
|
if run_migrations
|
13
|
-
run '
|
13
|
+
run 'bin/rails db:migrate'
|
14
14
|
else
|
15
15
|
puts 'Skipping rails db:migrate, don\'t forget to run it!'
|
16
16
|
end
|
@@ -2,27 +2,27 @@ module SpreeCodPayment
|
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
require 'spree/core'
|
4
4
|
isolate_namespace Spree
|
5
|
-
engine_name 'spree_cod_payment'
|
6
|
-
|
5
|
+
engine_name 'spree_cod_payment'
|
6
|
+
|
7
7
|
# use rspec for tests
|
8
8
|
config.generators do |g|
|
9
9
|
g.test_framework :rspec
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
12
|
+
config.after_initialize do |app|
|
13
|
+
app.config.spree.payment_methods << Spree::PaymentMethod::CodPayment
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
app.config.spree_admin.shipping_method_form_partials << 'spree/admin/shipping_methods/cod_form'
|
16
|
+
|
17
|
+
Spree::PermittedAttributes.shipping_method_attributes << :cod
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.activate
|
21
|
-
Dir.glob(File.join(File.dirname(__FILE__), '../../app
|
22
|
-
Rails.
|
21
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
22
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
config.to_prepare(&method(:activate).to_proc)
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module SpreeCodPayment
|
2
|
-
VERSION = '
|
2
|
+
VERSION = '2.0.1'.freeze
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# Returns the version of the currently loaded SpreeCodPayment as a
|
7
|
-
# <tt>Gem::Version</tt>.
|
8
|
-
def version
|
9
|
-
Gem::Version.new VERSION
|
4
|
+
def gem_version
|
5
|
+
Gem::Version.new(VERSION)
|
10
6
|
end
|
11
7
|
end
|
data/lib/spree_cod_payment.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_cod_payment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OlympusOne
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: spree
|
@@ -16,28 +15,42 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
18
|
+
version: 5.0.4
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
25
|
+
version: 5.0.4
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
27
|
+
name: spree_storefront
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
32
|
+
version: 5.0.4
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
39
|
+
version: 5.0.4
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: spree_admin
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.0.4
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 5.0.4
|
41
54
|
- !ruby/object:Gem::Dependency
|
42
55
|
name: spree_extension
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,48 +79,41 @@ dependencies:
|
|
66
79
|
- - ">="
|
67
80
|
- !ruby/object:Gem::Version
|
68
81
|
version: '0'
|
69
|
-
description:
|
82
|
+
description: Adds Cash on Delivery (COD) payment method to Spree stores.
|
70
83
|
email: info@olympusone.com
|
71
84
|
executables: []
|
72
85
|
extensions: []
|
73
86
|
extra_rdoc_files: []
|
74
87
|
files:
|
75
|
-
-
|
76
|
-
- ".rspec"
|
77
|
-
- ".rubocop.yml"
|
78
|
-
- ".travis.yml"
|
79
|
-
- CONTRIBUTING.md
|
80
|
-
- Gemfile
|
81
|
-
- LICENSE
|
88
|
+
- LICENSE.md
|
82
89
|
- README.md
|
83
90
|
- Rakefile
|
84
|
-
- app/assets/.gitkeep
|
85
|
-
- app/controllers/.gitkeep
|
86
|
-
- app/helpers/.gitkeep
|
87
|
-
- app/models/spree/order_decorator.rb
|
88
|
-
- app/models/spree/payment_decorator.rb
|
89
91
|
- app/models/spree/payment_method/cod_payment.rb
|
90
|
-
- app/models/spree/payment_method_decorator.rb
|
91
|
-
- app/
|
92
|
-
- app/
|
93
|
-
- app/serializers/.gitkeep
|
94
|
-
- app/services/.gitkeep
|
92
|
+
- app/models/spree/payment_method/payment_method_decorator.rb
|
93
|
+
- app/views/spree/admin/payment_methods/_cod_payment.html.erb
|
94
|
+
- app/views/spree/admin/payment_methods/descriptions/_cod_payment.html.erb
|
95
95
|
- app/views/spree/admin/payments/source_views/_cod_payment.html.erb
|
96
|
-
-
|
96
|
+
- app/views/spree/admin/shipping_methods/_cod_form.html.erb
|
97
|
+
- app/views/spree/admin/spree/checkout/payment/_cod_payment.html.erb
|
98
|
+
- app/views/spree/checkout/payment/_cod_payment.html.erb
|
97
99
|
- config/locales/el.yml
|
98
100
|
- config/locales/en.yml
|
99
101
|
- config/routes.rb
|
102
|
+
- db/migrate/20250601165042_add_cod_fee_to_shipping_methods.rb
|
100
103
|
- lib/generators/spree_cod_payment/install/install_generator.rb
|
101
104
|
- lib/spree_cod_payment.rb
|
102
105
|
- lib/spree_cod_payment/engine.rb
|
103
106
|
- lib/spree_cod_payment/factories.rb
|
104
107
|
- lib/spree_cod_payment/version.rb
|
105
|
-
- spree_cod_payment.gemspec
|
106
108
|
homepage: https://github.com/olympusone/spree_cod_payment
|
107
109
|
licenses:
|
108
110
|
- MIT
|
109
|
-
metadata:
|
110
|
-
|
111
|
+
metadata:
|
112
|
+
bug_tracker_uri: https://github.com/olympusone/spree_cod_payment/issues
|
113
|
+
changelog_uri: https://github.com/olympusone/spree_cod_payment/releases/tag/v2.0.1
|
114
|
+
documentation_uri: https://github.com/olympusone/spree_cod_payment
|
115
|
+
homepage_uri: https://github.com/olympusone/spree_cod_payment
|
116
|
+
source_code_uri: https://github.com/olympusone/spree_cod_payment/tree/v2.0.1
|
111
117
|
rdoc_options: []
|
112
118
|
require_paths:
|
113
119
|
- lib
|
@@ -115,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
121
|
requirements:
|
116
122
|
- - ">="
|
117
123
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
124
|
+
version: '3.0'
|
119
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
126
|
requirements:
|
121
127
|
- - ">="
|
@@ -123,8 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
129
|
version: '0'
|
124
130
|
requirements:
|
125
131
|
- none
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
132
|
+
rubygems_version: 3.6.9
|
128
133
|
specification_version: 4
|
129
|
-
summary: Spree Cash On Delivery Payment
|
134
|
+
summary: Spree Commerce Cash On Delivery Payment Extension
|
130
135
|
test_files: []
|
data/.gitignore
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
\#*
|
2
|
-
*~
|
3
|
-
.#*
|
4
|
-
.DS_Store
|
5
|
-
.idea
|
6
|
-
.localeapp/locales
|
7
|
-
.project
|
8
|
-
.vscode
|
9
|
-
coverage
|
10
|
-
default
|
11
|
-
Gemfile.lock
|
12
|
-
tmp
|
13
|
-
nbproject
|
14
|
-
pkg
|
15
|
-
*.sw?
|
16
|
-
spec/dummy
|
17
|
-
.rvmrc
|
18
|
-
.sass-cache
|
19
|
-
public/spree
|
20
|
-
.ruby-version
|
21
|
-
.ruby-gemset
|
22
|
-
*.gem
|
23
|
-
*/*.gem
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
DisplayCopNames: true
|
3
|
-
TargetRubyVersion: 2.5
|
4
|
-
Include:
|
5
|
-
- '**/Gemfile'
|
6
|
-
- '**/Rakefile'
|
7
|
-
- '**/Appraisals'
|
8
|
-
Exclude:
|
9
|
-
- 'spec/dummy/**/*'
|
10
|
-
- 'lib/generators/**/*'
|
11
|
-
|
12
|
-
Rails:
|
13
|
-
Enabled: true
|
14
|
-
|
15
|
-
Metrics/LineLength:
|
16
|
-
Max: 150
|
17
|
-
|
18
|
-
# DISABLED
|
19
|
-
|
20
|
-
Style/Documentation:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Style/FrozenStringLiteralComment:
|
24
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
os: linux
|
2
|
-
dist: bionic
|
3
|
-
|
4
|
-
addons:
|
5
|
-
apt:
|
6
|
-
sources:
|
7
|
-
- google-chrome
|
8
|
-
packages:
|
9
|
-
- google-chrome-stable
|
10
|
-
|
11
|
-
services:
|
12
|
-
- mysql
|
13
|
-
- postgresql
|
14
|
-
|
15
|
-
language: ruby
|
16
|
-
|
17
|
-
rvm:
|
18
|
-
- 2.7
|
19
|
-
- 3.0
|
20
|
-
|
21
|
-
env:
|
22
|
-
- DB=mysql
|
23
|
-
- DB=postgres
|
24
|
-
|
25
|
-
before_install:
|
26
|
-
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
27
|
-
|
28
|
-
before_script:
|
29
|
-
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
|
30
|
-
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
|
31
|
-
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
|
32
|
-
- unzip chromedriver_linux64.zip -d ~/bin
|
33
|
-
- nvm install 14
|
34
|
-
|
35
|
-
script:
|
36
|
-
- bundle exec rake test_app
|
37
|
-
- bundle exec rspec
|
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
git_source(:github) do |repo_name|
|
4
|
-
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
5
|
-
"https://github.com/#{repo_name}.git"
|
6
|
-
end
|
7
|
-
|
8
|
-
spree_opts = '~> 4.3.2'
|
9
|
-
gem 'spree', spree_opts
|
10
|
-
gem 'spree_backend', spree_opts
|
11
|
-
gem 'rails-controller-testing'
|
12
|
-
|
13
|
-
gemspec
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2025 OlympusOne
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
data/app/helpers/.gitkeep
DELETED
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Spree::OrderDecorator
|
2
|
-
def self.prepended(base)
|
3
|
-
base.has_many :payment_adjustments, through: :payments, source: :adjustments
|
4
|
-
end
|
5
|
-
|
6
|
-
def cod_payment?
|
7
|
-
return false unless ship_address.country_iso == 'GR'
|
8
|
-
|
9
|
-
payments.where.not(state: ['failed', 'void'])
|
10
|
-
.map { |m| m.payment_method.type }
|
11
|
-
.include?("Spree::PaymentMethod::CodPayment")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
::Spree::Order.prepend(Spree::OrderDecorator)
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Spree::PaymentDecorator
|
2
|
-
def self.prepended(base)
|
3
|
-
base.has_one :adjustment, as: :source, dependent: :destroy
|
4
|
-
|
5
|
-
base.after_create :set_adjustment
|
6
|
-
base.before_update :update_adjustment
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def set_adjustment
|
12
|
-
if payment_method.type == "Spree::PaymentMethod::CodPayment" && payment_method.charge && order.ship_address.country_iso == 'GR'
|
13
|
-
label = I18n.t('cod_payment.charge_label')
|
14
|
-
|
15
|
-
build_adjustment(
|
16
|
-
amount: payment_method.charge,
|
17
|
-
label: label,
|
18
|
-
order: order,
|
19
|
-
included: false,
|
20
|
-
state: 'closed',
|
21
|
-
adjustable: order
|
22
|
-
)
|
23
|
-
|
24
|
-
adjustment.save
|
25
|
-
|
26
|
-
order.update_totals
|
27
|
-
order.persist_totals
|
28
|
-
|
29
|
-
update_columns(
|
30
|
-
amount: order.total,
|
31
|
-
updated_at: Time.current
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def update_adjustment
|
37
|
-
if payment_method.type == "Spree::PaymentMethod::CodPayment" && (void? || invalid?) && adjustment && order.ship_address.country_iso == 'GR'
|
38
|
-
adjustment.update(eligible: false)
|
39
|
-
|
40
|
-
order.update_totals
|
41
|
-
order.persist_totals
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
::Spree::Payment.prepend(Spree::PaymentDecorator)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Spree::ShipmentDecorator
|
2
|
-
def determine_state(order)
|
3
|
-
return 'ready' if cod_payment? && !shipped?
|
4
|
-
|
5
|
-
return 'canceled' if order.canceled?
|
6
|
-
return 'pending' unless order.can_ship?
|
7
|
-
return 'pending' if inventory_units.any? &:backordered?
|
8
|
-
return 'shipped' if shipped?
|
9
|
-
|
10
|
-
return order.paid? || Spree::Config[:auto_capture_on_dispatch] ? 'ready' : 'pending'
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def cod_payment?
|
15
|
-
return false unless order.ship_address.country_iso == 'GR'
|
16
|
-
|
17
|
-
order.payments.any? do |payment|
|
18
|
-
payment.payment_method.type == "Spree::PaymentMethod::CodPayment" && !payment.void?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
::Spree::Shipment.prepend(Spree::ShipmentDecorator)
|
@@ -1,8 +0,0 @@
|
|
1
|
-
module SpreeCodPayment
|
2
|
-
class Configuration < Spree::Preferences::Configuration
|
3
|
-
# Some example preferences are shown below, for more information visit:
|
4
|
-
# https://guides.spreecommerce.org/developer/core/preferences.html
|
5
|
-
|
6
|
-
# preference :cod_payment_charge, :decimal
|
7
|
-
end
|
8
|
-
end
|
data/app/serializers/.gitkeep
DELETED
File without changes
|
data/app/services/.gitkeep
DELETED
File without changes
|
data/bin/rails
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" from the root of your extension
|
3
|
-
|
4
|
-
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
-
ENGINE_PATH = File.expand_path('../../lib/spree_cod_payment/engine', __FILE__)
|
6
|
-
|
7
|
-
require 'rails/all'
|
8
|
-
require 'rails/engine/commands'
|
data/spree_cod_payment.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
lib = File.expand_path('../lib/', __FILE__)
|
3
|
-
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
require 'spree_cod_payment/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.name = 'spree_cod_payment'
|
10
|
-
s.version = SpreeCodPayment.version
|
11
|
-
s.summary = 'Spree Cash On Delivery Payment'
|
12
|
-
s.description = ''
|
13
|
-
s.required_ruby_version = '>= 2.5'
|
14
|
-
|
15
|
-
s.author = 'OlympusOne'
|
16
|
-
s.email = 'info@olympusone.com'
|
17
|
-
s.homepage = 'https://github.com/olympusone/spree_cod_payment'
|
18
|
-
s.license = 'MIT'
|
19
|
-
|
20
|
-
s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
21
|
-
s.require_path = 'lib'
|
22
|
-
s.requirements << 'none'
|
23
|
-
|
24
|
-
spree_version = '>= 4.3.2'
|
25
|
-
s.add_dependency 'spree', spree_version
|
26
|
-
s.add_dependency 'spree_backend', spree_version
|
27
|
-
s.add_dependency 'spree_extension'
|
28
|
-
|
29
|
-
s.add_development_dependency 'spree_dev_tools'
|
30
|
-
end
|
File without changes
|
/data/app/{assets/.gitkeep → views/spree/admin/payment_methods/descriptions/_cod_payment.html.erb}
RENAMED
File without changes
|
/data/app/{controllers/.gitkeep → views/spree/admin/spree/checkout/payment/_cod_payment.html.erb}
RENAMED
File without changes
|