# Booking an open trip

This feature allows users (customers and merchants) book trips for themselves or on behalf of others. The created trip calculates the quote based on the configurations used for booking standard trips (customers) or configurations set by the merchants.&#x20;

## Collect trip information

The `trip_type`, `category_size`, `scheduled_date`, `source`, and `destination` parameters are required to create an open trip. We also collect `email`, `phone`, `first_name`, and `last_name` fields for the user, they are also optional fields. The created trip will be attributed to the user information passed.

```
Endpoint
https://dodge.truq.it/booking-service/booking/booking-trip/create_open_trip/
-H "Authorization: Bearer YOUR_PUBLIC_KEY"
-H "Organisation: YOUR_REFERENCE"
-X POST
```

## Types of Open Trips

There are two (2) types of open trips that can be initiated:

1. Merchant Open Trip: A merchant open trip is created when a merchant coupon is passed in the `coupon` field. The trip created is attributed to the user information passed in the request. The trip also calculates and displays the discounted amount gotten from the discount code

```
Request Body

{
    "last_name": "doe",
    "phone": "2348113780934",
    "first_name": "john",
    "email": "user@gmail.com",
    "trip_type": "INTRASTATE",
    "category_size": "8ebe0127-5081-48d8-8791-92a15b364660",
    "extras": {
        "shrink_wraps": 2,
        "loaders": 4,
        "destination_storeys": 2,
        "source_storeys": 3
    },
    "scheduled_date": "2024-07-15T12:30:00+01:00",
    "destination": {
        "city": "LAGOS",
        "state": "Lagos",
        "longitude": 3.4457216,
        "latitude": 6.4222015,
        "address": "Landmark Village, 4 Water Corporation Dr, Victoria Island, Lagos 106104, Lagos, Nigeria",
        "stops": {
            "number": 2,
            "stopovers": []
        }
    },
    "estimated_value": "222222",
    "source": {
        "city": "LAGOS",
        "state": "Lagos",
        "longitude": 3.4262558,
        "latitude": 6.435140899999999,
        "address": "1 Engineering Close, Victoria Island, Lagos 106104, Lagos, Nigeria"
    },
    "coupon": "GANGA-COMMUNITY-1"
}
```

