The below authentication in all the flows related to the billing API is handled by the client backend app in same way above.
Get Plans Flow
You can use the useBillingPlans hook to retrieve the plans and entitlements.
1
Client UI Initiates Request
The client UI calls the
useBillingPlans hook to trigger a call to the billing API.2
Billing API Validates Session
The billing API queries the client backend app to check the validity of the session and retrieve user details.
3
Return error to client if session is not valid
If the session is not valid, the billing API will return an error to the client UI.
4
Billing API Queries Lago
If session is valid then based on the user details, the billing API queries Lago to return the plans for the user. Currently, all plans are fixed for each client.
5
Lago Returns Plans
Lago returns the relevant plans to the billing API.
6
Billing API Responds to Client
The billing API forwards the plans back to the client UI. The
useBillingPlans hook receives the response, which includes the plans and any potential errors.You can use the useBillingPlans hook to retrieve the plans and entitlements.