Dunning Process
The dunning process is an automated system that ensures timely and accurate billing for subscription-based services. It involves checking for valid payment methods, creating and charging transactions, and handling failed payments.
Valid Credit Card Check: When a user upgrades their subscription, the dunning process checks whether the user is using a valid credit card ( this is done through a Braintree call). If the credit card is invalid, the user is prompted to update their payment information before the subscription upgrade can be completed.
Subscription Types: The dunning process includes two subscription types: monthly and yearly. The next charge is based on the subscription type and is automatically charged on the due date.
Rake Task - Create Subscription Transactions:
The create_subscription_transactions rake task is run every day to check for subscriptions that require billing. This task creates new transactions with a pending status, which will be charged on the next due date.
Rake Task - Charge Transactions:
The charge_transactions rake task is run every day to check for pending transactions that need to be charged. This task includes transactions that were previously charged but failed, as well as new transactions.
Handling Failed Payments: If a payment fails, the dunning process automatically retries the charge if there is any alternative credit card. If the charge continues to fail, the user is notified.
Day 1 - 1st CC failed payment + 1st email (warning that in 1 week will be hidden) Day 5 - 2nd failed payment trial + 2nd email (warning that in 2 days it will be hidden) Day 7 - 3rd email (Your app was hidden, pay it to get it back online) Day 9 - 3th trial + 4th email (reminder)