Accept payment terms and conditions
POST/truckers/payment/terms
Records the acceptance of terms and conditions for processing payments with Stripe.
Actions performed:
- Records timestamp and IP of acceptance
- Creates Stripe account for the company if it doesn't exist (using toolsStripeCia.updateOnStripe)
- Updates payment_settings.tos_acceptance in the company
- Enables Stripe payments if everything is successful
Validations:
- User must be authenticated (valid JWT)
- User must belong to a valid company
- The company must exist in the database
Technical flow:
- Gets user and company data
- Prepares acceptance data (timestamp, IP)
- If no Stripe account exists, creates one
- Updates terms accepted record
- Saves changes to the company
Possible responses:
- 200 OK: Terms accepted successfully
- 401 Unauthorized:
- Invalid JWT token
- User doesn't belong to valid company
- Error creating Stripe account
Request example:
// Frontend: Send terms acceptance
const acceptTerms = async () => {
try {
const response = await axios.post(
'/truckers/payment/terms',
{},
{ headers: { Authorization: `Bearer ${token}` } }
);
if (response.data.success) {
proceedToPayments(); // Continue to payments section
}
} catch (error) {
handleError(error);
}
};
Important notes:
- This endpoint is required to enable Stripe payments
- Can only be called once (acceptance is permanent)
- Records server IP, not client IP
Responses
- 200
- 401
Terms successfully accepted
Unauthorized. Possible causes:
- Invalid JWT token
- User does not belong to a valid company
- Error creating Stripe account