# Pagtrust

> Connect Pagtrust to your Cademí: the product ID or offer code, the webhook token and the version 2.0 webhook with the purchase and subscription events.

Connect Pagtrust to your Cademí so each approved purchase gives the student access on its own. You need the product ID (or the offer code), the webhook token of your Pagtrust account and a webhook pointing to Cademí.

## 1. Create the delivery in Cademí

1. In the Cademí dashboard, open **Sales > Deliveries** and add a delivery.
2. In **Select a Gateway**, pick **Pagtrust**. The screen shows the notice **This gateway is in the beta implementation phase, but you can already use it**: carry on as usual.
3. In **Delivery Name**, enter a name that helps you recognize it later.
4. In **Sales Mode**, choose **One-time sale** or **Subscription**, matching the product on Pagtrust.
5. The **Gateway connection** section shows the **Product ID** and **Webhook Token** fields and the **Postback URL**.

Keep the delivery open: you come back to it in the next steps.

## 2. Find the product ID or the offer code

1. In the Pagtrust dashboard, open **Produtos** (Products) and click the product.
2. To use the whole product, copy the product ID under **Informações gerais** (General information).
3. To use a specific offer, edit the product, open **Ofertas** (Offers), edit the offer and copy its code under **Informações gerais**.
4. Paste the value into **Product ID** in the Cademí delivery.

**Product or offer:** when the sale carries both, Cademí first looks for a delivery with the product ID and, if there is none, uses the one with the offer code. To give one offer a different access, do not register the product ID in another delivery.

## 3. Copy the webhook token

If you already registered your Pagtrust token in another delivery, pick it in **Use an already registered token** and go to step 4.

1. In the Pagtrust dashboard, open **Integrações** (Integrations) in the side bar and click **Webhook**.
2. Click **Copiar Token** (Copy token).
3. Paste the token into **Webhook Token** in the Cademí delivery.

## 4. Set up the webhook

1. Still under **Integrações > Webhook**, click **Adicionar** (Add; the **+** button in the top left corner).
2. In **Nome do Webhook** (Webhook name), enter "Cademí".
3. In **Produtos** (Products), choose all of them or only the ones you deliver through Cademí.
4. In **URL**, paste the **Postback URL** of the delivery.
5. In **Versão** (Version), choose **2.0**.
6. Select the events: Compra aprovada, Compra reprovada, Compra cancelada, Compra reembolsada, Chargeback, Assinatura criada, Assinatura renovada, Assinatura cancelada and Acesso encerrado (approved, declined, canceled and refunded purchase, chargeback, subscription created, renewed and canceled, and access ended).
7. Click **Salvar** (Save) and, in Cademí, save the delivery.

**If you chose only some products:** each time you start delivering a new product through Cademí, add it to this webhook configuration.
