Update Stripe Configuration
POST/truckers/payment/withStripe
Enable or disable Stripe payments for the carrier.
Technical Flow:
- Verifies user authentication
- Retrieves the company associated with the user
- Validates that terms are accepted if enabling Stripe
- If enabling and no Stripe account exists, creates one
- Updates the status in payment_settings.withStripe
- Saves changes to the company
Actions Performed:
- If enabled=true:
- Creates Stripe account if it doesn't exist (using toolsStripe.registerOnStripe)
- Updates payment_settings.withStripe to true
- If enabled=false:
- Updates payment_settings.withStripe to false
- Does not delete the Stripe account
Validations:
- User must be authenticated (valid JWT)
- User must belong to a valid company
- To enable (enabled=true):
- Terms must be accepted
- Billing email must be configured
Request Example:
// Frontend: Enable Stripe payments
const enableStripePayments = async () => {
try {
const response = await axios.post(
'/truckers/payment/withStripe',
{ enabled: true },
{ headers: { Authorization: `Bearer ${token}` } }
);
if (response.data.success) {
showSuccessMessage(); // Show confirmation
}
} catch (error) {
handleError(error);
}
};
Error Cases:
- 400 Bad Request: Enabled parameter not provided
- 401 Unauthorized:
- Invalid JWT token
- User has no associated company
- Terms not accepted (when enabling)
- Error connecting to Stripe
- 500 Internal Server Error: Error saving configuration
Request
Responses
- 200
- 401
Settings updated successfully
Unauthorized. Possible causes:
- Invalid JWT token
- User has no associated company
- Terms not accepted (when enabling)
- Error connecting to Stripe