Delete payment method
DELETE/truckers/payment/payment_method
Remove a payment method associated with the carrier in Stripe.
Technical Flow:
- Verify user authentication
- Retrieve the company associated with the user
- Validate that the payment method belongs to the company's Stripe customer
- Verify that the method is not the default
- Check that it is not in use in active transactions
- Delete the method using toolsStripe.deletePaymentMethod
Validations:
- User must be authenticated (valid JWT)
- User must belong to a valid company
- The payment method must belong to the company's Stripe customer
- The payment method must not be in use in active transactions
- The payment method must not be the default
Request Example:
// Frontend: Delete payment method
const deletePaymentMethod = async (paymentMethodId) => {
try {
const response = await axios.delete(
`/truckers/payment/payment_method/${paymentMethodId}`,
{ headers: { Authorization: `Bearer ${token}` } }
);
if (response.data.success) {
refreshPaymentMethods(); // Refresh payment methods list
}
} catch (error) {
handleError(error);
}
};
Error Cases:
- 400 Bad Request: Payment method ID not provided
- 401 Unauthorized:
- Invalid JWT token
- Payment method does not belong to the user
- Payment method is the default
- Payment method is in use in active transactions
- 500 Internal Server Error: Error deleting from Stripe
Request
Responses
- 200
- 401
Method successfully removed
Unauthorized or method in use. Possible causes:
- Invalid JWT token
- Method does not belong to the user
- Method is in use in active transactions
- It is the default method