---
page_title: Mandate Execution (Auto debit of Subscription)
product: SmartGateway API Reference (Basic Auth)
page_source: https://smartgateway.hdfc.bank.in/docs/smartgateway-api-ref-basicauth/docs/mandates-subscriptions/mandate-execution-auto-debit-of-subscription
llms_txt: https://smartgateway.hdfc.bank.in/docs/llms.txt
product_llms_txt: https://smartgateway.hdfc.bank.in/docs/smartgateway-api-ref-basicauth/llms.txt
---


# Mandate Execution(Auto debit of Subscription)



After successful mandate registration, the next step is auto debit of the subscription for next renewal cycle. You need to call the Mandate Execute API at least 25 hours before the auto debit date. Post that, bank will notify the user about the debit via SMS. Follow the steps mentioned below to integrate Mandate Execution successfully.


### Step 2.0. Updated Mandate Status


This is an optional but recommended step. It’s always better to know the status of the Mandate before calling the Execution API, to avoid calling revoked or expired mandates. There are multiple ways to know the mandate Status 

1. Consume Mandate Status Webhooks
2. Use **Mandate Status Check API**  - This API can be called to get the status of a particular mandate setup with us; we will sync with PGs to get the latest Mandate Status value and update back in our response, or share the latest Mandate Status stored with us in DB.




### Step 2.1. Call Mandate Execution API


Call **Mandate Execution API** (Server to Server call) to initiate a recurring debit transaction.After the successful Mandate registration, Merchant will receive a mandate_id, mandate_token from SmartGATEWAY that should be stored against a customer at their end. For the subsequent charge transactions, this API need to be called which will create an order and perform a transaction with PG based on the mandate_id passed in the request.

> **Warning**
> Call this API atleast 25 hrs. prior to the execution date. Always use a unique new order_id for the recurring payment in this API.






### Step 2.2. Consume Notification Webhooks


Once the Execution API is successfully hit, SmartGATEWAY will initiate the transaction with the underlying PG. Subsequently, the bank will notify the user of the debit via SMS. To track the notification status, you need to consume the Notification Webhook.

If the notification is successful, SmartGATEWAY will trigger a Notification Success webhook, and the amount will be debited from the user's account accordingly.

However, if the notification fails, SmartGATEWAY will initiate a Notification Failure webhook. In this scenario, the Mandate Execution API must be re-initiated.

> **Warning**
> Till the notification and execution takes place, transaction status will be Pending. According to RBI, notification will be triggered for cards and UPI only.






### Step 2.3. Handle Mandate Execution Response


To determine the status of the transaction (whether it's a success, failure, or pending), call the [Order Status API](https://docs.hdfcbank.juspay.in/docs/smartgateway-api-ref-basicauth/docs/apis/order-status-api)and consume[Webhooks](https://docs.hdfcbank.juspay.in/docs/hdfc-resources/docs/common-resources/mandate-webhook). You will receive a mandate block in the response.



## Sample Code Snippets:
### Top Header:

#### Mandate Status Check Request Code Snippet:

```mandate status check request
curl --location 'https://smartgateway.hdfc.bank.in/mandates/<mandate_id>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-merchant-id: <merchant_id>' \
--header 'Authorization: Basic <api key in base64 format>' \
--data-urlencode 'command=check_status'

```

#### Mandate Status Check Response Code Snippet:

```mandate status check response
{
  "order_id": "juspayKTestTxns849",
  "frequency": "ASPRESENTED",
  "end_date": "2633068438",
  "status": "ACTIVE",
  "activated_at": "2023-06-09T07:59:32Z",
  "last_activated_at": "2023-06-09T07:59:32Z",
  "amount_rule": "VARIABLE",
  "last_updated": "2023-06-09T07:59:32Z",
  "start_date": "1686293709",
  "mandate_debit_token": "tkn_88620327ecf64826ad5cea548a1554d4",
  "customer_id": "cst_z1fsoxwyhvp5gj13",
  "mandate_id": "hyhTD5Ga4jJ2KXZwwnyh4A",
  "block_fund": false,
  "currency": "INR",
  "max_amount": 20,
  "mandate_token": "4a1d3fd9727e4b95bdc5cfd60aa12530",
  "revokable_by_customer": true,
  "payment_info": {
    "payment_method": "PAY",
    "payment_method_type": "UPI"
  },
  "mandate_type": "EMANDATE"
}

```

### Bottom Header:

#### Mandate Execution Request:
```json
curl --location 'https://smartgateway.hdfc.bank.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-merchant-id: <merchant_id>' \
--header 'Authorization: Basic <api key in base64 format>' \
--data-urlencode 'order.order_id=mandateexecution1' \
--data-urlencode 'order.amount=1' \
--data-urlencode 'merchant_id=<merchant_id>' \
--data-urlencode 'mandate_id=<mandate_id>' \
--data-urlencode 'format=json'

```

#### Mandate Execution Response:
```plaintext
{
  "txn_uuid": "eulmN9X8JpeC7qK6AJq",
  "txn_id": "merchant_id-26234761248249834753485721-1",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "url": "https://smartgateway.hdfcuat.bank.in/v2/pay/finish/merchant_id/eulmN9X8JpeCxxxxxJq/26234761248249834753485721",
      "method": "GET"
    }
  },
  "order_id": "26234761248249834753485721",
  "offer_details": {
    "offers": []
  }
}

```



---

## See Also

- [Mandate Registration (Setting up a subscription)](https://smartgateway.hdfc.bank.in/docs/smartgateway-api-ref-basicauth/docs/mandates-subscriptions/mandate-registration-setting-up-a-subscription)
- [Mandate Execution API](https://smartgateway.hdfc.bank.in/docs/smartgateway-api-ref-basicauth/docs/mandates-subscriptions/mandate-execution-api)
