Skip to main content

Update Stripe Configuration

POST 

/truckers/payment/withStripe

Enable or disable Stripe payments for the carrier.

Technical Flow:

  1. Verifies user authentication
  2. Retrieves the company associated with the user
  3. Validates that terms are accepted if enabling Stripe
  4. If enabling and no Stripe account exists, creates one
  5. Updates the status in payment_settings.withStripe
  6. 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

Settings updated successfully