# Invoice Portal Configs

## Required Configs

### email

| Type   | Required            | Description                                                                                                                                              |
| ------ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | Yes OR customer\_id | The customer's email address. This will automatically populate checkout, or be used to identify current subscribers. Can alternatively use customer\_id. |

```javascript
{
    email: "example@google.com"
}
```

### customer\_id

| Type   | Required     | Description                                                                                                                                                                             |
| ------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | Yes OR email | The customer's Stripe Customer ID. This will be used to identify existing subscribers or subscribe new customers. You must have already created the Stripe Customer object to use this. |

```javascript
{
        customer_id: "cus_FtWXI6U0YxebLd"
}
```

### hash

| Type   | Required | Description                                                                                                                                                                                                                                                                                                                      |
| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | Yes      | An HMAC string used for authenticating the user loading the embed more securely. This is **required in order to go to 'Live Mode'** in Billflow (connected to 'Live Mode' in Stripe). The hash is generated with your Billflow Secret and the customer's email or Stripe Customer ID, whichever you are using to identify users. |

```javascript
{
    hash: "0709c7f107ed6326aaeaa3810330834870591f3924943e7bce66a826ac532045"
}
```

## Available Configs

### subscription\_id

| Type   | Required | Description                                                                                                                                                                              |
| ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | No       | The Stripe subscription ID. Pass if you want a user to only see and manage a single subscription. Used if your customers have multiple subscriptions and you only want them to view one. |

```javascript
{
    subscription_id: "sub_I9cJJypSQHOfzl"
}
```

### handleResponse

| Type     | Required | Description                                                                                                                                                                                                                                                                                                      |
| -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Function | No       | Function that is called when users signup, change plan (upgrade/downgrade), resubscribe, or update Credit Card. Used to update user data, do redirects, or provide notifications. Payload contains an event name and a response object. [Learn More](https://docs.billflow.io/developers/handling-embed-events). |

```javascript
{
    handleResponse: async function(payload) {
      console.log("Event ", payload.event);
      console.log("Response Object ", payload.response);
    }
}
```

### options.quantity

| Type   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Object | No       | <p>Use to set the quantity of a subscription during creation. Can get an integer or an object of key-value pairs. The quantity will apply to products with the unit\_label defined. If an integer is passed, it will apply the quantity to all products on the tier, if an object is passed with the unit\_labels as keys, it will assign that quantity to the respective unit\_label.</p><p>Eg: 5</p><p>OR</p><p>Eg: {product\_unit\_label1 : 10, unit\_label2: 20}</p> |

```javascript
{
  options: {
      quantity: {
        super_user: 3,
        user: 5,
      },
}
```
