---
updatedAt: 2025-10-23T19:48:40.000Z
agentTools:
  projectIndex: https://docs.rainforestpay.com/llms.txt
---

# Enable surcharging with BIN lookup

Integrate BIN lookup into the Rainforest Payment Component to compliantly surcharge

<Callout icon="✔️" theme="default">
  ### Feature requirements

  🔐 Rainforest must enable the platform to access this feature

  💲 Billing fees associated to this feature

  ⬆️ Only available on the API versions 2024-10-16 and 2023-12-01
</Callout>

When processing payments via the Payment Component, you can enable BIN lookup to retrieve information about the card to compliantly apply [surcharging](https://docs.rainforestpay.com/docs/payin-money-movement-copy) with four steps:

* Enable BIN lookup and configure your merchants billing profiles
* Configure the payin config to request BIN lookup
* Configure the Payment Component to respond to the BIN lookup
* Configure the Deposit Report Component to show the billing details

<br />

# Configure the merchant

***

In the Rainforest Sandbox and Production environments, Rainforest will need to enable this feature for your platform. Once you're ready to enable, reach out to <support@rainforestpay.com> and Rainforest will help you with your merchant's billing profile setup and enabling BIN lookup for your merchants.

### Set the BIN lookup fee

A BIN lookup fee is applied for every BIN lookup request. BIN lookup fees can be passed onto the merchant via the [merchant billing profile](https://docs.rainforestpay.com/docs/merchant-billing-profiles). See the [billing](https://docs.rainforestpay.com/docs/surcharging-with-bin-lookup#bin-lookup-billing) section for additional information on how the BIN lookup fee is billed to the merchant.

We can update the BIN lookup fee on an existing billing profile that currently has the BIN lookup fee set to $0. Or head over to the [Rainforest Platform Portal](https://platform.rainforestpay.com/) to create a new billing profile with a BIN lookup fee.

### Enable your platform

Reach out to <support@rainforestpay.com>and Rainforest will enable your platform for BIN lookup. Once we've enabled the feature, the payin config must be configured to request BIN lookup when the user enters their card number into the Payment Component.

<br />

# Configure the payin

***

BIN lookup is enabled by passing the `allow_bin_lookup` value of `true` on the [create payin config](https://docs.rainforestpay.com/reference/create_payin_config) request.

```diff
{
    "merchant_id": "{{merchant_id}}",
    "idempotency_key": "{{idempotency_key}}",
    "amount": 10000,
    "currency_code": "USD",
+   "allow_bin_lookup": "true"
}
```

The `allow_bin_lookup` of `true` tells Rainforest to retrieve BIN information once the user enters their card number into the [Payment Component](https://docs.rainforestpay.com/docs/process-payins-via-component).

## Apply the surcharging amount

To pass on the processing fee to the end user, you will need to do the <Anchor label="surcharging calculation" target="_blank" href="doc:surcharging-with-bin-lookup#/surcharging-calculation">surcharging calculation</Anchor> and accurately set the amount in the payin config.

<br />

# Configure the payment component

***

## Hide the submit button

When embedding the Payment Component in your platform, you should [hide the submit button](https://docs.rainforestpay.com/docs/hide-the-submit-button) so that you can listen to the results of the BIN lookup and make a decision, such as removing the surcharge if the user entered a debit card.

First, render the component with the `hide-button` attribute, so that it no longer renders the Rainforest-controlled button. Then render your own submit button and add appropriate styling and behavior to it. Ensure your submit button is not enabled until the Payment Component is [valid](https://docs.rainforestpay.com/docs/hide-the-submit-button#know-if-the-payment-is-ready-to-be-submitted) and you're ready to process the payment.

```diff HTML
  <rainforest-payment
      session-key="REPLACE_ME"
      payin-config-id="REPLACE_ME"
+     hide-button
  ></rainforest-payment>

+ <input type="submit" id="submit" disabled>
```

## Listen to the BIN lookup event

If BIN lookup was requested in the [payin config](https://docs.rainforestpay.com/docs/enable-surcharging-with-bin-lookup#configure-the-payin), the Payment Component will emit the `bin-lookup` every time the user enters the full card number into the Payment Component. This means if the user enters one card number, then changes their mind and enters another card number, the Payment Component will emit 2 `bin-lookup` events.

The `bin-lookup` event will return a payload in the format of the response from the [BIN lookup](https://docs.rainforestpay.com/reference/create_bin_lookup) endpoint:

```json

{
    "status": "SUCCESS",
    "data": {
        "bin_lookup_id": "sbx_bin_2xSzUXqaaPMX684vEXOSDVb96nB",
        "billable_merchant_id": "sbx_mid_2xSzXQoAprorB7EZ0sFBvEKTy7y",
        "bin": "41111111",
        "brand": "VISA",
        "type": "CREDIT",
        "last_4": "1111",
        "country": "US",
        "is_business": false,
        "is_healthcare": false
    },
    "errors": null
}
```

Listen to this event and parse the event data:

```javascript
const component = document.getElementById('payment-component');
component.addEventListener('bin-lookup', function (data) {
    if (data.detail[0].type) {
        console.log('Type: ' + data.detail[0].type);
    }
});
```

### International and Business Surcharging

If the merchant wants to surcharge on International cards or Business cards, then the platform should utilize the `country` and `is_business` fields in the BIN lookup response.

## Update the payin config

If the user's card number is determined to be a debit card, and per [surcharging compliance](https://docs.rainforestpay.com/docs/surcharging-with-bin-lookup#surcharging-compliance) if the surcharge needs to be removed, the payin config can be updated without having to re-render the Payment Component and lose the information the user has already entered.

Depending on the <Anchor label="surcharging calculation method" target="_blank" href="doc:surcharging-with-bin-lookup#/surcharging-calculation">surcharging calculation method</Anchor>, you will need to [create a new payin config](https://docs.rainforestpay.com/reference/create_payin_config) to:

1. Update the new amount of the payin and set the merchant billing fee, if utilizing <Anchor label="dynamic billing fees" target="_blank" href="doc:docs/surcharging-with-bin-lookup#/dynamic-billing-fees">dynamic billing fees</Anchor>.
2. Update the new amount of the payin if utilizing the formula to <Anchor label="calculate the amount" target="_blank" href="doc:surcharging-with-bin-lookup#/amount-calculation">calculate the amount</Anchor> of the payin.

[Update the config](https://docs.rainforestpay.com/docs/update-the-payment-configuration) attribute by using the JavaScript DOM attribute API:

```javascript
component.removeAttribute('payin-config-id');
component.setAttribute('payin-config-id', newPayinConfigId;
```

Confirm the [payin config was updated](https://docs.rainforestpay.com/docs/update-the-payment-configuration#know-if-the-payment-configuration-was-updated) by listening to the `config-update-accepted` event before processing the payin.

## Submit the payin

Once the payment is ready to be submitted and the user has hit your [submit button](https://docs.rainforestpay.com/docs/hide-the-submit-button#submit-the-payment), you can call the Payment Component's `submit` method.

```javascript
component.submit();
```

> 📘 Surcharging compliance
>
> It's important that you follow all the [surcharging regulations](https://docs.rainforestpay.com/docs/surcharging-with-bin-lookup#surcharging-compliance) within your checkout flow. Ensure you are displaying the surcharging fees and the end user has been notified of the surcharge.

<br />

# Configure deposit report for billing

***

BIN lookups do incur an additional billing fee. If you're passing the fee onto the merchant, then the deposit will include a billing adjustment.

<Image align="center" border={false} src="https://files.readme.io/d5c121efa405c83e23ff41442e8153fd94f7e3ff3d96180cd7051ce2d8d64bf8-Deposit_Details_Bin_Lookup_Billing_Adjustment.png" />

[Configure the Deposit Report Component](https://docs.rainforestpay.com/docs/deposit-report-component#custom-configuration-1)  to include the `memo` column in the Deposit Details activity report to provide the context on the billing adjustment to your merchant.

```html
<rainforest-deposit-report
    activity-columns='[
    {"name":"Created","type":"builtin","value":"created_at"},
    {"name":"Type","type":"builtin","value":"type"},
    {"name":"ID","type":"builtin","value":"id"},
    {"name":"Memo","type":"builtin","value":"memo"},
    {"name":"Customer","type":"builtin","value":"billing_contact_name"},
    {"name":"Method","type":"builtin","value":"payment_method"},
    {"name":"Amount","type":"builtin","value":"gross_amount"},
    {"name":"Fees","type":"builtin","value":"billing_fees_amount"},
    {"name":"Net","type":"builtin","value":"net_amount"}
]'
></rainforest-deposit-report>
```