change the time used for failed payments #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short version (Just read this bit if you don't want to read all the detail, apologies the PR description is so long!)
I have changed the payment/opportunity/recurring donation creation date to be the time in which the stripe payment_intent.payment_failed event is created rather than the time the original payment intent object was created.
This means if a payment intent object is invoked multiple times to recharge a recurring donor then we don't use the same date for each recharge.
Description
Through testing it was highlighted that each recharge of a recurring donation uses the original monthly charge creation date rather than the date of each actual recharge attempt.
We have a donor https://dashboard.stripe.com/payments/pi_3NZLl7HPCO7LDipn0klWAEeX who in salesforce has this recurring donation generated from an incoming payment:
https://otwarteklatki--datacopy.sandbox.lightning.force.com/lightning/r/npe03__Recurring_Donation__c/a09Fg000000hPBFIA2/view
It has two donations attached to it:
https://otwarteklatki--datacopy.sandbox.lightning.force.com/lightning/r/006Fg000005BBdFIAW/view
https://otwarteklatki--datacopy.sandbox.lightning.force.com/lightning/r/006Fg000005DBpEIAW/view
Both for the date of 29th of July, which is the date the initial donation is meant to be on.
In stripe we see:
The screenshot above shows the time in CET from filip who is an hour ahead of me, which is why it’s the 30th not the 29th in the initial payment. Also bare in mind that the integration was turned on on the 17th so we shouldn't expect to see anything before that.
What we want to see in stripe is
Opp -> 29th/30th of July
Failed payment 4 -> 18th of august
Failed payment 5 -> 20th of august
Details for failed payment 4:
On the 18th this payment_intent.payment_failed event fired https://dashboard.stripe.com/events/evt_3NZLl7HPCO7LDipn08N9tiMV
And successfully sent data to our webhook provider (see link above for details)
"event.created": 1692319442, // webhook event creation date = Friday, 18 August 2023 00:44:02
"event.data.object.created": 1690670233, // payment intent creation date = Saturday, 29 July 2023 22:37:13
So I've swapped the dates used for failed payments. I believe this will mean we use the event created data for creating new payments and opportunities but when a payment comes it which can be attached to an existing opportunity it will not effect the date on the existing opportunity and use the created date for the new payment.
Changes
Testing
I tested/checked our Stripe payment scenarios and if the event created time is what we expected.
I also tested if the time in which we ask stripe sends the webhook has an effect on the event creation time it sends us
Implications on downstream methods
This new created date will be used in the following contexts assuming the payment we're processing failed:
Issues Closed
https://app.clickup.com/t/4540126/ROZPR-12385