Overview
The Checkout API enables you to create secure payment sessions for FitAiid products using Stripe. This endpoint handles product purchases, subscription plans, and digital fitness content.All payment processing is handled securely through Stripe. FitAiid never stores sensitive payment information.
Create Checkout Session
Headers
Bearer token:
Bearer YOUR_JWT_TOKENBody Parameters
Array of products to purchase
URL to redirect after successful payment
URL to redirect if payment is cancelled
Shipping address information
Shipping method selection
Discount coupon code
Special delivery instructions (max 500 characters)
Response
After receiving the response, redirect the user to the
checkoutUrl to complete payment on Stripe’s secure checkout page.Verify Payment Status
Path Parameters
Stripe checkout session ID returned from create-session
Response
Apply Coupon Code
Body Parameters
Coupon code to validate
Array of cart items to calculate discount
Response
Stripe Webhook Handler
Webhook Events Handled
checkout.session.completed
Triggered when a customer completes the checkout session
- Creates order record in database
- Updates product inventory
- Sends confirmation email
- Updates payment status to
paid
checkout.session.expired
Triggered when a checkout session expires
- Updates order status to
cancelled - Releases reserved inventory
payment_intent.succeeded
Triggered when payment is successfully processed
- Confirms order status
- Triggers fulfillment workflow
payment_intent.payment_failed
Triggered when payment fails
- Updates payment status to
failed - Sends payment failure notification
charge.refunded
Triggered when a charge is refunded
- Updates order status to
refunded - Restores product inventory
- Sends refund confirmation
Configuration
To set up the webhook in your Stripe dashboard:- Go to Developers → Webhooks in Stripe Dashboard
- Click Add endpoint
- Enter URL:
https://api.fitaiid.com/api/checkout/webhook - Select events to listen for:
checkout.session.completedcheckout.session.expiredpayment_intent.succeededpayment_intent.payment_failedcharge.refunded
- Copy the Signing secret and add to your environment variables as
STRIPE_WEBHOOK_SECRET
Security
Webhook Signature Verification
All webhook requests are verified using Stripe’s signature in the
stripe-signature header. Requests without valid signatures are rejected.Calculate Shipping Cost
Body Parameters
Array of cart items
Desired shipping method:
standard, express, overnight, or pickupDelivery city for location-based calculations
Response
Orders over $200,000 COP qualify for free standard shipping. Express and overnight shipping incur additional charges.
Error Responses
400 Bad Request
Invalid request parameters
401 Unauthorized
Missing or invalid authentication token
404 Not Found
Product or checkout session not found
500 Internal Server Error
Stripe API error or server issue
Testing
Test Cards
Use these test card numbers in Stripe test mode:Successful Payment
Card Number: 4242 4242 4242 4242Expiry: Any future dateCVC: Any 3 digits
Payment Declined
Card Number: 4000 0000 0000 0002Use this to test declined payments
3D Secure Required
Card Number: 4000 0027 6000 3184Use this to test Strong Customer Authentication
See Stripe Testing Documentation for more test scenarios.