Pay
Manage Subscription
Get the current subscription details plus a Stripe Customer Portal URL where the user updates their payment method or cancels — no billing UI to build yourself.
POST
/api/pay/manage_subscription.php
Requires
Authorization: AppID:AppKey + user tokenRequest body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| token | string | required | — | User session token |
| itemKey | string | required | — | Subscription plan key |
| return_url | string | optional | Vanelton ID | Where Stripe sends the user back after they leave the portal |
| debug | bool | optional | false | Use Stripe test mode |
Test this endpoint
Headers
Body
Example
POST /api/pay/manage_subscription.php
Authorization: com.myapp:MyAppKey12345678901234
Content-Type: application/json
{
"token": "USER_TOKEN",
"itemKey": "plan-pro"
}
Success response 200
{
"success": true,
"subscription": {
"itemKey": "plan-pro",
"status": "active",
"current_period_end": "2025-06-10 14:32:00",
"stripe_subscription_id": "sub_..."
},
"portal_url": "https://billing.stripe.com/p/session/..."
}
Redirect the user to portal_url. From there they can update their card, download invoices, or cancel — Stripe's hosted portal handles all of it, then sends them back to return_url.
Errors
| Code | Message | Cause |
|---|---|---|
| 400 | Missing required parameter 'token' / 'itemKey'. | Field not sent |
| 401 | Invalid or expired token. | Bad user token |
| 404 | No subscription found for this itemKey and user. | User never subscribed to this plan |
| 409 | Subscription record has no Stripe customer associated. Cannot open management portal. | Data integrity issue on an old record — contact support |
| 500 | Failed to create customer portal session. Check server logs. | Stripe API error |