Skip to content
Last updated

Order Operations

Order endpoints allow you to create and manage car rental reservations. The order system handles the complete booking workflow including vehicle selection, passenger information, billing details, and integration with payment processing.

Create Order

Creates a new car rental order. This endpoint initiates the comprehensive booking process including vehicle reservation, passenger registration, and payment preparation.

Endpoint

POST /order

Authentication

This endpoint requires authentication. Include your JWT access token in the Authorization header:

Authorization: Bearer YOUR_ACCESS_TOKEN

Request Body

FieldTypeRequiredDescription
paymentTypestringYesPayment method: creditCard or limit
searchIDstringYesSearch ID obtained from vehicle search results
codestringYesSelected vehicle product code from search results
extraProductsarrayNoList of additional products and services
passengerobjectYesPrimary passenger information
billingobjectNoCustom billing address (optional, defaults to passenger info)
isFullCreditbooleanNoUse full credit payment (agency must be authorized)
isLimitedCreditbooleanNoUse limited credit payment (agency must be authorized)

Extra Products

FieldTypeRequiredDescription
codestringYesProduct code from extra products search
quantityintegerYesQuantity to add (minimum 1)

Passenger Information

FieldTypeRequiredDescription
firstNamestringYesPassenger first name
lastNamestringYesPassenger last name
emailstringYesValid email address
nationalitystringYesISO country code (2 characters)
phonestringYesPhone number in E.164 format
birthDatestringYesBirth date (YYYY-MM-DD format)
identityNumberstringNo11-digit identity number (for Turkish citizens)
passportNostringNoPassport number (for international travelers)

Billing Address (Optional)

FieldTypeRequiredDescription
typestringYesAddress type: individual or corporateCompany
labelstringNoCustom label for the address
firstNamestringYesBilling first name
lastNamestringNoBilling last name
emailstringNoBilling email address
phonestringNoBilling phone number
countryNamestringYesFull country name
countryCodestringYesISO country code (2 characters)
adm1stringYesAdministrative division level 1 (state/province)
adm2stringNoAdministrative division level 2 (city/district)
linestringNoAddress line (street address)
zipCodestringNoPostal/ZIP code
taxDivisionstringNoTax office/division
taxIdentifierstringNoTax ID number

Example Request

curl -X POST https://api.pro.yolcu360.com/api/v1/order \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "paymentType": "creditCard",
    "searchID": "search_123456789",
    "code": "ECAR",
    "isFullCredit": true,
    "isLimitedCredit": false,
    "extraProducts": [
      {
        "code": "GPS",
        "quantity": 1
      },
      {
        "code": "CDW",
        "quantity": 1
      }
    ],
    "passenger": {
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "nationality": "US",
      "phone": "+1234567890",
      "birthDate": "1990-01-15",
      "passportNo": "ABC123456"
    },
    "billing": {
      "type": "individual",
      "label": "Home Address",
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "phone": "+1234567890",
      "countryName": "United States",
      "countryCode": "US",
      "adm1": "California",
      "adm2": "Los Angeles",
      "line": "123 Main Street",
      "zipCode": "90210"
    }
  }'

Response

Success Response (201 Created):

{
  "id": "order_123456789",
  "paymentType": "creditCard",
  "paymentCurrency": "TRY",
  "language": "en",
  "createdAt": "2024-12-25T10:00:00Z",
  "updatedAt": "2024-12-25T10:00:00Z",
  "passenger": {
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "nationality": "US",
    "phone": "+1234567890"
  },
  "billing": {
    "type": "individual",
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "phone": "+1234567890"
  },
  "orderedCarProduct": {
    "id": 1001,
    "status": "pending",
    "quantity": 1,
    "isFullCredit": true,
    "isLimitedCredit": false,
    "vendorCancelled": false,
    "createdAt": "2024-12-25T10:00:00Z",
    "updatedAt": "2024-12-25T10:00:00Z",
    "car": {
      "code": "ECAR",
      "searchID": "search_123456789",
      "brand": {
        "id": "toyota",
        "name": "Toyota"
      },
      "model": {
        "id": "corolla",
        "name": "Corolla"
      },
      "class": {
        "id": "economy",
        "name": "Economy"
      },
      "imageURL": "https://example.com/car-image.jpg",
      "pricing": {
        "total": {
          "amount": 50000,
          "currency": "TRY"
        },
        "paymentTotal": {
          "amount": 50000,
          "currency": "TRY"
        }
      }
    }
  },
  "orderedExtraProducts": [
    {
      "id": 1002,
      "status": "pending",
      "quantity": 1,
      "vendorCancelled": false,
      "createdAt": "2024-12-25T10:00:00Z",
      "updatedAt": "2024-12-25T10:00:00Z",
      "extraProduct": {
        "code": "GPS",
        "name": "GPS Navigation System",
        "type": "equipment",
        "pricing": {
          "total": {
            "amount": 1500,
            "currency": "TRY"
          }
        }
      }
    },
    {
      "id": 1003,
      "status": "pending",
      "quantity": 1,
      "vendorCancelled": false,
      "createdAt": "2024-12-25T10:00:00Z",
      "updatedAt": "2024-12-25T10:00:00Z",
      "extraProduct": {
        "code": "CDW",
        "name": "Collision Damage Waiver",
        "type": "insurance",
        "pricing": {
          "total": {
            "amount": 3000,
            "currency": "TRY"
          }
        }
      }
    }
  ]
}

