Checkout
This endpoint allows you to retrieve the cart items with payment calculations and available payment methods for authenticated users. For mobile application, payment is mostly handled through wallet balance, which can be recharged using In-App Purchases (IAP). While the API still supports all the payment methods mentioned in the web application, mobile should still only use wallet for payments to comply with App Store requirements.
Endpoint
POST /v1/mobile/cart/checkout
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| products | array | Yes | Array of products to be processed |
| products.*.with_certificate | boolean | No | Whether to include certificate with the product |
| products.*.with_summary | boolean | No | Whether to include summary with the product |
| payment | boolean | Yes | Must be set to true for checkout page |
| order_confirmed | boolean | No | Must be false or omitted for checkout page |
| coupon | string | No | Coupon code to apply discount |
| use_new_customer_discount | boolean | No | Whether to apply new customer discount |
Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"cart_items": {
"total_price": 333,
"total_discount": 0,
"total_price_after_discount": 333,
"total_price_after_tax": 382.95,
"amount_paid_with_wallet": 0,
"points": 20,
"tax": 49.95,
"is_taxed": true,
"cart": [
{
"id": "8a620ad0-a5a2-11ee-8c63-07e9c26c60de",
"poster": "http://127.0.0.1:8000/storage/20786/مصادر-الثراء.png",
"name": "مصادر الثراء",
"count": 8,
"old_price": 0,
"price": 333,
"subtotal": 333,
"subtotal_after_tax": 382.95,
"certificate_price": 0,
"summary_price": 0,
"with_certificate": false,
"with_summary": false,
"has_certificate": false,
"has_summary": false,
"is_taxed": true,
"type": "course",
"duration": 730,
"gift_username": null,
"gift_email": null,
"gift": null,
"is_gift_to_unknown_customer": null
}
],
"can_use_wallet": false,
"available_balance": 0,
"can_use_new_customer_discount": true,
"is_wallet_balance_sufficient": false
},
"discounts": [],
"related_products": []
},
"status_code": 200
}
Implementation Details
Flow
- Validates the incoming request parameters
- Creates cart collection from products array
- Applies any coupon discounts if provided
- Checks eligibility for new customer discount
- Calculates prices including tax
- Checks wallet balance and eligibility
- Determines if wallet balance is sufficient for purchase
Special Cases
New Customer Discount
- Available when cart total ≥ 300 and at least one product price > 100
- Can only be used once per customer
- Must be explicitly requested via
use_new_customer_discountparameter
Wallet Usage
- Wallet is the recommended payment method for mobile applications
- Wallet balance must be sufficient for the total purchase amount
- For gift purchases, only giftable balance can be used
- Wallet can be recharged through In-App Purchases (IAP)
- The
is_wallet_balance_sufficientfield indicates whether the current wallet balance can cover the purchase
Notes
- All prices include tax calculations
- Payment methods are restricted to wallet only for mobile applications
- Wallet recharging through IAP is covered in the In-App Purchases documentation