Skip to content

Commit

Permalink
Website: Add two events to stripe webhook, add comments about when ev…
Browse files Browse the repository at this point in the history
…ents are sent. (#14370)

Changes:
- Added the `invoice.updated` and `invoice.voided` events to the
`STRIPE_EVENTS_SENT_BEFORE_A_SUBSCRIPTION_RECORD_EXISTS` array in the
`receive-from-stripe` webhook.
  • Loading branch information
eashaw authored Oct 7, 2023
1 parent 1555d09 commit eafc9ab
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions website/api/controllers/webhooks/receive-from-stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ module.exports = {
let subscriptionForThisEvent = await Subscription.findOne({stripeSubscriptionId: subscriptionIdToFind}).populate('user');

let STRIPE_EVENTS_SENT_BEFORE_A_SUBSCRIPTION_RECORD_EXISTS = [
'invoice.created',
'invoice.finalized',
'invoice.paid',
'invoice.payment_succeeded',
'invoice.payment_failed',
'invoice.payment_action_required',
'invoice.created',// Sent when a user submits the billing form on /customers/new-license, before the user's biliing card is charged.
'invoice.finalized',// Sent when a user submits the billing form on /customers/new-license, before the user's biliing card is charged.
'invoice.paid',//Sent when a user submits the billing form on /customers/new-license, when the user's biliing card is charged.
'invoice.payment_succeeded',// Sent when payment for a users subscription is successful. The save-billing-info-and-subscribe action will check for this event before creating a license key.
'invoice.payment_failed',// Sent when a users subscritpion payment fails. This can happen before we create a license key and save the subscription in the database.
'invoice.payment_action_required',// Sent when a user's billing card requires additional verification from stripe.
'invoice.updated',// Sent before an incomplete invoice is voided. (~24 hours after a payment fails)
'invoice.voided',// Sent when an incomplete invoice is marked as voided. (~24 hours after a payment fails)
];

// If this event is for a subscription that was just created, we won't have a matching Subscription record in the database. This is because we wait until the subscription's invoice is paid to create the record in our database.
Expand Down

0 comments on commit eafc9ab

Please sign in to comment.