> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-881012b3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Payment Capture Settings using Orders API

> Configure auto-capture settings for individual payments using APIs.

<div style={{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.35rem 0.9rem",border:"1px solid rgba(128,128,128,0.28)",borderRadius:"0.5rem",padding:"0.45rem 0.75rem",margin:"0 0 1.25rem",fontSize:"0.875rem"}}>
  <span style={{fontWeight:600}}>Available in</span>
  <span>🇮🇳 India</span>
</div>

Once your customer completes a payment, it is automatically moved to `captured` state. However, the payment can attain `authorized` state in the following scenarios:<br />

* **Late authorization** <br />
  Due to external factors such as network issues or technical errors, Razorpay may not receive payment status from the bank immediately. In this case, Razorpay polls the APIs intermittently for 5 days to check the status. If we receive the payment status as successful, the payment is moved to the `authorized` state. [Learn more about late authorization](/docs/payments/payments/late-authorisation).
* **Specific business use case** <br />
  Some businesses such as those in the Ecommerce industry may retain the payment in the `authorized` state and later move them to the `captured` state.

You must ensure that all payments in the `authorized` state are moved to the `captured` state within 5 days of creation. This is mandatory because payments that are not captured within this time period will be refunded automatically to customers.

You can configure **Payment Capture setting** for individual payments using the Orders API.

<Warning>
  **Watch Out!**

  The options sent in the below API take precedence over the [account level auto-capture settings](/docs/payments/payments/capture-settings) configured using the Dashboard.
</Warning>

## API

Use the below endpoint to configure auto-capture settings for individual payments.

`POST /orders`

<CodeGroup>
  ```bash Curl theme={null}
  curl  -X POST https://api.razorpay.com/v1/orders
  -u <API_KEY>:<API_SECRET>
  -H 'content-type:application/json'
  -d '{
    "amount": 50000,
    "currency": "INR",
    "receipt": "rcptid_11",
    "payment": {
      "capture": "automatic",
      "capture_options": {
        "automatic_expiry_period": 12,
        "manual_expiry_period": 7200,
        "refund_speed": "optimum"
      }
    }
  }'
  ```

  ```java Java theme={null}
  RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  JSONObject orderRequest = new JSONObject();
  orderRequest.put("amount",50000);
  orderRequest.put("currency","INR");
  orderRequest.put("receipt", "rcptid_11");
  JSONObject payment = new JSONObject();
  payment.put("capture","automatic");
  JSONObject captureOptions = new JSONObject();
  captureOptions.put("automatic_expiry_period",12);
  captureOptions.put("manual_expiry_period",7200);
  captureOptions.put("refund_speed","optimum");
  payment.put("capture_options",captureOptions);
  orderRequest.put("payment",payment);
                
  Order order = razorpay.orders.create(orderRequest);
  ```

  ```python Python theme={null}
  import razorpay
  client = razorpay.Client(auth=("YOUR_ID", "YOUR_SECRET"))

  client.order.create({
    'amount':50000,
    'currency': 'INR',
    'receipt': 'rcptid_11',
    'payment': {
      'capture': 'automatic',
      'capture_options': {
        'automatic_expiry_period': 12,
        'manual_expiry_period': 7200,
        'refund_speed': 'optimum'
      }  
    }
  })
  ```

  ```php PHP theme={null}
  <?php

  $api = new Api($key_id, $secret);

  $api->order->create(
      array(
          'amount'   => 50000,
          'currency' => 'INR',
          'receipt'  => 'rcptid_11',
          'payment'  => array(
              'capture'       => 'automatic',
              'capture_options' => array(
                  'automatic_expiry_period' => 12,
                  'manual_expiry_period'    => 7200,
                  'refund_speed'            => 'optimum'
              )
          )
      )
  );
  ```

  ```ruby Ruby theme={null}
  require "razorpay"
  Razorpay.setup('YOUR_KEY_ID', 'YOUR_SECRET')

  para_attr = {
    "amount":50000,
    "currency": "INR",
    "receipt": "rcptid_11",
    "payment": {
      "capture ": "automatic",
      "capture_options ": {
        "automatic_expiry_period ": 12,
        "manual_expiry_period ": 7200,
        "refund_speed": "optimum"
      }  
    }
  }
  Razorpay::Order.create(para_attr)
  ```

  ```javascript Node.js theme={null}
  var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })

  instance.orders.create({
    amount:50000,
    currency: 'INR',
    receipt: 'rcptid_11',
    payment: {
      capture : 'automatic',
      capture_options : {
        automatic_expiry_period : 12,
        manual_expiry_period : 7200,
        refund_speed : 'optimum'
      }  
    }
  })
  ```

  ```csharp .NET theme={null}
  RazorpayClient client = new RazorpayClient(api_key, api_secret);

  Dictionary<string, object> options = new Dictionary<string,object>();
  options.Add("amount", 50000); // amount in the smallest currency unit
  options.Add("receipt", "order_rcptid_11");
  options.Add("currency", "INR");
  payment.capture="automatic";
  payment.capture_options.automatic_expiry_period=12;
  payment.capture_options.manual_expiry_period=7200;
  payment.capture_options.refund_speed="optimum";
  options.Add("payment", payment);
  Order order = client.Order.Create(options);
  ```

  ```go Go theme={null}
  import ( razorpay "github.com/razorpay/razorpay-go" )

  client := razorpay.NewClient("api_key", "api_secret")

  data := map[string]interface{}{ 
    "amount": 1234, 
    "currency": "INR", 
    "receipt": "some_receipt_id", 
    "payment": map[string]interface{}{ 
      "capture": "automatic", 
      "capture_options": map[string]interface{}{ 
        "automatic_expiry_period": 12, 
        "manual_expiry_period": 7200, 
        "refund_speed": "optimum"
      } 
    } 
  }
  body, err := client.Order.Create(data)
  ```

  ```json Response theme={null}
  {
    "id": "order_DBJOWzybf0sJbb",
    "entity": "order",
    "amount": 50000,
    "amount_paid": 0,
    "amount_due": 50000,
    "currency": "INR",
    "receipt": "rcptid_11",
    "status": "created",
    "attempts": 0,
    "notes": [],
    "created_at": 1566986570
  }
  ```
</CodeGroup>

### Request Parameters

`amount` *mandatory*
: `integer` The amount, in currency subunit, for order. For example, for an amount of ₹295, enter `29500`.

`currency` *mandatory*
: `string` 3-letter ISO currency code for the payment. [List of supported currencies](/docs/payments/international-payments#supported-currencies).

`payment` *optional*
: `array` Payment capture settings for the payment. The options sent here override the [account level auto-capture settings](/docs/payments/payments/capture-settings) configured using the Dashboard.

`capture` *mandatory*
: `string` Option to automatically capture payment. Possible values:

* `automatic`: Payments are auto-captured according to the configurations specified in the `capture_options` array.
* `manual`: You have to manually capture payments using our [Capture API](/docs/api/payments/capture) or from the [Dashboard](/docs/payments/payments/dashboard#manually-capture-payments).

`capture_options` *optional*
: `array` Use this array to determine the expiry period for automatic and [manual capture](/docs/payments/payments/capture-settings/api) of payments and the refund speed in the case of non-capture.

`automatic_expiry_period` *mandatory if capture = automatic*
: `integer` Time in minutes till when payments in the `authorized` state should be auto-captured.
Minimum value `12` minutes. This parameter is mandatory only if the value of `capture` parameter is `automatic`.

`manual_expiry_period` *optional*
: `integer` Time in minutes till when you can manually capture payments in the `authorized` state.

* Must be equal to or greater than the `automatic_expiry_period` value.
* Default value `7200` minutes.
* Maximum value `7200` minutes.
* Payments in the `authorized` state after the `manual_expiry_period` are auto-refunded.

`refund_speed` *mandatory*
: `string` Refund speed for payments that were not captured (automatically or manually). Possible values:

* `normal`: The refund is processed in 5-7 working days.<br /><br />If no value is passed, the refund is processed using the [default speed set on the Dashboard](/docs/payments/refunds#setting-the-default-speed-of-refunds).

`receipt` *optional*
: `string` Maximum length is 40 characters. Receipt number, for internal reference, entered by you for the order.

`notes` *optional*
: `object` Key-value pair to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, `"note_key": "Beam me up Scotty”`.

### Response Parameters

`id`
: `string` The unique identifier of the order. For example, `order_EKwxwAgItmmXdp`.

`amount`
: `integer` The amount, in currency subunit, for the order. For example, for an amount of ₹295, enter `29500`.

`amount_paid`
: `integer` The amount, in currency subunit, paid against the order.

`amount_due`
: `integer` The amount, in currency subunit, pending against the order.

`currency`
: `string` 3-letter ISO currency code for the payment. [List of supported currencies](/docs/payments/international-payments#supported-currencies).

`receipt`
: `string` Maximum length is 40 characters. Receipt number, for internal reference, entered by you for the order.

`status`
: `string` The status of the order. Possible values:

* `created`: When you create an order it is in the `created` state.<br />It stays in this state till a payment is attempted on it.
* `attempted`: An order moves from `created` to `attempted` state when a payment is first attempted on it.<br />It remains in the `attempted` state till one payment associated with that order is captured.
* `paid`: After the successful capture of the payment, the order moves to the `paid` state.<br />No further payment requests are permitted once the order moves to the `paid` state.<br />The order stays in the `paid` state even if the payment associated with the order is refunded.

`attempts`
: `integer` The number of payment attempts, successful and failed, that have been made against this order. For example, `1`.

`notes`
: `object` Key-value pairs to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, `"note_key": "Beam me up Scotty”`.

`created_at`
: `integer` Timestamp, in Unix, when the order was created. For example, `1593607540`.

<Note>
  **Handy Tips**

  * If `automatic_expiry_period` is `60` minutes and `manual_expiry_period` is `120` minutes, payments in the `authorized` state after `120` minutes are auto-refunded.
  * If `automatic_expiry_period` is `0` minutes and `manual_expiry_period` is `120` minutes, payments in the `authorized` state after `120` minutes are auto-refunded.
</Note>

### Related Information

* [Orders API](/docs/api/orders)
* [How Payment Gateway Works](/docs/payments/payment-gateway/how-it-works)
* [Payment States](/docs/payments/payments#payment-life-cycle)
* [Refunds](/docs/payments/refunds)
* [Manually capture payments using Capture API](/docs/api/payments/capture)
* [Manually capture payments from the Dashboard](/docs/payments/payments/dashboard#manually-capture-payments)
* [Set up and subscribe to Webhook events](/docs/webhooks/setup-edit-payments)
