The Payments SDK for React enables you to subscribe users using React-specific features.
Getting Started
1. Install the SDK
Install the SDK with your preferred package manager.
2. Wrap Your App with the Provider
In order for your microapp to have access to payments features, it needs to be wrapped in the SubscriptionProvider component:
For local development, we recommend using the sandbox feature on the SubscriptionProvider component to return mocked subscriptions:
The sandbox prop should only be used for local development. Do not use it in
production.
3. Use the useSubscription Hook
The useSubscription hook returns all of the payments data and methods available to your microapp. It returns the following type:
4. Prompt the User to Subscribe
You can prompt the user to subscribe by calling the requireSubscription method.
5. Get Notified when the User subscribes
You can get notified when the user subscribes or changes the subscription passing a callback on Payments initialization
6. Example Usage
Here is an example of how you can use the useSubscription hook in your microapp: