Skip to main content

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

ParameterTypeRequiredDescription
productsarrayYesArray of products to be processed
products.*.with_certificatebooleanNoWhether to include certificate with the product
products.*.with_summarybooleanNoWhether to include summary with the product
paymentbooleanYesMust be set to true for checkout page
order_confirmedbooleanNoMust be false or omitted for checkout page
couponstringNoCoupon code to apply discount
use_new_customer_discountbooleanNoWhether 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

  1. Validates the incoming request parameters
  2. Creates cart collection from products array
  3. Applies any coupon discounts if provided
  4. Checks eligibility for new customer discount
  5. Calculates prices including tax
  6. Checks wallet balance and eligibility
  7. 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_discount parameter

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_sufficient field 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