Docs : SDK : cancelSubscription
cancelSubscription lets your users cancel their subscription.
userbase.cancelSubscription().then((result) => {
// user sucessfully canceled subscription
}).catch((e) => console.error(e))
Result
-
result [object] - Contains the date the subscription is set to be canceled.
- cancelSubscriptionAt [string] - The date the user's subscription is set to be canceled.
Notes
-
Your user will not be charged again for the subscription your app is currently set to after successfully calling this function.
-
If your user is subscribed to a plan and you delete that subscription plan on your app in the Admin panel and then set a new plan, this function will not cancel that user's subscription plan. You must manually delete that user's plan in the Stripe dashboard.
-
This sets your user’s subscription to cancel at the end of the current period. For example, if your user purchases a yearly subscription on May 4th, 2021 and then cancels the subscription on June 10th, 2021, then your user’s subscription will cancel on May 4th, 2022.
-
After this function is called successfully, your user's cancelSubscriptionAt will be set to to the date the subscription is set to be canceled. If the user's subscriptionStatus was set to 'active' before calling this function, the user will still be able to call openDatabase on an app with payments enabled until the subscription is canceled on that date.
Errors
- SubscriptionPlanNotSet
- StripeAccountNotConnected
- PaymentsDisabled
- SubscriptionAlreadyCanceled
- UserNotSignedIn
- TooManyRequests
- ServiceUnavailable