In the last experiment, I integrated the Stripe billing portal and realized it can handle the subscription canceling flow and result in closing the account in the IdP.
So all that’s left to do:
- Handle the
customer.subscription.deletedwebhook. - Update the account
paymentStatus,cancelAt,canceledAt, andclosedAt. Here’s an explanation of the fields:cancelAtis the timestamp the subscription is expected to cancel.canceledAtis the timestamp when the cancelation request was submitted.closedAtis the timestamp when the subscription stopped being active. Only set once the subscription is over.
- Revoke tokens for all account members.
- Block signin for members of closed accounts.
Code
joshnuss/idp-experiment@fe9fa92
Notes
- Unfourtunately the
canelation_reasonis not availabe via Stripe’s API, but it is available with Stripe Sigma - Need to send webhooks when account is closed or token revoked.
- Get a better understanding of the expired token, how is the access token effected? Will it keep work for 15 minutes?