Subscriptions
Manage subscription state, entitlement, and renewal periods.
Subscription is billing state; entitlement is an application decision
Store the subscription_id, status, Product, ProductPrice snapshot, and current-period end. Query BenefitGrants when your application needs the current entitlements.
const subscription = await fetch(
`${apiUrl}/public/v2/subscriptions/${subscriptionId}`,
{ headers: apiHeaders },
).then((res) => res.json())
State and access
Grant access only after a valid Checkout and its Subscription event. active and recovery-state past_due retain BenefitGrants; canceled revokes them.
Renewal lifecycle
PayOS does not automatically debit recurring payments. Before renewal VietBilling creates a pending Order, Checkout, and Payment attempt. When payment succeeds, order.paid, payment.succeeded, checkout.succeeded, and subscription.updated advance the period.
- Store every webhook event id idempotently.
- Deliver the renewal Checkout URL through your channel.
- Receive
subscription.updatedafter Payment succeeds. - Update the current period and refresh BenefitGrants.
Do not renew access merely because a customer opened the renewal URL.