Docs : SDK : updatePaymentMethod
updatePaymentMethod redirects your users to a Stripe Checkout form that allows the user to input a new credit card.
userbase.updatePaymentMethod({
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel'
}).then(() => {
// user successfully redirected to Stripe Checkout form
}).catch((e) => console.error(e))
Parameters
-
sucessUrl [string] - The URL the user will be redirected to upon successfully saving their new credit card.
-
cancelUrl [string] - The URL the user will be redirected to upon canceling the form.
Notes
-
This function is especially useful for when your user's credit card fails. At the end of a billing cycle your user gets charged for example, but their card has expired. Calling this function will update their credit card and pay off the outstanding subscription automatically.
-
The credit card the user sets here will be used to pay their subscription going forward.
Errors
- ParamsMustBeObject
- SuccessUrlMissing
- SuccessUrlMustBeString
- SuccessUrlInvalid
- CancelUrlMissing
- CancelUrlMustBeString
- CancelUrlInvalid
- StripeError
- StripeJsLibraryMissing
- SubscriptionNotPurchased
- StripeAccountNotConnected
- PaymentsDisabled
- UserNotSignedIn
- TooManyRequests
- ServiceUnavailable