# Compliance element

The compliance element displays the [selling entity](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities) facilitating a transaction and renders links to applicable disclosures, such as terms of sale, cookie policies, and cancellation rights.

<figure><img src="https://334437993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LqH4RJfLVLuHPXuJyTZ%2Fuploads%2FvQCyO6p2hVwMH1SM61nU%2FCompliance%20element.png?alt=media&#x26;token=63f2f9b4-ad6f-4745-bfda-5fc0b3d14846" alt=""><figcaption></figcaption></figure>

This page provides information on how to [create](#creating-a-compliance-element), [mount](#mount), [unmount](#unmount), [destroy](#destroy), [update](#update), and [configure](#compliance-element-configuration-object) the element.

{% hint style="info" %}
For details on using the element in checkout flows, refer to [Displaying compliance disclosures](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts#displaying-compliance-disclosures) on the [Building checkouts](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts) page.
{% endhint %}

## Creating a compliance element

To create a compliance element, pass `'compliance'` and its [configuration object](#compliance-element-configuration-object) to `createElement()`, which is exposed by the [`DigitalRiver` object](https://docs.digitalriver.com/digital-river-api/developer-resources/digitalriver-object#creating-a-digitalriver-object).

```javascript
var compliance = digitalRiver.createElement('compliance', complianceOptions);
```

## `mount()`

Call this function to place the created compliance element on your page.

```javascript
<div id="compliance"></div>

compliance.mount('compliance');
```

## `unmount()`

Call this function to remove the compliance element from your page. The element may be re-added to your page by calling [`mount()`](#mount).

```javascript
compliance.unmount();
```

## `destroy()`

Call this function to remove both the compliance element and its functionality from your page. You cannot re-add a destroyed element to your page via [`mount()`](#mount).

```javascript
compliance.destroy();
```

## `update()`

To refresh the compliance element, pass its [configuration object](#compliance-element-configuration-object) to `update()`.

```javascript
let complianceOptions = {
  compliance: {
    entity: 'DR_JAPAN-ENTITY'
  }
}
compliance.update(complianceOptions);
```

## Compliance element configuration object

The compliance element's configuration object contains a nested [`classes`](#classes) and [`compliance`](#compliance).

### `classes`

To stylize the compliance element, define the optional `classes`. For details, refer to [Custom classes](https://docs.digitalriver.com/digital-river-api/developer-resources/reference/elements/..#custom-classes).

```javascript
var complianceOptions = {
    classes: {
      base: 'DRElement'
    },
    ...
}
var compliance = digitalRiver.createElement('compliance', complianceOptions);
```

### `compliance`

The `compliance` object consists of a [`language`](#language), [`country`](#country), and [`entity`](#entity), all of which are required to make the element behave properly. Giving Digital River this data increases the probability that customers are shown accurately translated disclosures that apply to their shopping country.

For example, the following configuration results in the compliance element displaying the required disclosures, translated into Spanish, when customers shop in Germany, and Digital River Ireland Ltd. facilitates the transaction.

```javascript
var complianceOptions = {
    compliance: {
      entity: 'DR_IRELAND-ENTITY',
      language: 'es',
      country: 'DE'
    }
}
var compliance = digitalRiver.createElement('compliance', complianceOptions);
```

#### `language`

This required string determines the language of the text displayed in the element as well as the linked-to disclosure documents. The value you assign `language` doesn't affect what disclosures are displayed, only how their text is rendered.

For a list of accepted values, refer to [Supported languages](https://app.gitbook.com/s/ZrhMyLX5esFYS64lNWVW/digital-river-api-reference-guide/supported-languages).

#### `country`

A required string, formatted as an [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code, represents the customer's shopping country. Since legal requirements vary slightly from country to country, the value you assign to this property determines which specific disclosures are rendered in the element. For example, some `country` values display a link to the customer's cancellation rights, while others do not.

If the transaction involves [physical products](https://docs.digitalriver.com/digital-river-api/product-management/skus#how-products-are-classified-as-physical-or-digital), `country` should ideally be the same as the customer’s ship to country. If customers only purchase [digital products](https://docs.digitalriver.com/digital-river-api/product-management/skus#how-products-are-classified-as-physical-or-digital), you can use their billing country.

#### `entity`

A required string that represents the transaction's designated [selling entity](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities). Like `compliance.country`, this property affects which disclosures are displayed in the element.

{% hint style="info" %}
In [checkouts](https://www.digitalriver.com/docs/digital-river-api-reference/#tag/Checkouts), you can find this value in `sellingEntity.id`.
{% endhint %}

For a list of accepted values, refer to [Supported selling entities](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities#supported-selling-entities).

#### `jpCommerceLawPageUrl`

If `compliance.country` is `jp`, then the element displays a link to a disclosure that pertains to Japanese commercial transaction law.

If you'd like to replace the default URL behind this link with your own, use `jpCommerceLawPageUrl`.

```javascript
var complianceOptions = {
    classes: {
      base: 'DRElement'
    },
    compliance: {
      ...
      country: 'JP',
      jpCommerceLawPageUrl: 'https://acme.com/JapaneseCommerceLaw'
    }
}
var compliance = digitalRiver.createElement('compliance', complianceOptions);
```
