Set up new payment method
POST/company/payment/setup_payment_method
Generate a Stripe portal URL so the company can securely add a new payment method (credit/debit card).
Objective
Redirect the user to the Stripe portal where they can register their card information without exposing sensitive data to the backend.
Use Cases
- Add the first credit/debit card
- Add additional payment methods (max. 10)
- Replace expired cards with new ones
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{stripe_customer exists?}
H -->|No| I[404 STRIPE_CUSTOMER_NOT_FOUND]
H -->|Yes| J{Count < 10?}
J -->|No| K[200 - Empty string]
J -->|Yes| L[Create payment methods portal]
L --> M[200 - Portal URL]
Notes
- Requires JWT authentication (bearerAuth)
- Limit of 10 payment methods per company; if reached, returns `` (empty string)
- Requires the company to have a
stripe_customer(use/register_stripefirst) - The
returnUrlis where Stripe redirects the user after adding the method
Request
Responses
- 200
- 400
- 401
- 404
- 500
Portal URL or empty string if the limit of 10 was reached.
Response Headers
Return URL not provided
Response Headers
Company not found
Response Headers
User or Stripe customer not found
Response Headers
Error creating portal session