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

# Net Banking

Use the Net Banking Component to let a customer pay from their bank account through their bank's internet banking page.

```js theme={null}
const netBanking = TBDropin.create("tb_netBanking", {
  value: {
    bankCode: 1013, // bank code, see Supported Banks
    bankName: "HDFC Bank", // optional, used as a fallback when bankCode is not passed
  },
});
```

> [!NOTE]
>
> One component instance represents **one bank**. To offer several banks, create
> one component per bank and pass the selected one as `payMethod` to `pay()`.

**Component Options**

| Option | Type | Description |
| - | - | - |
| **value.bankCode** | `number` \| `string` | Code of the selected bank. Numeric strings (for example `"1013"`) are accepted. |
| **value.bankName** | `string` | Name of the selected bank. |

**Returned Value**

**netBanking** `Net Banking Object`

```js theme={null}
{
  element: "tb_netBanking",
  value: {
    bankCode: 1013,
    bankName: "HDFC Bank"
  },
  isValid: true,
  ready: true,
  error: null
}
```

| Field | Type |
| - | - |
| **bankCode** | `number` |
| **bankName** | `string` |

**Validation**

The component resolves the bank code from `value.bankCode`, falling back to a case- and whitespace-insensitive lookup of `value.bankName`. If the resolved code is not in the supported bank list, the component reports:

```js theme={null}
{
  isValid: false,
  value: { bankCode: null, bankName: "" },
  error: {
    message: "Please select a valid bank",
    code: "INVALID_BANK_CODE"
  }
}
```

Validation runs as soon as the component is mounted, so a wrong or missing bank code is visible in `netBanking.data()` before the customer presses pay. If `pay()` is called with an invalid bank, it rejects and the root `error` event fires with this error object.

**Code Snippet for netBanking component**

```js theme={null}
const TBDropin = window.TBDropin();

await TBDropin.init({
  mode: "sandbox", // sandbox or production
  publishKey: "", // your publish key goes here
  popupConfig: popupOptions,
});

const netBanking = TBDropin.create("tb_netBanking", {
  value: { bankCode: 1013, bankName: "HDFC Bank" },
});

netBanking.mount("#netBanking");

netBanking.on("ready", (data) => console.log("netBanking", data));
netBanking.on("click", (data) => console.log("netBanking", data));

const result = await TBDropin.pay({
  billingSessionId: "bs_xxxxx", // billingSessionId || subscriptionId || mandateId
  payMethod: netBanking,
  sessionToken,
});
```

> [!NOTE]
>
> Net Banking does not use `cardType`. Pass only the billing session /
> subscription / mandate id, the `sessionToken`, and the selected net banking
> component as `payMethod`.

### Building a bank list

A common layout is a few popular banks as clickable tiles plus a **More banks** dropdown for the rest. Create one component per bank, mount it into a 1 px hidden node inside the tile, and make your own tile the visible, clickable surface.

```js theme={null}
const bankCodeMap = {
  1013: "HDFC Bank",
  1014: "ICICI Bank",
  1001: "Axis Bank",
  1023: "Kotak Mahindra Bank",
  1033: "State bank of India",
  // ...see Supported Banks
};

const createBankComponent = (bankCode) =>
  TBDropin.create("tb_netBanking", {
    value: {
      bankCode,
      bankName: bankCodeMap[bankCode] || "",
    },
    styles: { width: "1px", height: "1px" },
    frameStyle: { width: "1px", height: "1px" },
  });

// render your own tile markup, each with a mount node
// <div class="bank-tile" data-bank-code="1013"><div id="netbank-1013"></div><span>HDFC Bank</span></div>

const mountedBanks = new Map();

Object.keys(bankCodeMap).forEach((bankCode) => {
  const component = createBankComponent(bankCode);
  component.mount(`#netbank-${bankCode}`);
  mountedBanks.set(bankCode, component);
});

document.querySelectorAll(".bank-tile").forEach((tile) => {
  tile.addEventListener("click", () => {
    const bankCode = tile.dataset.bankCode;
    selectedPaymentMethod = mountedBanks.get(bankCode);

    document
      .querySelectorAll(".bank-tile")
      .forEach((t) => t.classList.remove("selected"));
    tile.classList.add("selected");
  });
});
```

For the **More banks** dropdown, create and mount the component lazily on `change` — mount it into a node you append to the container, and keep only one lazily-mounted component alive at a time:

```js theme={null}
let currentBankComponent = null;

bankSelect.addEventListener("change", () => {
  const bankCode = bankSelect.value;
  if (!bankCode) return;

  if (currentBankComponent) {
    currentBankComponent.unmount();
    currentBankComponent = null;
  }

  const mountId = `netbank-hidden-${bankCode}`;
  let node = document.getElementById(mountId);
  if (!node) {
    node = document.createElement("div");
    node.id = mountId;
    bankContainer.appendChild(node);
  }

  currentBankComponent = createBankComponent(bankCode);
  currentBankComponent.mount(`#${mountId}`);
  selectedPaymentMethod = currentBankComponent;
});
```

When the customer switches away from the net banking tab, unmount every bank component you mounted and clear your selection, so the next tab starts from a clean state:

```js theme={null}
const unmountNetBanking = () => {
  if (currentBankComponent) {
    currentBankComponent.unmount();
    currentBankComponent = null;
  }

  mountedBanks.forEach((component) => component.unmount());
  mountedBanks.clear();

  bankContainer.innerHTML = "";
  selectedPaymentMethod = null;
};
```

### Supported Banks

> [card] [Customize Your SDK -> Supported Banks](https://developer.transactbridge.com/checkout.js/web-sdk/dropin/customize-your-sdk.md#12-supported-banks-net-banking)
>
> View the full list of bank codes supported for Net Banking

**Next Steps**

* **Customize component styles**
* **Add multiple payment methods using tabs**
* **Handle payment confirmation on backend**
* **Set up webhooks for payment status**

**Need Help?**

Explore the following sections for more details:

* [**Dropin Overview**](https://developer.transactbridge.com/checkout.js/web-sdk/dropin/overview.md)
* [**Quickstart**](https://developer.transactbridge.com/checkout.js/web-sdk/dropin/quickstart.md)
* [**Customization**](https://developer.transactbridge.com/checkout.js/web-sdk/dropin/customize-your-sdk.md)

If you need assistance, our support team is here to help 🚀


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.