spree_komoju 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ea64674cab50e80b6043ca43be33c0a6023bbce
4
- data.tar.gz: 0231d2c6bcab54d3286df056ebcc6ddc2ed4667a
3
+ metadata.gz: fab6019e2802d287ff898d2d70594e9f46a6fac3
4
+ data.tar.gz: 1ed0ae676b5a76cc97f46ae004f0ffaa56ea7789
5
5
  SHA512:
6
- metadata.gz: 9f63a3887afaa56661a5c029cc08d3c53473ad8fd7ed7af4d1f19ee22f429a95a21b1f2a1486e15aeb8ccd5fb7b004629194c57e58310a3a3446c147add78946
7
- data.tar.gz: 3fe280708bdb7b80d18d172f95d744b16e50a186ff1cb489ede01aec1b458444e12e8c35f48ceecb1322a57c8a29adaeccf833411acc40fc2509cd03cd3b0cad
6
+ metadata.gz: d7a6d1fc42a4bbd4aaee6824aa6fc2ba2a4e8ccc9f1331cdc4f420886ab4034e4c8c9f3570cb9b112fcd3804e983a97e8a44c3b7eb6a2c911ea5e5a01be8613d
7
+ data.tar.gz: 61c9167f7503d82ebad69619ad138af3a90728320e07628d82ca5ac3dcad350e1a4d17f2c32c375ba8229a244243840f7ced248e22418b33db6b85004fa68c58
@@ -22,5 +22,9 @@ module Spree
22
22
  def instructions_partial_path
23
23
  "spree/orders/bank_transfer"
24
24
  end
25
+
26
+ def imported
27
+ false
28
+ end
25
29
  end
26
30
  end
@@ -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
@@ -37,5 +37,9 @@ module Spree
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ def payment_profiles_supported?
42
+ true
43
+ end
40
44
  end
41
45
  end
@@ -15,17 +15,13 @@ module Spree
15
15
  end
16
16
 
17
17
  def payment_profiles_supported?
18
- true
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
- Thank you for your order. Instructions have been sent to your e-mail address.<br>
3
- <br>
4
- <h4>Banktransfer ID: <%= source.order_id %></h4>
5
- The Banktransfer ID is very important! Please make a note of it and bring it with you when you go to pay at the ATM.<br>
6
- If you have chosen to use bank transfer payment, please use a bank transfer form which your bank offers, or please remit at ATM.<br>
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
- Please make sure to include your banktransfer ID in the payer's name. Please enter your banktransfer ID shown in this email in front of your name as Payer when remitting.<br>
9
- Please see the confirmation email for further payment instructions.
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>
@@ -0,0 +1,5 @@
1
+ class AddSpreeBankTransfersInstructionUrl < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_bank_transfers, :instructions_url, :string
4
+ end
5
+ end
@@ -75,6 +75,8 @@ module ActiveMerchant #:nodoc:
75
75
  else
76
76
  post[:customer] = payment
77
77
  end
78
+ else
79
+ post[:payment_details] = payment
78
80
  end
79
81
  end
80
82
 
@@ -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
- let(:params) { { "payment_deadline" => Time.now.iso8601.to_s, "payment_details" => { "order_id" => "order_id", "bank_transfer" => "bank_transfer" } } }
31
- let(:response) { double(ActiveMerchant::Billing::Response, params: params) }
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 "with currency is USD" do
38
- let(:currency) { "USD" }
46
+ context 'when response is successful' do
47
+ let(:response) { double(ActiveMerchant::Billing::Response, params: params, success?: true) }
39
48
 
40
- it "calls ActiveMerchant::Billing::KomojuGateway#purchase with original options" do
41
- expect_any_instance_of(ActiveMerchant::Billing::KomojuGateway).to receive(:purchase).with(800.0, details, options) { response }
49
+ context 'when currency is JPY' do
50
+ let(:currency) { "JPY" }
42
51
 
43
- subject.authorize(money, source, options)
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 "with currency is JPY" do
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 "calls ActiveMerchant::Billing::KomojuGateway#purchase with options converted from cents to dollars" do
51
- options_converted_to_dollars = { login: "api_key", shipping: 1.0, tax: 2.0, subtotal: 8.0, discount: 1.0,
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.4'
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
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-07 00:00:00.000000000 Z
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/20151126050103_add_gateway_profile_ids_to_spree_konbinis.rb
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
@@ -1,6 +0,0 @@
1
- class AddGatewayProfileIdsToSpreeKonbinis < ActiveRecord::Migration
2
- def change
3
- add_column :spree_konbinis, :gateway_customer_profile_id, :string
4
- add_column :spree_konbinis, :gateway_payment_profile_id, :string
5
- end
6
- end