> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.kreezalid.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Handling Cart/Order After Preauth Success

When a preauthorization (preauth) for a payment is successful in your frontend payment process, you need to communicate this information to the Kreezalid backend to handle the associated cart and/or order appropriately. This guide explains how to do this using the `POST` endpoint `/checkout/preauth-success` of the Kreezalid Admin API.

## Endpoint

`POST` api/v1/checkout/preauth-success

## Request Body

 The following parameters should be included in the request body:

```
{
    "checkout_entity_type": "cart",
    "checkout_entity_id": "123456",
    "transaction_id" : "444",
    "tos_acceptance_at" : "2023-09-22 14:30:00",
    "customer_checkout_message": "Pellentesque vitae volutpat nisi, vitae porta metus.",
    "request": "",
    "response": "",
    "note": ""
}
```

### Parameters

- **checkout_entity_type** (required): The type of entity being checked out, which can be either "cart" or "order." In this case, it's "cart" for a shopping cart.

- **checkout_entity_id** (required): The unique identifier associated with the cart or order. This could be an order ID or a cart ID depending on the `checkout_entity_type`.

- **transaction_id** (required): A unique identifier for the transaction resulting from the preauth. This is often provided by your payment gateway.

- **tos_acceptance_at** (required): The date and time when the customer accepted the terms of service or agreement related to the payment.

- **customer_checkout_message**: A message or note from the customer regarding their checkout. This can be helpful for any special instructions or comments.

- **request**: Additional information related to the request, if needed.

- **response**: Any response data from the preauth process.

- **note**: A general note or comment related to the preauth or checkout process.

## Preauth Success Handling

1. **Preauth Initiation**: In your frontend, after the payment preauth is successful, you should make a `POST` request to the `/checkout/preauth-success` endpoint of the Kreezalid Admin API. Include all the required parameters mentioned above in the request body.

2. **Backend Processing**: The Kreezalid Backend should receive the request and validate the data sent from the frontend. Ensure that the `transaction_id` is unique and corresponds to the preauth that occurred. Save any additional information, such as the `customer_checkout_message`.

3. **Cart/Order Update**: Depending on the `checkout_entity_type` ("cart" or "order"), the status of the associated cart or order will be updated. For example, if it's a cart, it will be closed and its contained orders status will be updated to "new" while waiting for the vendor to accept the order.

4. **Confirmation**: A response will be sent back to the frontend to confirm that the preauth success was handled successfully. If there are any errors, they will be included in the response.

By following these steps, you can effectively handle cart and/or order management after a preauth success in your frontend payment process.
