From ac09a7ae88bb2b20106f4d31ac62727761820069 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Mon, 28 Oct 2024 16:24:40 +0100 Subject: [PATCH] move add_history_entry to record_payment and refund_payment --- app/controllers/registrations_controller.rb | 3 --- app/models/registration.rb | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 66bbf7d2ac..4e52b7b162 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -545,7 +545,6 @@ def stripe_webhook # and Stripe tries again after an exponential backoff. So we (erroneously!) record the creation timestamp # in our DB _after_ the backed-off event has been processed. This can lead to a wrong registration order :( stored_payment.update!(created_at: audit_event.created_at_remote) - stored_intent.holder.add_history_entry({ payment_status: stored_intent.wca_status, iso_amount: ruby_money.cents }, "stripe_webhook", audit_event.id, 'Payment') elsif stored_intent.holder.is_a? MicroserviceRegistration ruby_money = charge_transaction.money_amount begin @@ -622,7 +621,6 @@ def payment_completion charge_transaction, current_user.id, ) - registration.add_history_entry({ payment_status: stored_intent.wca_status, iso_amount: ruby_money.cents }, "user", current_user.id, 'Payment') end # Running in sync mode, so if the code reaches this point we're reasonably confident that the time the Stripe payment @@ -748,7 +746,6 @@ def refund_payment payment_record.registration_payment.id, current_user.id, ) - registration.add_history_entry({ payment_status: "refund", iso_amount: amount_left }, "user", current_user.id, 'Refund') end flash[:success] = 'Payment was refunded' diff --git a/app/models/registration.rb b/app/models/registration.rb index 6144a42b76..1806caf9c6 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -173,6 +173,7 @@ def record_payment( receipt: receipt, user_id: user_id, ) + add_history_entry({ payment_status: receipt.wca_status, iso_amount: amount_lowest_denomination }, "user", user_id, 'Payment') end def record_refund( @@ -189,6 +190,7 @@ def record_refund( refunded_registration_payment_id: refunded_registration_payment_id, user_id: user_id, ) + add_history_entry({ payment_status: "refund", iso_amount: paid_entry_fees.cents - amount_lowest_denomination }, "user", user_id, 'Refund') end # Since Registration.events only includes saved events