Get payment URLs for subscription plans
GET/truckers/payment/urls
Returns Stripe checkout URLs for the different available subscription plans.
Technical Flow:
- Verifies user authentication
- Gets the company associated with the user
- Queries available plans in the database
- Gets Stripe prices using toolsStripe.getPricesList()
- Creates a checkout session for each plan
- Associates the Stripe customer if it exists
- Returns URLs ready to redirect the user
Important Details:
- Uses subscription mode for recurring payments
- Automatically associates the Stripe customer if it exists
- Uses the company's billing email if no Stripe customer exists
- Generates a unique client_reference_id for each company
Information included per plan:
- id_plan: Unique plan identifier
- name: Plan name
- description: Plan description
- price: Plan price
- url: Stripe checkout URL
Validations:
- User must be authenticated (valid JWT)
- User must belong to a valid company
- The company must have a configured billing email
Response Example:
[
{
id_plan: plan_basic,
name: Basic Plan,
description: Access to basic features,
price: 9.99,
url: https://checkout.stripe.com/pay/cs_test_abc123
},
{
id_plan: plan_premium,
name: Premium Plan,
description: Full access to all features,
price: 19.99,
url: https://checkout.stripe.com/pay/cs_test_xyz456
}
]
Frontend Usage Example:
// Frontend: Get payment URLs
const getPaymentUrls = async () => {
try {
const response = await axios.get('/truckers/payment/urls', {
headers: { Authorization: `Bearer ${token}` }
});
if (response.data.length > 0) {
displayPlans(response.data); // Display available plans
}
} catch (error) {
handleError(error);
}
};
Error Cases:
- 401 Unauthorized:
- Invalid JWT token
Responses
- 200
- 401
List of payment URLs with details of each plan.
Unauthorized. Possible causes:
- Invalid JWT token
- User does not belong to a valid company
- Error connecting to Stripe