The TypeScript Payments SDK enables you to subscribe users without requiring a particular frontend framework.
Getting Started
1. Install the SDK
Install the SDK with your preferred package manager.
2. Import and Initialize the Payments SDK
To use the Payments SDK in your code, import it in any file where you need to use it.
For local development, we recommend using the sandbox feature on the Payments class to return mocked subscriptions:
The sandbox prop should only be used for local development. Do not use it in production.
3. Check if the User is subscribed
The hasSubscription method returns the user’s subscription status: true if subscribed and false otherwise.
The getSubscription method returns the user’s subscription information.
5. Prompt the User to subscribe
If the user is not subscribed, you can prompt them to subscribe by calling the requireSubscription method.
6. Get Notified when the User is subscribed
You can get notified when the user subscribes or changes its subscription using onUserSubscribed method.