Skip to main content

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_stripe first)
  • The returnUrl is where Stripe redirects the user after adding the method

Request

Responses

Portal URL or empty string if the limit of 10 was reached.

Response Headers