Order Status Values

StatusDescription
pendingItem added to order, awaiting confirmation
reservedItem successfully reserved with vendor
failedItem reservation failed
cancelledItem cancelled by user or vendor
removedItem removed from order

Get Order Details

Retrieve comprehensive details of a specific order including current status, passenger information, ordered products, and payment information.

Endpoint

GET /order/{orderID}

Authentication

This endpoint requires authentication. Include your JWT access token in the Authorization header.

Path Parameters

ParameterTypeRequiredDescription
orderIDstringYesUnique order identifier

Example Request

curl -X GET https://api.pro.yolcu360.com/api/v1/order/order_123456789 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

Success Response (200 OK):

Returns the same structure as the create order response, with updated status information and any changes that have occurred since creation.

{
  "id": "order_123456789",
  "paymentType": "creditCard",
  "paymentCurrency": "TRY",
  "language": "en",
  "createdAt": "2024-12-25T10:00:00Z",
  "updatedAt": "2024-12-25T10:15:00Z",
  "passenger": {
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "nationality": "US",
    "phone": "+1234567890"
  },
  "orderedCarProduct": {
    "id": 1001,
    "status": "reserved",
    "quantity": 1,
    "isFullCredit": false,
    "vendorCancelled": false,
    "vendorReservationID": "AVIS_RES_789012",
    "paymentID": 2001,
    "createdAt": "2024-12-25T10:00:00Z",
    "updatedAt": "2024-12-25T10:15:00Z",
    "car": {
      "code": "ECAR",
      "searchID": "search_123456789",
      "brand": {
        "id": "toyota",
        "name": "Toyota"
      },
      "model": {
        "id": "corolla",
        "name": "Corolla"
      }
    }
  },
  "orderedExtraProducts": [
    {
      "id": 1002,
      "status": "reserved",
      "quantity": 1,
      "paymentID": 2001,
      "vendorReservationID": "AVIS_GPS_789013"
    }
  ]
}

Check Cancel Eligibility

Checks whether an order is eligible for cancellation and refund. This endpoint does not modify the order but provides information about the cancellation and refund eligibility status.

Endpoint

POST /order/{orderID}/cancel_eligibility

Authentication

This endpoint requires authentication. Include your JWT access token in the Authorization header.

Path Parameters

ParameterTypeRequiredDescription
orderIDstringYesUnique identifier of order to check

Example Request

curl -X POST https://api.pro.yolcu360.com/api/v1/order/YLP_123456/cancel_eligibility \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

Success Response (200 OK):

{
  "cancellable": true,
  "refundable": true
}

Response Fields

FieldTypeDescription
cancellablebooleanWhether the order is eligible for cancellation
refundablebooleanWhether the order is eligible for refund if cancelled

Cancel Order

Cancels an existing order. The order must be in a cancellable state for this operation to succeed. This endpoint will attempt to cancel the order with the vendor and update the order status accordingly.

Endpoint

POST /order/{orderID}/cancel

Authentication

This endpoint requires authentication. Include your JWT access token in the Authorization header.

Path Parameters

ParameterTypeRequiredDescription
orderIDstringYesUnique identifier of order to cancel

Example Request

curl -X POST https://api.pro.yolcu360.com/api/v1/order/YLP_123456/cancel \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

Success Response (200 OK):

{
  "success": true,
  "message": "Order has been successfully cancelled",
  "orderId": "YLP_123456",
  "status": "success"
}

Cancel Status Values

StatusDescription
pendingCancellation request is being processed
successOrder was successfully cancelled
failedCancellation request failed

Order Creation Workflow

The order creation process involves multiple steps executed automatically by the system:

1. Order Initialization

  • Creates base order record
  • Validates search session and vehicle availability
  • Sets initial status to "open"