```
Response Body

{
    "status": "SUCCESS",
    "message": "Successfully created trip",
    "data": {
        "id": "0e5dbd1f-xxxx-xxxx-xxxx-3a811e9ae624",
        "user": {
            "id": "2b81bf2f-xxxx-xxxx-xxxx-49ea568ad83f",
            "email": "user@gmail.com",
            "first_name": "john",
            "last_name": "doe",
            "phone": "2348113780934"
        },
        "reference": "TRUH0D4F6LF7XXXX",
        "waybill_number": "WJ1794UN",
        "organisation": "TRU_H0D4",
        "is_interoperability": false,
        "interoperability_details": {},
        "is_advanced_payment": false,
        "advanced_payment": {},
        "driver": null,
        "category_size": {
            "id": "8ebe0127-5081-48d8-8791-92a15b364660",
            "category": "0.2TONNE",
            "tonnage": "0.2"
        },
        "coupon": {
            "key": "VP6YVDFE",
            "code": "GANGA-COMMUNITY-1",
            "discount": "10"
        },
        "trip_type": "INTRASTATE",
        "system_trip_type": "VARIABLE",
        "source": {
            "city": "LAGOS",
            "state": "Lagos",
            "address": "1 Engineering Close, Victoria Island, Lagos 106104, Lagos, Nigeria",
            "latitude": 6.435140899999999,
            "longitude": 3.4262558
        },
        "destination": {
            "city": "LAGOS",
            "state": "Lagos",
            "stops": {
                "number": 2,
                "stopovers": []
            },
            "address": "Landmark Village, 4 Water Corporation Dr, Victoria Island, Lagos 106104, Lagos, Nigeria",
            "latitude": 6.4222015,
            "longitude": 3.4457216
        },
        "insurance_details": {},
        "extras": {
            "loaders": 4,
            "shrink_wraps": 2,
            "source_storeys": 3,
            "destination_storeys": 2
        },
        "is_transit": false,
        "is_completed": false,
        "distance": "5.16",
        "created_at": "2024-06-19T11:28:10.154445Z",
        "status": "AWAITING-PAYMENT",
        "system_status": "AWAITING-PAYMENT",
        "is_insured": true,
        "estimated_value": "222222.00",
        "insurance_status": false,
        "is_paid": false,
        "quote": {
            "base_fare": "1516.00",
            "charge": "1587.14",
            "checkout_url": "https://checkout.paystack.com/qnpnbh2ydzu3g6p",
            "cost_per_kilometer": null,
            "currency": "NGN",
            "estimated_insurance": "0",
            "estimated_value": "0",
            "insurance_premium": "0",
            "reference": "TRP5P1MFLWCC",
            "sub_total": null,
            "total_charge": "1738.74",
            "total_vat": "32.97",
            "vat_type": "NET_VAT",
            "vat_value": "22.74",
            "waybill_number": null,
            "suggested_price": "0",
            "system_charge": "1738.74",
            "system_total_charge": "1738.74",
            "system_base_fare": "1516.00",
            "system_base_platform": "303.20",
            "system_platform_fee": "133.79",
            "discount_amount": "151.60",
            "manager_discount": "79.36",
            "state_price": "0",
            "dest_state_city_price": "0",
            "source_state_city_price": "0",
            "loaders": "0",
            "shrink_wraps": "200",
            "source_storeys": null,
            "destination_storeys": null
        },
        "confirmation": {},
        "user_journey": [
            {
                "time": "2024-06-19 11:28:10.246401+00:00",
                "status": "INITIATED",
                "message": "Trip Initiated",
                "latitude": null,
                "longitude": null,
                "system_status": "INITIATED"
            },
            {
                "time": "2024-06-19 11:28:11.416623+00:00",
                "status": "AWAITING-PAYMENT",
                "message": "Awaiting payment",
                "latitude": null,
                "longitude": null,
                "system_status": "AWAITING-PAYMENT"
            }
        ],
        "business_tripset": {
            "user": "aede0acc-3160-4a55-92f7-07364785d42e",
            "business": "GAN-FMYL",
            "is_default": true,
            "tripset_id": "fea26517-xxxx-xxxx-xxxx-0d4bfd85e934",
            "business_id": "2e6c4862-xxxx-xxxx-xxxx-647d51f62111",
            "is_merchant": true,
            "account_manager": "4c579a8d-xxxx-xxxx-xxxx-8ab3bdb98310",
            "tripset_reference": "TRPJL2K8XXXX"
        },
        "is_ims": false,
        "is_bulk_ims": false,
        "ims_orderset": null,
        "scheduled_date": "2024-07-15T11:30:00Z",
        "updated_at": "2024-06-19T11:28:11.455921Z"
    }
}
```

2. Customer Open Trip: A customer open trip is created when the trip is initiated without a merchant coupon code. A coupon code (not belonging to a merchant) can be applied, and the dicount is calculated and displayed

```
Request body

{
    "last_name": "doe",
    "phone": "2348113780934",
    "first_name": "john",
    "email": "user@gmail.com",
    "trip_type": "INTRASTATE",
    "category_size": "8ebe0127-5081-48d8-8791-92a15b364660",
    "extras": {
        "shrink_wraps": 2,
        "loaders": 4,
        "destination_storeys": 2,
        "source_storeys": 3
    },
    "scheduled_date": "2024-07-15T12:30:00+01:00",
    "destination": {
        "city": "LAGOS",
        "state": "Lagos",
        "longitude": 3.4457216,
        "latitude": 6.4222015,
        "address": "Landmark Village, 4 Water Corporation Dr, Victoria Island, Lagos 106104, Lagos, Nigeria",
        "stops": {
            "number": 2,
            "stopovers": []
        }
    },
    "estimated_value": "222222",
    "source": {
        "city": "LAGOS",
        "state": "Lagos",
        "longitude": 3.4262558,
        "latitude": 6.435140899999999,
        "address": "1 Engineering Close, Victoria Island, Lagos 106104, Lagos, Nigeria"
    }
}
```

