Skip to content

Commit da5a35b

Browse files
author
Simon Fry
committed
Divide using float so we don't floor the result and lose the cents in the refund amount.
1 parent 037b218 commit da5a35b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/models/spree/adyen/notification_processor.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def handle_modification_event
7777

7878
elsif notification.refund?
7979
payment.refunds.create!(
80-
amount: notification.value / 100, # cents to dollars
80+
amount: notification.value / 100.0, # cents to dollars
8181
transaction_id: notification.psp_reference,
8282
refund_reason_id: ::Spree::RefundReason.first.id # FIXME
8383
)

spec/models/spree/adyen/notification_processor_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@
200200
from(0).
201201
to(1)
202202
end
203+
204+
it "creates a refund of the correct value" do
205+
subject
206+
expect(payment.reload.refunds.last.amount).to eq 23.99
207+
end
203208
end
204209

205210
context "when refunded from Solidus" do

0 commit comments

Comments
 (0)