How to handle multiple failed donations
Hi,
as we know Stripe repeats charging when it failed twice (6 days later and 12 days later). Each time stripe endpoint civicrm/payment/ipn/ID receives event invoice.payment_failed
type what means that new contribution with Failed status is created. In the end we have three Failed contributions for given month. Of course I'm talking about recurring contributions.
Where is my problem? Shouldn't we have an only one Failed contribution with 3 Failed payments?
First of all CiviCRM's data structure is a bit poorer than Stripe's
Stripe | CiviCRM |
---|---|
Subscription | -> Recurring contribution |
Invoice | -> Contribution |
Payment | -> Contribution + Payment |
Charge | -> Contribution + Payment |
On Stripe side one Invoice has up to 3 payments/charges.
Invoice is unique on civicrm (civicrm_contribution.invoice_id) so it's possible to check when endpoint receive invoice.payment_failed
event whether it exists or not. And create it only if needed.
What do you think about this case?