Subscribing to a subscription
This tutorial provides an overview of how consumers can subscribe to a subscription plan. Before proceeding, it is assumed that the developer is already familiar with the Acta Billings API and its functionality.
This guide is intended for registered merchants only. However, developers who wish to explore it can request access to a sandbox API key through our Help & Support section.
Subscription Steps
Create Checkout-session
In the first step, create the checkout session for consumer using PaymentLink Id
Create wagmi config
create a Wagmi configuration file.
Precompute smart wallet address
Use the useActaAccount()
hook to precompute the smart wallet address by passing the required parameters. Mock validators can be used for development and testing, but for production, please contact us to obtain custom validators.
The useSalt()
hook requests a signature to generate a unique salt, which is then used to precompute the smart wallet address
Insert required parameters
Pass the required parameters, such as Paymaster URL, Paymaster Address, Token Address, etc. Additionally, useFees()
is required for fee calculation, useMerkleSignUserOps()
is needed for the Merkle operations signing process and useNonceKeys()
is need to get unused validators.
Fetch Checkout-session data
Pass the required parameters, such as Paymaster URL, Paymaster Address, Token Address, etc. Additionally, useFees()
is required for fee calculation, useMerkleSignUserOps()
is needed for the Merkle operations signing process and useNonceKeys()
is need to get unused validators.
Subscribe to subscription plan
In the final step, subscribe to a subscription plan, assuming the subscriber has selected plan[0]
.
NOTE: Before subscribing to a subscription, the consumer must ensure that their smart wallet has sufficient allowance.
The required allowance should be calculated as:
totalAllowanceRequired = (transferAmount + actaFees + paymasterFees) * volume
Refer to this code example to calculate the required allowance.
👏 Congratulations! You have successfully subscribed to a subscription plan!
Full Code
If you want to see the complete code that integrates all the previous steps in detail, you can find it in our separate repository. If you plan to run it, don’t forget to replace the API key with your own!