Move pending payment check above subscription checks.

This commit is contained in:
Alex Hart
2025-09-12 11:17:47 -03:00
parent 60df7502ee
commit b2e3d7ba20

View File

@@ -118,6 +118,8 @@ class InAppPaymentKeepAliveJob private constructor(
return
}
clearOldPendingPaymentsIfRequired()
if (SignalDatabase.inAppPayments.hasPrePendingRecurringTransaction(type.inAppPaymentType)) {
info(type, "We are currently processing a transaction for this type. Skipping.")
return
@@ -151,8 +153,6 @@ class InAppPaymentKeepAliveJob private constructor(
return
}
clearOldPendingPaymentsIfRequired()
val activeInAppPayment = getActiveInAppPayment(subscriber, subscription)
if (activeInAppPayment == null) {
warn(type, "Failed to generate active in-app payment. Exiting")
@@ -235,6 +235,8 @@ class InAppPaymentKeepAliveJob private constructor(
* fail the job and let the keep-alive check create a new one as necessary.
*/
private fun clearOldPendingPaymentsIfRequired() {
info(type, "Clearing out old pending payments as required.")
val inAppPayments = SignalDatabase.inAppPayments.getOldPendingPayments(type.inAppPaymentType)
inAppPayments.forEach { inAppPayment ->