spree_komoju 0.0.4 → 0.0.5
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/app/models/spree/bank_transfer.rb +4 -0
- data/app/models/spree/gateway/komoju_bank_transfer.rb +3 -2
- data/app/models/spree/gateway/komoju_credit_card.rb +4 -0
- data/app/models/spree/komoju_gateway.rb +1 -5
- data/app/views/spree/orders/_bank_transfer.html.erb +15 -7
- data/db/migrate/20151207084412_add_spree_bank_transfers_instruction_url.rb +5 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +2 -0
- data/spec/models/spree/gateway/komoju_bank_transfer_spec.rb +47 -15
- data/spree_komoju.gemspec +2 -2
- metadata +4 -3
- data/db/migrate/20151126050103_add_gateway_profile_ids_to_spree_konbinis.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fab6019e2802d287ff898d2d70594e9f46a6fac3
|
4
|
+
data.tar.gz: 1ed0ae676b5a76cc97f46ae004f0ffaa56ea7789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7a6d1fc42a4bbd4aaee6824aa6fc2ba2a4e8ccc9f1331cdc4f420886ab4034e4c8c9f3570cb9b112fcd3804e983a97e8a44c3b7eb6a2c911ea5e5a01be8613d
|
7
|
+
data.tar.gz: 61c9167f7503d82ebad69619ad138af3a90728320e07628d82ca5ac3dcad350e1a4d17f2c32c375ba8229a244243840f7ced248e22418b33db6b85004fa68c58
|
@@ -17,8 +17,9 @@ module Spree
|
|
17
17
|
source.update!(
|
18
18
|
expires_at: response.params["payment_deadline"].to_time,
|
19
19
|
order_id: response.params["payment_details"]["order_id"],
|
20
|
-
bank_number: response.params["payment_details"]["bank_number"]
|
21
|
-
|
20
|
+
bank_number: response.params["payment_details"]["bank_number"],
|
21
|
+
instructions_url: response.params["payment_details"]["instructions_url"]
|
22
|
+
) if response.success?
|
22
23
|
response
|
23
24
|
end
|
24
25
|
end
|
@@ -15,17 +15,13 @@ module Spree
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def payment_profiles_supported?
|
18
|
-
|
18
|
+
false
|
19
19
|
end
|
20
20
|
|
21
21
|
def supports?(source)
|
22
22
|
true
|
23
23
|
end
|
24
24
|
|
25
|
-
# no-op, override where necessary
|
26
|
-
def create_profile(payment)
|
27
|
-
end
|
28
|
-
|
29
25
|
# We need to change shipping, tax, subtotal and discount from cents to dollar for Komoju gateway.
|
30
26
|
# Because, Komoju gateway supports JPY currency only.
|
31
27
|
#
|
@@ -1,10 +1,18 @@
|
|
1
1
|
<div>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
<p>
|
3
|
+
Thank you for your order. Instructions have been sent to your e-mail address.<br/>
|
4
|
+
You can find a link with instructions on how to pay below:
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<%= link_to source.instructions_url do %>
|
8
|
+
How to make a bank transfer payment
|
9
|
+
<% end %>
|
10
|
+
</div>
|
7
11
|
<br>
|
8
|
-
|
9
|
-
|
12
|
+
|
13
|
+
<div class='alert alert-info' role='alert'>
|
14
|
+
<h4>Order ID</h4>
|
15
|
+
<p><%= source.order_id %></p>
|
16
|
+
<h4>End Date</h4>
|
17
|
+
<p><%= source.expires_at %></p>
|
10
18
|
</div>
|
@@ -5,6 +5,7 @@ describe Spree::Gateway::KomojuBankTransfer, type: :model do
|
|
5
5
|
|
6
6
|
describe "#authorize" do
|
7
7
|
let(:money) { 1000.0 }
|
8
|
+
let(:currency) { "JPY" }
|
8
9
|
let(:source) do
|
9
10
|
Spree::BankTransfer.create!(
|
10
11
|
email: "email",
|
@@ -14,8 +15,7 @@ describe Spree::Gateway::KomojuBankTransfer, type: :model do
|
|
14
15
|
family_name_kana: "family_name_kana"
|
15
16
|
)
|
16
17
|
end
|
17
|
-
let(:options) { { login: "api_key", shipping: 100.0, tax: 200.0, subtotal: 800.0, discount: 100.0,
|
18
|
-
currency: currency } }
|
18
|
+
let(:options) { { login: "api_key", shipping: 100.0, tax: 200.0, subtotal: 800.0, discount: 100.0, currency: currency } }
|
19
19
|
let(:details) do
|
20
20
|
{
|
21
21
|
type: "bank_transfer",
|
@@ -27,32 +27,64 @@ describe Spree::Gateway::KomojuBankTransfer, type: :model do
|
|
27
27
|
family_name_kana: "family_name_kana"
|
28
28
|
}
|
29
29
|
end
|
30
|
-
|
31
|
-
let(:
|
30
|
+
|
31
|
+
let(:params) do
|
32
|
+
{
|
33
|
+
"payment_deadline" => Time.now.iso8601.to_s,
|
34
|
+
"payment_details" => {
|
35
|
+
"order_id" => "order_id",
|
36
|
+
"bank_number" => "bank_number",
|
37
|
+
"instructions_url" => "instructions_url"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
32
41
|
|
33
42
|
before do
|
34
43
|
allow_any_instance_of(Spree::Gateway::KomojuBankTransfer).to receive(:options) { options }
|
35
44
|
end
|
36
45
|
|
37
|
-
context
|
38
|
-
let(:
|
46
|
+
context 'when response is successful' do
|
47
|
+
let(:response) { double(ActiveMerchant::Billing::Response, params: params, success?: true) }
|
39
48
|
|
40
|
-
|
41
|
-
|
49
|
+
context 'when currency is JPY' do
|
50
|
+
let(:currency) { "JPY" }
|
42
51
|
|
43
|
-
|
52
|
+
it 'updates the source payment' do
|
53
|
+
expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase) { response }
|
54
|
+
|
55
|
+
subject.authorize(money, source, options)
|
56
|
+
expect(source.order_id).to eq("order_id")
|
57
|
+
expect(source.instructions_url).to eq("instructions_url")
|
58
|
+
expect(source.bank_number).to eq("bank_number")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "creates a payment with correct active merchant options" do
|
62
|
+
options_converted_to_dollars = { login: "api_key", shipping: 1.0, tax: 2.0, subtotal: 8.0, discount: 1.0, currency: currency }
|
63
|
+
expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase).with(998.0, details, options_converted_to_dollars) { response }
|
64
|
+
|
65
|
+
subject.authorize(money, source, options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when currency is USD" do
|
70
|
+
let(:currency) { "USD" }
|
71
|
+
|
72
|
+
it "creates a payment with correct active merchant options" do
|
73
|
+
expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase).with(800.0, details, options) { response }
|
74
|
+
|
75
|
+
subject.authorize(money, source, options)
|
76
|
+
end
|
44
77
|
end
|
45
78
|
end
|
46
79
|
|
47
|
-
context
|
80
|
+
context 'when response is not successful' do
|
81
|
+
let(:response) { double(ActiveMerchant::Billing::Response, params: params, success?: false) }
|
48
82
|
let(:currency) { "JPY" }
|
49
83
|
|
50
|
-
it
|
51
|
-
|
52
|
-
currency: currency }
|
53
|
-
expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase).with(998.0, details, options_converted_to_dollars) { response }
|
54
|
-
|
84
|
+
it 'does not update the source' do
|
85
|
+
expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase) { response }
|
55
86
|
subject.authorize(money, source, options)
|
87
|
+
expect(source.instructions_url).to be_nil
|
56
88
|
end
|
57
89
|
end
|
58
90
|
end
|
data/spree_komoju.gemspec
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
4
4
|
s.name = 'spree_komoju'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.5'
|
6
6
|
s.summary = 'Spree Komoju Payment Gateway'
|
7
7
|
s.description = 'Spree Payment gateway for Komoju payment gateway'
|
8
|
-
s.authors = ['Masahiro Saito', 'Chris Salzberg']
|
8
|
+
s.authors = ['Masahiro Saito', 'Chris Salzberg', 'Richard Ramsden']
|
9
9
|
s.required_ruby_version = '>= 2.0.0'
|
10
10
|
|
11
11
|
# s.author = 'You'
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_komoju
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Saito
|
8
8
|
- Chris Salzberg
|
9
|
+
- Richard Ramsden
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
13
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: spree_core
|
@@ -202,7 +203,7 @@ files:
|
|
202
203
|
- config/routes.rb
|
203
204
|
- db/migrate/20150331051027_create_spree_konbinis.rb
|
204
205
|
- db/migrate/20150401074721_create_spree_bank_transfers.rb
|
205
|
-
- db/migrate/
|
206
|
+
- db/migrate/20151207084412_add_spree_bank_transfers_instruction_url.rb
|
206
207
|
- lib/active_merchant/billing/gateways/komoju.rb
|
207
208
|
- lib/generators/spree_komoju/install/images/circle-k.png
|
208
209
|
- lib/generators/spree_komoju/install/images/daily-yamazaki.png
|