> ## 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.

# Payment Orchestration

> Orchestrate complex payment flows.

This endpoint allows you to orchestrate complex payment flows, by breaking the transaction into multiple destination accounts, for example to account for partner commission, transaction routing, and so on.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://developers.flouci.com/api/v2/generate_payment' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <PUBLIC_KEY>:<PRIVATE_KEY>' \
    -d '{
      "amount": 10000,
      "success_link": "https://your-website.com/success",
      "fail_link": "https://your-website.com/fail",
      "webhook": "https://your-website.com/webhook",
      "developer_tracking_id": "<YOUR_TRACKING_ID>",
      "destination": [
          {
              "amount": 8000,
              "destination": "1234"
          }  ,{
              "amount": 2000,
              "destination": "4321"
          }
      ]
    }'
  ```
</RequestExample>

### Body

<ParamField body="amount" type="integer" 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="accept_card" type="boolean" default="false">
  Whether to accept card payments.
</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>

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

<ParamField body="destination" type="array">
  A list of destination objects specifying the distribution of the transaction amount. Each destination must include:

  <ul>
    <li><b>amount</b> (integer): The amount in millimes to send to this destination. The sum of all destination amounts must not exceed the total <code>amount</code> of the transaction.</li>
    <li><b>destination</b> (string): A valid Flouci Merchant ID that can receive the funds</li>
  </ul>
</ParamField>

<ResponseExample>
  ```json Success theme={null}
  {
    "result": {
      "payment_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
      "link": "https://flouci.com/pay/a1b2c3d4-e5f6-7890-1234-567890abcdef"
    }
  }
  ```

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