WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@hdiniz
Copy link
Contributor

@hdiniz hdiniz commented Nov 4, 2025

No description provided.

@hdiniz hdiniz self-assigned this Nov 4, 2025
@hdiniz hdiniz marked this pull request as ready for review November 4, 2025 11:26
@hdiniz hdiniz requested a review from Betree November 4, 2025 11:27
Comment on lines 30 to 38
paymentIntent = await stripe.paymentIntents.retrieve(order.data.paymentIntent.id, {
stripeAccount,
});
} catch (err) {
logging?.(`Order ${order.id} payment intent not found on stripe`, err);
if (!IS_DRY) {
await order.update({
status: OrderStatuses.CANCELLED,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look at the error type before cancelling the order. The request could fail for numerous other reasons: rate-limiting, network error, Stripe API being down...etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in this last push to specifically handle the case where the payment intent is expired on stripe. Happens when the payment intent is created, but no action is taken on it (i.e. user went into the last step of the contribution flow, but abandoned the contribution).


logging?.(`Order ${order.id} paymentIntent status: ${paymentIntent.status}`);

const charge = (paymentIntent as any).charges?.data?.[0] as Stripe.Charge;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only look at the first charge? Could it be that a payment intent fails first, then succeeds after?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array contains the charges ordered by most recent first. Its a deprecated field, replaced by latest_charge in the latest API, but I did not want to modify this at this time. We are due a task to try and update our stripe API usage, this field is not missing even from the docs at stripe.

@hdiniz hdiniz requested a review from Betree December 2, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants