> ## Documentation Index
> Fetch the complete documentation index at: https://dev.chargily.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a checkout

> Creates a new checkout.

## Body parameters

<ParamField body="items" type="array" multiple>
  **Required if the parameters `amount` and `currency` are not provided.**

  The items are the products that are being sold.

  <Expandable title="items">
    <ParamField body="price" type="string" required>
      The ID of the [Price](/v2/api-reference/prices/price-object "Price").
    </ParamField>

    <ParamField body="quantity" type="integer" required>
      The quantity of the item.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="amount" type="integer">
  **Required if the parameter `items` is not provided.**

  The total amount of the checkout.
</ParamField>

<ParamField body="currency" type="string">
  **Required if the parameter `amount` is provided.**

  A lowercase [ISO currency
  code](https://www.iso.org/iso-4217-currency-codes.html "ISO currency code").
  Currently supported currencies are: "dzd".
</ParamField>

<ParamField body="payment_method" type="string" default="edahabia">
  The payment method that will be used to pay the checkout. Currently supported
  payment methods are: "edahabia", "cib" and "chargily\_app". The customer can always change the payment method at the checkout page.

  **When the payment method is "chargily\_app", a "qr\_code\_url" param will be returned in the response.**
</ParamField>

<ParamField body="success_url" type="string" required>
  The URL where your customer will be redirected after a successful payment.
</ParamField>

<ParamField body="customer_id" type="string">
  The ID of an existing [Customer](/v2/api-reference/customers/customer-object "Customer").
</ParamField>

<ParamField body="failure_url" type="string">
  The URL where your customer will be redirected after a failed or canceled
  payment.
</ParamField>

<ParamField body="webhook_endpoint" type="string">
  The URL of your endpoint that will receive the webhook events sent by Chargily
  Pay.
</ParamField>

<ParamField body="description" type="string">
  A description of the checkout. You can use this field to save a note about the
  checkout.
</ParamField>

<ParamField body="locale" type="string">
  The language of the checkout page, accepted values are: 'ar', 'en' or 'fr'.
</ParamField>

<ResponseField name="pass_fees_to_customer" type="boolean">
  **DEPRECATED, use chargily\_pay\_fees\_allocation instead.**

  A Boolean value indicates whether the Chargily Pay fees will be paid by you,
  the merchant, or your customers.
</ResponseField>

<ResponseField name="chargily_pay_fees_allocation" type="string">
  Can be one of "customer", "merchant" or "split".

  Choose who is going to pay Chargily Pay fees ("Merchant" means you will pay the fees, "Customer" means the customer will pay the fees, "Split" means you will split the fees with the customer).
</ResponseField>

<ParamField body="shipping_address" type="string">
  The shipping address of the customer for the checkout.
</ParamField>

<ParamField body="collect_shipping_address" type="boolean">
  A Boolean value indicates whether the shipping address should be collected
  from the customer.
</ParamField>

<ParamField body="percentage_discount" type="integer">
  **Prohibited if the parameter `amount_discount` is provided.**

  A percentage discount that will be applied to the total amount of the
  checkout.
</ParamField>

<ParamField body="amount_discount" type="integer">
  **Prohibited if the parameter `percentage_discount` is provided.**

  An amount discount that will be applied to the total amount of the checkout.
</ParamField>

<ParamField body="metadata" type="array">
  A Set of key-value pairs that can be used to store additional information
  about the product.
</ParamField>

## Returns

If the request is successful, it returns a checkout object.

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "01hj5n7cqpaf0mt2d0xx85tgz8",
    "entity": "checkout",
    "livemode": false,
    "amount": 2500,
    "currency": "dzd",
    "fees": 0,
    "fees_on_merchant": 0,
    "fees_on_customer": 0,
    "pass_fees_to_customer": null,
    "chargily_pay_fees_allocation": "customer",
    "status": "pending",
    "locale": "en",
    "description": null,
    "metadata": null,
    "success_url": "https://my-app.com/payments/success",
    "failure_url": "https://my-app.com/payments/failure",
    "webhook_endpoint": null,
    "payment_method": null,
    "invoice_id": null,
    "customer_id": "01hj150206g0jxnh5r2yvvdrna",
    "payment_link_id": null,
    "created_at": 1703144567,
    "updated_at": 1703144567,
    "shipping_address": null,
    "collect_shipping_address": 0,
    "discount": {
      "type": "percentage",
      "value": 50
    },
    "amount_without_discount": 5000,
    "checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"
  }
  ```
</ResponseExample>
