Checkout
This endpoint allows you to retrieve the cart items with payment calculations and available payment methods for authenticated users.
Endpoint
POST /v1/customer/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 |
| use_wallet | boolean | No | Whether to use wallet balance for payment |
Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"cart_items": [
{
"id": "09d53ec0-b305-11ef-98a6-735d2de688a2",
"poster": "https://example.com/image.png",
"name": "Course Name",
"price": 250,
"price_after_tax": 287.5,
"type": "course",
"count": 1,
"has_active_subscribed": false,
"duration": 730,
"old_price": null,
"has_certificate": true,
"certificate_price": 50,
"has_summary": false,
"summary_price": 0,
"gift": null
}
],
"subtotal": 250,
"tax": 37.5,
"total": 287.5,
"total_after_discount": 287.5,
"can_use_wallet": true,
"available_balance": 100,
"can_use_new_customer_discount": true,
"payment_methods": [
"credit_card",
"bank_transfer",
"spotii",
"tamara",
"tabby",
"apple_pay",
"paytabs",
"wallet"
]
},
"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 available payment methods
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 balance must be positive
- For gift purchases, only giftable balance can be used
- Must be explicitly requested via
use_walletparameter
Common error cases:
- Invalid coupon code
- Insufficient wallet balance
Notes
- All prices include tax calculations
- Wallet usage is currently disabled in the system