Overview
The Orders API handles the creation and management of service orders. Orders connect clients with freelancers through purchased gig packages, integrating with YouCan Pay for payment processing.Mutations
create
Create a new order for a gig package with payment information. Input Parameters:Order amount in MAD
Payment transaction ID from payment provider
Unique order identifier
ID of the gig being purchased
ID of the specific package tier (basic, standard, or premium)
Order Model
Orders in the database follow this structure:Order Fields
Unique order identifier (CUID)
ID of the client placing the order
ID of the purchased gig
ID of the purchased package (basic, standard, or premium)
Order status:
pending, processing, completed, or cancelledDefault: pendingTotal order amount in MAD
Order creation timestamp
Last update timestamp
Relations
The client who placed the order
The purchased gig
The specific package tier purchased
Associated payment record (one-to-one)
Payment Model
Payments associated with orders:Payment Fields
Unique payment identifier (CUID)
Associated order ID (unique)
Payment status:
pending, success, or failedDefault: pendingPayment amount in MAD
Payment method used (e.g., “card”, “bank_transfer”)
External transaction ID from payment provider
Payment creation timestamp
Last update timestamp
Payment Integration
Khedma Market integrates with YouCan Pay for payment processing.tokenizePayment()
Server-side function to tokenize a payment with YouCan Pay. Parameters:amount(number): Payment amountcurrency(string): Currency code (e.g., “MAD”)order_id(string): Unique order identifier
YouCan Pay API Flow
-
Tokenize: Create a payment token
-
Response: Receive token
- Process: Use token to complete payment with YouCan Pay widget
Order Status Flow
- pending: Order created, awaiting payment
- processing: Payment confirmed, work in progress
- completed: Order delivered and accepted
- cancelled: Order cancelled by client or freelancer