From f33aec2f48cc46cd4d80c6f6cfaf468c9005ff1a Mon Sep 17 00:00:00 2001 From: camelmasa Date: Fri, 8 Apr 2016 13:09:26 +0900 Subject: [PATCH 1/2] Remove cents_to_dollar method The `credit` method's third argument is not Hash for gateway options. Currency is nil everytime now. That's "Hash" but included Refund instance. https://github.com/spree/spree/blob/master/core/app/models/spree/refund.rb#L58-L60 --- app/models/spree/gateway/komoju_credit_card.rb | 7 ------- spec/models/spree/gateway/komoju_credit_card_spec.rb | 7 ------- 2 files changed, 14 deletions(-) diff --git a/app/models/spree/gateway/komoju_credit_card.rb b/app/models/spree/gateway/komoju_credit_card.rb index f72f6b8..6f3bba0 100644 --- a/app/models/spree/gateway/komoju_credit_card.rb +++ b/app/models/spree/gateway/komoju_credit_card.rb @@ -5,7 +5,6 @@ def auto_capture? end def credit(money, source, response_code, gateway_options) - money = cents_to_dollar(money) if gateway_options[:currency] == "JPY" provider.refund(money, response_code, {}) end @@ -54,11 +53,5 @@ def create_profile(payment) def payment_profiles_supported? true end - - private - - def cents_to_dollar(amount) - amount / 100.0 - end end end diff --git a/spec/models/spree/gateway/komoju_credit_card_spec.rb b/spec/models/spree/gateway/komoju_credit_card_spec.rb index 5c8b55b..89d2d1f 100644 --- a/spec/models/spree/gateway/komoju_credit_card_spec.rb +++ b/spec/models/spree/gateway/komoju_credit_card_spec.rb @@ -58,13 +58,6 @@ expect(komoju_gateway).to receive(:refund).with(cent_amount, response_code, {}) subject.credit(cent_amount, source, response_code, {}) end - - context "when currency is JPY" do - it "receives dollar amount" do - expect(komoju_gateway).to receive(:refund).with(100.0, response_code, {}) - subject.credit(cent_amount, source, response_code, {currency: "JPY"}) - end - end end describe "#void" do From 9f6d8459393a988fbb5cec28cf8260f35e6e724b Mon Sep 17 00:00:00 2001 From: camelmasa Date: Fri, 8 Apr 2016 13:24:08 +0900 Subject: [PATCH 2/2] Rename incorrect variable name --- app/models/spree/gateway/komoju_credit_card.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/gateway/komoju_credit_card.rb b/app/models/spree/gateway/komoju_credit_card.rb index 6f3bba0..b33b923 100644 --- a/app/models/spree/gateway/komoju_credit_card.rb +++ b/app/models/spree/gateway/komoju_credit_card.rb @@ -4,7 +4,7 @@ def auto_capture? true end - def credit(money, source, response_code, gateway_options) + def credit(money, source, response_code, refund_options) provider.refund(money, response_code, {}) end