Skip to main content

Access Stripe customer portal to manage subscription

POST 

/company/payment/changePlans

Generate a Stripe Customer Portal session where the company can manage its subscription, change plans, update its card, or view invoices.

Objective

Provide access to the Stripe self-service portal with validation that the account is active and not expired.

Use Cases

  • Change from Basic to Professional plan or vice versa
  • Cancel active subscription
  • Update subscription payment method
  • View Stripe invoice history
  • Download invoices as PDF

Validation Flow

flowchart TD
A[Receive Request - returnUrl] --> B{returnUrl provided?}
B -->|No| C[400 MISSING_RETURN_URL]
B -->|Yes| D{User authenticated?}
D -->|No| E[404 USER_NOT_FOUND]
D -->|Yes| F{Company found?}
F -->|No| G[401 CIA_NOT_FOUND]
F -->|Yes| H{UserActivity exists?}
H -->|No| I[404 USER_NOT_FOUND]
H -->|Yes| J{Account not expired?}
J -->|Expired| K[404 USER_EXPIRED]
J -->|Active| L[Create Customer Portal session]
L --> M[200 Portal URL]

Notes

  • Requires JWT authentication (bearerAuth)
  • Unlike the truckers module, it validates that the account is not expired
  • Verifies userActivity.dateEnd > now before creating the session
  • The return URL (returnUrl) is mandatory in the body
  • The portal session expires in ~5 minutes (Stripe default behavior)
  • Requires stripe_customer to be configured for the company

Request

Responses

Stripe Customer Portal URL

Response Headers