Skip to content

Commit

Permalink
move add_history_entry to record_payment and refund_payment
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Oct 28, 2024
1 parent 3506531 commit ac09a7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions app/models/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit ac09a7a

Please sign in to comment.