Create Payment Intent
Initializes a payment session for course enrollment. Automatically selects the appropriate payment gateway (Stripe or Flutterwave) based on user currency.Request Body
Course ID to purchase
Enrollment mode (informational)
Course title (used for payment description)
Redirect context: “course-detail” or “courses-list”
Response
Response varies by payment gateway:Stripe Response
Stripe Checkout session URL
“stripe”
Payment amount in user’s currency
User’s preferred currency
Original course price in platform currency
Platform’s default currency
Flutterwave Response
Flutterwave payment page URL
“flutterwave”
Transaction reference ID
Payment amount
Payment currency
Example Request
Example Response (Stripe)
Example Response (Flutterwave)
Record Payment
Records a completed payment in the database. Called after successful payment via gateway callback.Request Body
Course ID
Payment amount
Payment gateway: “stripe” or “flutterwave”
Response
Payment recording status
Created payment record
Example Request
Payment Gateway Selection
The API automatically selects the payment gateway based on the user’s currency preference:| Currency | Gateway | Notes |
|---|---|---|
| NGN (Nigerian Naira) | Flutterwave | Optimized for African markets |
| All others (USD, EUR, etc.) | Stripe | Global payment processing |
Currency Conversion
Course prices are stored in the platform’s default currency (configurable inplatform_settings). The API:
- Fetches the course price in platform currency
- Gets the user’s preferred currency from their profile
- Converts the amount using real-time exchange rates
- Creates a payment session in the user’s currency
- Stores both original and payment amounts for reporting
Currency Fields
- original_amount: Course price in platform currency
- original_currency: Platform’s default currency (e.g., “USD”)
- payment_amount: Amount charged to user (after conversion)
- payment_currency: User’s payment currency
- exchange_rate: Rate used for conversion (amountUSD / originalAmount)
Payment Callbacks
Stripe Callback
Handles Stripe Checkout session completion. Query Parameters:success: “true” for successful paymentcourseId: Course IDreferrer: Redirect context
Flutterwave Callback
Handles Flutterwave payment completion. Query Parameters:status: Payment statustx_ref: Transaction referencetransaction_id: Flutterwave transaction IDcourseId: Course IDreferrer: Redirect context
Payment Webhooks
Stripe Webhook
Receives and processes Stripe webhook events for payment confirmations and updates.Payment Flow
- User initiates payment: POST to
/api/payments/create-intent - API creates payment session:
- Converts price to user’s currency
- Selects appropriate gateway (Stripe or Flutterwave)
- Returns checkout/payment URL
- User completes payment: On gateway-hosted page
- Gateway redirects to callback:
/api/payments/callback/{gateway} - Callback records payment: Calls
/api/payments/record-payment - User enrolled automatically: Callback creates enrollment record
- User redirected: To course page or courses list
Error Codes
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid course ID or parameters |
| 401 | Unauthorized - Authentication required |
| 404 | Not Found - Course not found |
| 500 | Internal Server Error - Payment gateway error |