Get registered payment methods
GET/truckers/payment/payment_method
Returns the list of payment methods associated with the carrier in Stripe.
Technical Flow:
- Verifies user authentication
- Gets the company associated with the user
- Retrieves payment methods from Stripe using
toolsStripeCia.getPaymentMethodsList - Checks which methods are in use (active transactions)
- Formats the response with relevant information
Information Included:
- Card details (last 4 digits, brand, expiration date)
- Default method indicator
- Indicator for whether it can be deleted (not in use in active transactions)
Validations:
- User must be authenticated (valid JWT)
- User must belong to a valid company
- The company must have an associated Stripe account
- Only shows methods from the associated Stripe customer
Example Response:
[
{
id: pm_1ABC123XYZ456,
billing_details: { name: Juan Perez },
card: {
country: ES,
display_brand: visa,
exp_month: 12,
exp_year: 2025,
last4: 4242
},
is_default: true,
can_delete: false
},
{
id: pm_1DEF456UVW789,
billing_details: { name: Juan Perez },
card: {
country: ES,
display_brand: mastercard,
exp_month: 6,
exp_year: 2024,
last4: 5555
},
is_default: false,
can_delete: true
}
]
Error Cases:
- 401 Unauthorized:
- Invalid JWT token
- User has no associated company
- No Stripe account configured
- 500 Internal Server Error: Error connecting to Stripe
Responses
- 200
- 401
List of payment methods
Unauthorized. Possible causes:
- Invalid JWT token
- User does not have an associated Stripe account
- Error connecting to Stripe