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

# Paying for orders using bulk payments

> Pay for multiple orders using a single transfer of funds

### Requirements to start the flow.

<CardGroup cols={1}>
  <Card title="API key" icon="shield-keyhole">
    Have an API key ([Tutorial here](/quickstart#api-key-generation)).
  </Card>
</CardGroup>

### <Icon icon="arrow-progress" iconType="solid" /> Order flow

Some customers, especially those with smaller transaction sizes, may need to settle multiple orders at once in order to mitigate the operational overhead of paying for each transaction independently. To support this use case, we have created a suite of endpoints that allow users to pay for more than one buy order with a single bank transfer and more than one sell order with a single blockchain transaction. This guide will walk you through how to use the bulk crypto payment system for off ramps.

<Steps>
  <Step title="Create bulk payment">
    Before you can start creating orders, you need to create a bulk payment that you will use to pay for multiple orders at once. This needs to be done each time you want to create a new set of orders that a single payment will cover.

    Assuming you want to sell USDC (Solana) in Mexico, then you would pass the following fields in the request body:

    ```javascript theme={null}
    {
      "crypto":"SOL_USDC_PTHX",
      "country":"MX"
    }
    ```

    <Card title="Create bulk crypto payment" icon="square-code" href="/api-reference/crypto-payments/create-bulk-crypto-payment" />
  </Step>

  <Step title="Create a quote">
    Create a quote for the order. Assuming you would like to sell USDC (Solana) for MXN, you would provide the following fields in the body:

    ```javascript theme={null}
      {
        "side":"sell",
        "crypto":"SOL_USDC_PTHX",
        "fiat":"MXN",
        "country":"MX"
      }
    ```

    Additionally, you need to specify the order size. You can either specify how much USDC (Solana) you would like to sell, like this (selling \$150,000 USDC (Solana)):

    ```javascript theme={null}
    "amountCrypto":150000
    ```

    Or you can alternatively specify the amount of MXN you would like to receive, like this (receiving \$1,000,000 MXN):

    ```javascript theme={null}
    "amountFiat":1000000
    ```

    <Card title="Go to create quote endpoint" icon="square-code" href="/api-reference/quotes/create-quote" />
  </Step>

  <Step title="Create order">
    Once you are satisfied with a quote, you can create an order to book the trade. Assuming you would like to continue with the quote you created in the previous step to sell USDC (Solana) for MXN, then you would provide the following body:

    ```javascript theme={null}
    {
        "quoteId":"{{QUOTE_ID_FROM_PREVIOUS_RESPONSE}}",
        "payoutBankAccountId":"{{ID_OF_MXN_BANK_ACCOUNT}}",
        "bulkCryptoPaymentId":"{{ID_FROM_RESPONSE_OF_STEP_1}}",
        "usePreSettlement":true
    }
    ```

    <Card title="Go to create order" icon="square-code" href="/api-reference/orders/create-order" />
  </Step>

  <Step title="Create more orders (optional)">
    Before settling this order, you can create other orders with the same
    `bulkCryptoPaymentId`. By doing so, you will add them to the bulk crypto
    payment and thus will only need to make one payment to settle multiple orders.
  </Step>

  <Step title="Wait for the order to be ready to accept payment">
    After creating an order, it will update its `status` field as it goes through its lifecycle. Once the `status` field is equal to `awaitingPayment`, the order is ready to receive payment. When all of the orders you added to the bulk crypto payment are in this status, you can get ready to send the payment.&#x20;

    <Card title="Go to check order status" icon="square-code" href="/api-reference/orders/get-order" />
  </Step>

  <Step title="Get payment instructions">
    Retrieve payment amount and the deposit address specified by the bulk payment you created earlier.&#x20;

    <Card title="Get crypto bulk payment" icon="square-code" href="/api-reference/crypto-payments/get-bulk-crypto-payment" />
  </Step>

  <Step title="Complete payment">
    Send the USDC (Solana) specified by the `amount` field of the bulk crypto
    payment to the address specified by the `depositAddress` field of the bulk
    crypto payment. Make sure to send the exact amount to avoid delays.&#x20;
  </Step>

  <Step title="Order is complete">
    Since the funds have been pre-settled, the order is now complete. You will be able to view the details of the payout by inspecting the `payoutsSent` field of the `order`.
  </Step>
</Steps>

#### <Icon icon="check-to-slot" iconType="solid" /> Poll order status or subscribe to webhooks

<Card title="Go to check order status" icon="square-code" href="/api-reference/orders/get-order" />

<Note>
  **Disclaimer**: All technical documentation is subject to the terms and
  conditions, which apply supplementarily and take precedence over the
  documentation.
</Note>