2. Product Addition

  • Adds selected vehicle to the order
  • Adds any selected extra products
  • Calculates total pricing including commissions

3. Passenger Registration

  • Validates passenger information
  • Stores passenger details securely
  • Links passenger to the order

4. Billing Setup

  • Uses custom billing address if provided
  • Falls back to passenger information for billing
  • Validates billing information completeness

5. Payment Preparation

  • Calculates final payment amounts
  • Determines payment requirements based on payment type
  • Prepares order for payment processing

Order Lifecycle

Yes
No
Create Order
Add Vehicle
Add Extra Products
Add Passenger Info
Add Billing Info
Calculate Totals
Order Ready for Payment
Process Payment
Payment Success?
Reserve with Vendor
Payment Failed
Order Complete
Retry Payment

Order Best Practices

Passenger Information

  • Required Fields: Ensure all mandatory passenger fields are provided
  • Document Validation: Provide either identity number (for domestic) or passport (for international)
  • Contact Information: Use valid email and phone number for notifications
  • Age Verification: Ensure passenger meets minimum age requirements

Billing Address

  • Optional Usage: Only provide billing address if different from passenger address
  • Corporate Orders: Use company billing information for business rentals
  • Tax Information: Include tax details for corporate billing addresses
  • Address Validation: Ensure address information is complete and accurate

Extra Products

  • Quantity Limits: Respect minimum and maximum quantity constraints
  • Compatibility: Verify product compatibility with selected vehicle
  • Pricing Updates: Extra product prices may change between search and order

Error Handling

Common Error Responses:

  • 400 Bad Request: Invalid order data or missing required fields
  • 401 Unauthorized: Authentication required or token expired
  • 404 Not Found: Search session expired or vehicle unavailable
  • 422 Unprocessable Entity: Validation errors in passenger or billing data
  • 500 Internal Server Error: System error during order processing

Example Error Response:

{
  "code": 1001,
  "description": "Invalid passenger information",
  "details": {
    "field": "passenger.email",
    "message": "Invalid email format"
  }
}

Validation Rules

Passenger Validation

  • Email: Must be valid email format
  • Phone: Must be in E.164 international format
  • Birth Date: Must be valid date and meet minimum age requirements
  • Nationality: Must be valid ISO country code
  • Identity/Passport: Required based on nationality and travel requirements

Credit Type Validation

  • Mutual Exclusivity: Only one of isFullCredit or isLimitedCredit can be true
  • Agency Authorization: Agency must be configured to use the selected credit type

Billing Validation

  • Type: Must be one of: individual, corporateCompany
  • Country: Country code must match country name
  • Corporate Fields: Tax division and identifier required for company types
  • Address: Administrative divisions must be valid for the country

Integration Examples

Basic Order Creation

async function createOrder(searchResult, passengerInfo) {
    const orderData = {
        paymentType: 'creditCard',
        searchID: searchResult.searchID,
        code: searchResult.code,
        passenger: {
            firstName: passengerInfo.firstName,
            lastName: passengerInfo.lastName,
            email: passengerInfo.email,
            nationality: passengerInfo.nationality,
            phone: passengerInfo.phone,
            birthDate: passengerInfo.birthDate
        }
    };

    const response = await fetch('/api/v1/order', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${accessToken}`
        },
        body: JSON.stringify(orderData)
    });

    if (!response.ok) {
        const error = await response.json();
        throw new Error(`Order creation failed: ${error.description}`);
    }

    return await response.json();
}

Order with Extra Products

async function createOrderWithExtras(searchResult, passengerInfo, selectedExtras) {
    const orderData = {
        paymentType: 'creditCard',
        searchID: searchResult.searchID,
        code: searchResult.code,
        extraProducts: selectedExtras.map(extra => ({
            code: extra.code,
            quantity: extra.quantity
        })),
        passenger: passengerInfo
    };

    return await createOrder(orderData);
}

Polling Order Status

async function waitForOrderCompletion(orderID, maxWaitTime = 300000) {
    const startTime = Date.now();

    while (Date.now() - startTime < maxWaitTime) {
        const order = await getOrder(orderID);

        if (order.status === 'closed') {
            return order;
        }

        if (order.orderedCarProduct.status === 'failed') {
            throw new Error('Order failed - vehicle reservation unsuccessful');
        }

        // Wait 5 seconds before checking again
        await new Promise(resolve => setTimeout(resolve, 5000));
    }

    throw new Error('Order completion timeout');
}

Rate Limiting

Order endpoints are subject to rate limiting:

  • Create order: Maximum 5 requests per minute per user
  • Get order: Maximum 60 requests per minute per user

Monitor rate limit headers in responses and implement appropriate retry logic.