WIP Process payments for expired invoices

This commit is contained in:
2025-01-02 08:42:33 -05:00
parent 7df56479a4
commit aca13a25c3
2 changed files with 27 additions and 13 deletions

View File

@@ -84,21 +84,26 @@ class Contributions::DonationsController < ApplicationController
@donation.paid_at = DateTime.now
@donation.payment_status = "settled"
@donation.save!
flash_message = { success: "Thank you!" }
msg = { success: "Thank you!" }
when "Processing"
unless @donation.processing?
@donation.payment_status = "processing"
@donation.save!
flash_message = { success: "Thank you! We will send you an email when the payment is confirmed." }
msg = { success: "Thank you! We will send you an email when the payment is confirmed." }
BtcpayCheckDonationJob.set(wait: 20.seconds).perform_later(@donation)
end
when "Expired"
flash_message = { warning: "The payment request for this donation has expired" }
if invoice["additionalStatus"] &&
invoice["additionalStatus"] == "PaidLate"
# TODO introduce state machine
mark_as_paid(donation)
end
msg = { warning: "The payment request for this donation has expired" }
else
flash_message = { warning: "Could not determine status of payment" }
msg = { warning: "Could not determine status of payment" }
end
redirect_to contributions_donations_url, flash: flash_message
redirect_to contributions_donations_url, flash: msg
end
private