I'm using hosted pages and API, so it looks like I could:
Is there a more efficient way to do this?
URLs I've researched on this topic:
I believe your workflow is this - allow customers to login to your webpage - they purchase a subscription - using the customer ID, you'd like to create a portal session for the user. If this is not the workflow, please stop here and get back to me with your use case along with the workflow.
If the above is your setup:
1. The customer ID can be retrieved from the redirect URL; you don't have to use the Retrieve Subscription API call to get the customer ID.
2. You can create a portal session for the customer using their ID.
3. Storing the customer ID in your database is optional. You can store them if there are any actions performed based on the active session.
If you still want to reduce the steps involved, can you elaborate your business model? It would help us offer you the best suggestions.