🐛 Fixed bug with persisting offer redemptions for existing free members #20571
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.
ref https://linear.app/tryghost/issue/ENG-1251/support-escalation-re-offers-not-tracking
SubscriptionCreatedEvent
, under the assumption that the offer details would be included in this event. This assumption was valid for brand new members starting a subscription with an offer, but not for existing free members upgrading to a paid plan with an offer.customer.subscription.created
Stripe webhook. At this point, the offer/discount is not attached to the subscription, so theSubscriptionCreatedEvent
triggers without the offer information, and the offer redemption is not recorded. After thecheckout.session.completed
webhook is received (which does include the offer details), the subscription is updated in Ghost, but the Offer Redemption is not stored.customer.subscription.created
webhook no-ops, because the member and Stripe Customer don't exist yet. Therefore, the subscription is first created in Ghost in response to thecheckout.session.completed
webhook, which does include the offer information, so the offer information is included in theSubscriptionCreatedEvent
and the offer redemption is recorded as expected.OfferRedemptionEvent
, which triggers either: (1) when a new subscription is created with an offer (as in the case of a brand new member), or (2) when an existing subscription is first updated to include an offer (as in the case of an existing free member upgrading with an offer). The Offer Redemption is then persisted in the DB in response to theOfferRedemptionEvent
rather than theSubscriptionCreatedEvent
.