```
"status": "SUCCESS",
    "message": "Successfully created trip",
    "data": {
        "id": "54534169-xxxx-xxxx-xxxx-9b4956158520",
        "user": {
            "id": "2b81bf2f-xxxx-xxxx-xxxx-49ea568ad83f",
            "email": "user@gmail.com",
            "first_name": "john",
            "last_name": "doe",
            "phone": "2348113780934"
        },
        "reference": "TRUH0D4XXXXEAI8B",
        "waybill_number": "QN1DTP12",
        "organisation": "TRU_H0D4",
        "is_interoperability": false,
        "interoperability_details": {},
        "is_advanced_payment": false,
        "advanced_payment": {},
        "driver": null,
        "category_size": {
            "id": "8ebe0127-5081-48d8-8791-92a15b364660",
            "category": "0.2TONNE",
            "tonnage": "0.2"
        },
        "coupon": {
            "key": "invalid_code",
            "code": null
        },
        "trip_type": "INTRASTATE",
        "system_trip_type": "VARIABLE",
        "source": {
            "city": "LAGOS",
            "state": "Lagos",
            "address": "1 Engineering Close, Victoria Island, Lagos 106104, Lagos, Nigeria",
            "latitude": 6.435140899999999,
            "longitude": 3.4262558
        },
        "destination": {
            "city": "LAGOS",
            "state": "Lagos",
            "stops": {
                "number": 2,
                "stopovers": []
            },
            "address": "Landmark Village, 4 Water Corporation Dr, Victoria Island, Lagos 106104, Lagos, Nigeria",
            "latitude": 6.4222015,
            "longitude": 3.4457216
        },
        "insurance_details": {},
        "extras": {
            "loaders": 4,
            "shrink_wraps": 2,
            "source_storeys": 3,
            "destination_storeys": 2
        },
        "is_transit": false,
        "is_completed": false,
        "distance": "5.16",
        "helper_info": {},
        "created_at": "2024-06-19T10:46:40.267361Z",
        "status": "AWAITING-PAYMENT",
        "system_status": "AWAITING-PAYMENT",
        "is_insured": true,
        "estimated_value": "222222.00",
        "insurance_status": false,
        "is_paid": false,
        "quote": {
            "base_fare": "1000.00",
            "charge": "1738.74",
            "checkout_url": "https://checkout.paystack.com/67oh6wvvzg38qoa",
            "cost_per_kilometer": "516.00",
            "currency": "NGN",
            "estimated_insurance": "0.00",
            "estimated_value": 222222.0,
            "insurance_premium": "0.00",
            "reference": "TRPVEB8QEZIU",
            "sub_total": "1516.00",
            "total_charge": "1738.74",
            "total_vat": "32.97",
            "vat_type": "NET_VAT",
            "vat_value": "22.74",
            "waybill_number": "QN1DTP12",
            "suggested_price": "0",
            "system_charge": "1738.74",
            "system_total_charge": "1738.74",
            "system_base_fare": "1000.00",
            "system_base_platform": "303.20",
            "system_platform_fee": "133.79",
            "discount_amount": null,
            "manager_discount": null,
            "state_price": null,
            "dest_state_city_price": null,
            "source_state_city_price": null,
            "loaders": "0.00",
            "shrink_wraps": "200.00",
            "source_storeys": null,
            "destination_storeys": null
        },
        "confirmation": {},
        "user_journey": [
            {
                "time": "2024-06-19 10:46:40.374718+00:00",
                "status": "INITIATED",
                "message": "Trip Initiated",
                "latitude": null,
                "longitude": null,
                "system_status": "INITIATED"
            },
            {
                "time": "2024-06-19 10:46:41.156260+00:00",
                "status": "AWAITING-PAYMENT",
                "message": "Awaiting payment",
                "latitude": null,
                "longitude": null,
                "system_status": "AWAITING-PAYMENT"
            }
        ],
        "business_tripset": null,
        "is_ims": false,
        "is_bulk_ims": false,
        "ims_orderset": null,
        "scheduled_date": "2024-07-15T11:30:00Z",
        "updated_at": "2024-06-19T10:46:41.169690Z"
    }
}
```
