Delete payment method
DELETE/company/payment/payment_method/:id
Purpose
Permanently delete a payment method (card) from the company's Stripe account.
Objective
Allow for the cleanup of the payment method portfolio by removing obsolete cards that are not currently in use.
Use Cases
- Delete an expired card
- Remove a card added by mistake
- Clean up the list of payment methods (max. 10)
Validation Flow
flowchart TD
A[Receive Request - id] --> B{User authenticated?}
B -->|No| C[404 USER_NOT_FOUND]
B -->|Yes| D{Company found?}
D -->|No| E[401 CIA_NOT_FOUND]
D -->|Yes| F{stripe_customer exists?}
F -->|No| G[404 STRIPE_CUSTOMER_NOT_FOUND]
F -->|Yes| H{PM belongs to customer?}
H -->|No| I[401 PAYMENT_METHOD_NOT_FOUND]
H -->|Yes| J{PM active in deliveries?}
J -->|Yes| K[401 PAYMENT_METHOD_IN_USE]
J -->|No| L[Delete from Stripe]
L --> M[200 success: true]
Notes
- Requires JWT authentication (bearerAuth)
- Cannot be deleted if it is active in deliveries with paid
payment_intent - Cannot be deleted if it is the default method (
is_default: true) - Deletion in Stripe is permanent (non-recoverable)
Request
Responses
- 200
- 401
- 404
- 500
Payment method successfully removed
Response Headers
Company not found, method non-existent or in active use.
Response Headers
Stripe user or customer not found
Response Headers
Error deleting in Stripe