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

# Installing the plugin

#### Pre-Requisites

1. You must be a customer of OrderProtection. If you are not a customer of OrderProtection but would like to be please
   reach out to [Onboarding](mailto:onboarding@orderprotection.com)
2. You must have access to your OrderProtection dashboard at [https://app.orderprotection.com](https://app.orderprotection.com)

### Installing the Plugin

You can download the Magento module zip file [Here](https://cdn.orderprotection.com/plugins/magento/latest/OrderProtection.zip)

To install the plugin please follow the README.md which will be included in the directory.

**After Magento Installation**

Before you edit the plugin settings we need to generate a few items from your OrderProtection dashboard.

Login [here](https://app.orderprotection.com)

Once signed in, you must make sure that the store you would like to install the plugin on is selected from the store
dropdown.

<img src="https://mintcdn.com/orderprotectioncom/GDuchlp6KbhScehe/public/assets/img/woo/woo-sidebar.png?fit=max&auto=format&n=GDuchlp6KbhScehe&q=85&s=aa4bff390cb8505c8f64e11e6c536a27" alt="sidebar img" width="250" height="182" data-path="public/assets/img/woo/woo-sidebar.png" />

### Generating your API Token

You must generate an API token which will be used to authenticate your store with OrderProtection's API. This is a
sensitive key as it will allow you to send order information into OrderProtection. Please store this in a safe place.

Click on the settings navigation item in the left sidebar.

<img src="https://mintcdn.com/orderprotectioncom/GDuchlp6KbhScehe/public/assets/img/woo/woo-settings-sidebar.png?fit=max&auto=format&n=GDuchlp6KbhScehe&q=85&s=679553da30bcd16a18e458c0863a4735" alt="sidebar-settings" width="250" height="259" data-path="public/assets/img/woo/woo-settings-sidebar.png" />

After navigating to settings, navigate to the API Tokens tab

<img src="https://mintcdn.com/orderprotectioncom/GDuchlp6KbhScehe/public/assets/img/woo/woo-api-tokens.png?fit=max&auto=format&n=GDuchlp6KbhScehe&q=85&s=2bfdf7fad0a71c19cd9141a3bd0f0ca8" alt="woo-settings-api-tokens" width="1169" height="387" data-path="public/assets/img/woo/woo-api-tokens.png" />

Generate a new API token using the `Create API Token` button. You can name this anything that you'd like. We use the
name to attribute actions to a specific key. If your API key were to be compromised you'd be able to know exactly which
key to remove.

<img src="https://mintcdn.com/orderprotectioncom/GDuchlp6KbhScehe/public/assets/img/woo/woo-create-api-token.png?fit=max&auto=format&n=GDuchlp6KbhScehe&q=85&s=0792f3eb4a4feb91fd38f6add2ff31c1" alt="create-api-token" width="571" height="386" data-path="public/assets/img/woo/woo-create-api-token.png" />

After clicking `Create` make sure to save the value shown. You will not be able to see this value again!

<img src="https://mintcdn.com/orderprotectioncom/GDuchlp6KbhScehe/public/assets/img/woo/woo-created-api-token.png?fit=max&auto=format&n=GDuchlp6KbhScehe&q=85&s=4fba46743c327a239111b947bd92b06a" alt="woo-created-api-token" width="577" height="262" data-path="public/assets/img/woo/woo-created-api-token.png" />

Save this token somewhere safe, you'll need this in your OrderProtection Magento plugin settings.

### Creating a Webhook

In order for OrderProtection to be able to create replacement orders and refund customers we need to create a webhook.
This webhook will send a request to your OrderProtection Magento plugin informing the plugin which items to reship
or refund.

You'll need to know your hosted sites location e.g ([https://orderprotection.com](https://orderprotection.com))

Go back to your settings tab in your OrderProtection dashboard and click on the `Webhooks` tab.

<img src="https://mintcdn.com/orderprotectioncom/jzsZz1L0F1t7QLbE/public/assets/img/woo/woo-webhooks.png?fit=max&auto=format&n=jzsZz1L0F1t7QLbE&q=85&s=1d9515d00bd0ed60cab412373ebffb37" alt="webhooks-view" width="1160" height="501" data-path="public/assets/img/woo/woo-webhooks.png" />

Click on the `Create Webhook` button and add the following details:

**Payload URL**:

```
https://${yourdomain}/rest/V1/order-protection/webhook
```

**Webhook Secret**

*In your Magento dashboard*:

You will need to navigate to `System` -> `Integration` and create a new Integration.

You can call this Integration `Order Protection`. Once you have this integration you need to click on the Edit (pencil)
button. This will show you the integration settings.

You need to find the `Access Token` field.

Your webhook secret will match the following format:

`${AccessToken}`

Input this into your OrderProtection webhook secret field.

**Events** Click on `Let me select individual events`

Choose the following:

* `Claims -> Approved`
* `Claims -> Created`

You only need this one event for the OrderProtection Plugin to work correctly.

Click `Create`

It should look something like this:

<img src="https://mintcdn.com/orderprotectioncom/YH-3ZcWwdyNXknOd/public/assets/img/woo/woo-webhook-event-selections.png?fit=max&auto=format&n=YH-3ZcWwdyNXknOd&q=85&s=43e3c983c3bdeac3d9107fa8ba9a9501" alt="webhook-select-events" width="1000" height="2936" data-path="public/assets/img/woo/woo-webhook-event-selections.png" />

### Finalizing Plugin Settings

Once you have your API token and Webhook secret, navigate to your admin page of your
store. You will need to find the Order Protection section

You can find this section by navigating to Stores -> Configuration -> Sales -> Order Protection

<img src="https://mintcdn.com/orderprotectioncom/YH-3ZcWwdyNXknOd/public/assets/img/woo/mg-config-op-new.png?fit=max&auto=format&n=YH-3ZcWwdyNXknOd&q=85&s=0684f96107dedc62f335f78d676bf4d6" alt="Side Bar View of Config" width="1900" height="831" data-path="public/assets/img/woo/mg-config-op-new.png" />

Once in this section you will need to scroll to the API Setting section. Here you will configure your
api token and store URL.

### Ensuring Order Protection Has Proper Scopes

For the Order Protection module to work correctly on your store, you need to ensure it has the API access scopes are configured correctly.

Step 1: Go to `System > Integrations`

<img src="https://mintcdn.com/orderprotectioncom/Plza7lHy-l-FiRlv/public/assets/img/magento/magento-settings-integrations.png?fit=max&auto=format&n=Plza7lHy-l-FiRlv&q=85&s=fd5621e6adcbc50acd6792b09af14dd4" alt="" width="2164" height="1356" data-path="public/assets/img/magento/magento-settings-integrations.png" />

Step 2: Under `Order Protection` select the edit icon.

<img src="https://mintcdn.com/orderprotectioncom/Plza7lHy-l-FiRlv/public/assets/img/magento/magento-settings-edit-op.png?fit=max&auto=format&n=Plza7lHy-l-FiRlv&q=85&s=d961040973e2f29c3d63df7dc987cac5" alt="" width="2166" height="1362" data-path="public/assets/img/magento/magento-settings-edit-op.png" />

Step 3: Navigate to the API tab under the `Basics Settings` menu and scroll to the bottom. Ensure that `Order Protection Orders` and `Order Protection Orders Update` are both selected.

<img src="https://mintcdn.com/orderprotectioncom/Plza7lHy-l-FiRlv/public/assets/img/magento/magento-op-api-select.png?fit=max&auto=format&n=Plza7lHy-l-FiRlv&q=85&s=d6bf715a4e720342772b4b8fe97a53f0" alt="" width="2184" height="1362" data-path="public/assets/img/magento/magento-op-api-select.png" />
