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
Response
Response varies by payment gateway:Stripe Response
Flutterwave Response
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
Response
Example Request
Payment Gateway Selection
The API automatically selects the payment gateway based on the user’s currency preference: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