# Add a service fee to a sale

Add a service fee to a card sale by looking up BIN information to calculate the fee, disclosing it to the customer, then sending a POST request to the Payments endpoint.

**Prerequisites:** [Authentication](/api/authentication) · [Run a card sale](/guides/payments/run-a-card-sale)

A service fee is an additional amount that you add to a sale to help cover administration costs. Only certain cards and industries are eligible for service fees.

How we calculate the service fee depends on the card type:

- **Credit cards:** The service fee can be only a percentage of the sale amount.
- **Debit and prepaid cards:** The service fee can be a percentage of the sale amount or a flat amount.

To add a service fee to a sale, calculate the amount of the service fee, disclose it to the customer, and then run the sale. If the customer doesn't accept the service fee, let them cancel the sale.

<a id="integration-steps"></a>
## Integration steps

**Step 1.** Look up BIN information. **Step 2.** Run a sale.

<a id="before-you-begin"></a>
## Before you begin

- Make sure that your processing terminal is set up for service fees. If you want to add a service fee to sales, contact our Integrations team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com).
- [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors).

<a id="step-1-look-up-bin-information"></a>
## Step 1. Look up BIN information

To check if a card is eligible for a service fee and to calculate the fee amount, send a POST request to our Cards endpoint.

| Environment | URL |
| --- | --- |
| Test | [https://api.uat.payroc.com/v1/cards/bin-lookup](https://api.uat.payroc.com/v1/cards/bin-lookup) |
| Production | [https://api.payroc.com/v1/cards/bin-lookup](https://api.payroc.com/v1/cards/bin-lookup) |

<a id="request-parameters"></a>
### Request parameters

Include the total amount of the sale in the `amount` parameter. Our gateway uses the amount to calculate the service fee.

To create the body of your request, use the following parameters:

<a id="schema-requestbody"></a>
### Schema (`request.body`)

[Request body schema for `POST /cards/bin-lookup`](/api/bin-lookup)

<a id="example-request"></a>
### Example request

POST [https://api.payroc.com/v1/cards/bin-lookup](https://api.payroc.com/v1/cards/bin-lookup)

```json
{
  "processingTerminalId": "1234001",
  "amount": 4999,
  "currency": "USD",
  "card": {
    "type": "card",
    "cardDetails": {
      "entryMethod": "keyed",
      "keyedData": {
        "dataFormat": "plainText",
        "cardNumber": "4539858876047062",
        "expiryDate": "1230"
      }
    }
  }
}
```

<a id="response-fields"></a>
### Response fields

If your request is successful, our gateway returns a `serviceFee` object in the response, which contains information about the service fee, and a disclosure statement that describes the fee.

Show the customer the new total with the service fee, and the disclosure statement from the response. If the customer accepts the new total, go to [Step 2. Run a sale](#step-2-run-a-sale).

<a id="schema-responsebody"></a>
### Schema (`response.body`)

[Response body schema for `POST /cards/bin-lookup`](/api/bin-lookup)

<a id="example-response"></a>
### Example response

```json
{
  "type": "Visa",
  "cardNumber": "453985******7062",
  "country": "US",
  "currency": "USD",
  "debit": false,
  "serviceFee": {
    "applicable": true,
    "amount": 150,
    "percentage": 3.0,
    "basis": "creditPercentage",
    "disclosure": "A 3% service fee applies to this payment."
  }
}
```

<a id="step-2-run-a-sale"></a>
## Step 2. Run a sale

If the customer accepts the service fee, run the sale. You don't need to change your request to add the service fee. Send the sale amount as normal, and our gateway automatically applies the service fee.

To run a sale, send a POST request to our Payments endpoint.

| Environment | URL |
| --- | --- |
| Test | [https://api.uat.payroc.com/v1/payments](https://api.uat.payroc.com/v1/payments) |
| Production | [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) |

<a id="request-parameters-1"></a>
### Request parameters

To create the body of your request, use the following parameters:

<a id="schema-requestbody-1"></a>
### Schema (`request.body`)

[Request body schema for `POST /payments`](/api/payment)

<a id="response-fields-1"></a>
### Response fields

If your request is successful, our gateway runs the sale and adds the service fee to the transaction total. The response includes a `serviceFee` object in the payment breakdown:

<a id="schema-responsebody-1"></a>
### Schema (`response.body`)

[Response body schema for `POST /payments`](/api/payment)

<a id="example-response-1"></a>
### Example response

```json
{
  "paymentId": "M2MJOG6O2Y",
  "status": "approved",
  "order": {
    "amount": 5149,
    "currency": "USD",
    "breakdown": {
      "subtotal": 4999,
      "serviceFee": {
        "amount": 150,
        "percentage": 3.0,
        "basis": "creditPercentage"
      }
    }
  }
}
```
