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

# Generate Payment

> Generate a new payment and get a redirection link for the user to complete the payment in.

This endpoint creates a new payment and returns a URL to redirect the user to for completing the payment.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://developers.flouci.com/api/v2/generate_payment' \
    -H 'Authorization: Bearer <PUBLIC_KEY>:<PRIVATE_KEY>' \
    -H 'Content-Type: application/json' \
    -d '{
      "amount": "40300",
      "developer_tracking_id": "<YOUR_TRACKING_ID>",
      "accept_card": true,
      "success_link": "https://your-website.com/success",
      "fail_link": "https://your-website.com/fail",
      "webhook": "https://your-website.com/webhook",
      "client_id": "customer name or reference"
    }'
  ```
</RequestExample>

### Body

<ParamField body="amount" type="string" required>
  The amount to be paid in millimes.
</ParamField>

<ParamField body="success_link" type="string" required>
  The URL to redirect the user to after a successful payment.
</ParamField>

<ParamField body="fail_link" type="string" required>
  The URL to redirect the user to after a failed payment.
</ParamField>

<ParamField body="webhook" type="string">
  The webhook URL you want to receive payment confirmation on.
</ParamField>

<ParamField body="developer_tracking_id" type="string">
  An ID for you to track the payment. This is a free field that Flouci doesn't check against.
</ParamField>

<ParamField body="session_timeout_secs" type="integer" default="1200">
  The session timeout in seconds.
</ParamField>

<ParamField body="accept_card" type="boolean" default="false">
  Whether to accept card payments.
</ParamField>

<ParamField body="client_id" type="string">
  A customer name or reference to identify the payer. This is displayed on the payment page.
</ParamField>

<ParamField body="image_url" type="URL">
  The URL of the image to display on the payment page. This field is optional, and the default image is the image of the merchant in the Flouci portal.
</ParamField>

<ResponseExample>
  ```json Success theme={null}
  {
    "result": {
      "success": true,
      "payment_id": "FoPKKHqfQIKfBqhEj8M47A",
      "link": "https://flouci.com/pay/FoPKKHqfQIKfBqhEj8M47A",
      "developer_tracking_id": "<DEVELOPER_TRACKING_ID>"
    },
    "name": "developers",
    "code": 0,
    "version": "v2"
  }
  ```

  ```json Error theme={null}
  {
    "result": {
      "status": 400,
      "message": "Bad Request"
    }
  }
  ```
</ResponseExample>
