From da5a35b6ea71f873dcd2c41793b7af04f27cd87f Mon Sep 17 00:00:00 2001 From: Simon Fry Date: Thu, 7 Jan 2016 14:43:33 +0000 Subject: [PATCH] Divide using float so we don't floor the result and lose the cents in the refund amount. --- app/models/spree/adyen/notification_processor.rb | 2 +- spec/models/spree/adyen/notification_processor_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/spree/adyen/notification_processor.rb b/app/models/spree/adyen/notification_processor.rb index 44e93e7f..74308d4b 100644 --- a/app/models/spree/adyen/notification_processor.rb +++ b/app/models/spree/adyen/notification_processor.rb @@ -77,7 +77,7 @@ def handle_modification_event elsif notification.refund? payment.refunds.create!( - amount: notification.value / 100, # cents to dollars + amount: notification.value / 100.0, # cents to dollars transaction_id: notification.psp_reference, refund_reason_id: ::Spree::RefundReason.first.id # FIXME ) diff --git a/spec/models/spree/adyen/notification_processor_spec.rb b/spec/models/spree/adyen/notification_processor_spec.rb index 159617f9..9c1968f8 100644 --- a/spec/models/spree/adyen/notification_processor_spec.rb +++ b/spec/models/spree/adyen/notification_processor_spec.rb @@ -200,6 +200,11 @@ from(0). to(1) end + + it "creates a refund of the correct value" do + subject + expect(payment.reload.refunds.last.amount).to eq 23.99 + end end context "when refunded from Solidus" do