fix: Minor fixes and cleanup to the payments setup (#11356)

This PR adds a couple new statuses to the payment collection and payment webhook results. The payment collection will now be marked as "completed" once the captured amount is the full amount of the payment collection.

There are several things left to improve the payment setup, so non-happy-path cases are handled correctly.
1. Currently the payment session and payment models serve a very similar purpose. Part of the information is found on one, and the other part on the other model, without any clear reason for doing so. We can simplify the payment module and the data models simply by merging the two.
2. We need to handle failures more gracefully, such as setting the payment session status to failed when such a webhook comes in.
3. We should convert the payment collection status and the different amounts to calculated fields from the payment session, captures, and refunds, as they can easily be a source of inconsistencies.
This commit is contained in:
Stevche Radevski
2025-02-09 15:42:02 +00:00
committed by GitHub
parent 3dbef519d9
commit 702d338284
17 changed files with 344 additions and 262 deletions
@@ -38,4 +38,6 @@ export const capturePaymentStep = createStep(
return new StepResponse(payment)
}
// We don't want to compensate a capture automatically as the actual funds have already been taken.
// The only want to compensate here is to issue a refund, but it's better to leave that as a manual operation for now.
)
@@ -38,4 +38,6 @@ export const refundPaymentStep = createStep(
return new StepResponse(payment)
}
// We don't want to compensate a refund automatically as the actual funds have already been sent
// And in most cases we can't simply do another capture/authorization
)