1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

fix PayZen::Service#find_transaction_by_payment_schedule_item

This commit is contained in:
Nicolas Florentin 2023-12-01 16:45:14 +01:00
parent 038c7d8efc
commit 736e42f565
2 changed files with 7 additions and 2 deletions

View File

@ -149,9 +149,10 @@ class PayZen::Service < Payment::Service
due_date = payment_schedule_item.due_date.to_date
transactions.find do |tr|
expected_capture_date = Time.zone.parse(tr["transactionDetails"]["paymentMethodDetails"]["expectedCaptureDate"]).to_date
next unless tr["operationType"] == "DEBIT"
(tr["operationType"] == "DEBIT") && (expected_capture_date.between?(due_date - 1.day, due_date + 1.day))
expected_capture_date = Time.zone.parse(tr["transactionDetails"]["paymentMethodDetails"]["expectedCaptureDate"]).to_date
expected_capture_date.between?(due_date - 1.day, due_date + 1.day)
end
end

View File

@ -74,5 +74,9 @@ class PayZen::ServiceTest < ActiveSupport::TestCase
transactions = [format_transaction(operation_type: "CREDIT", expected_capture_date: expected_capture_date)]
assert_nil @service.find_transaction_by_payment_schedule_item(transactions, payment_schedule_item)
transactions = [format_transaction(operation_type: "VERIFICATION", expected_capture_date: nil)]
assert_nil @service.find_transaction_by_payment_schedule_item(transactions, payment_schedule_item)
end
end