<!-- Canonical: https://www.ezdis.net/en/manual/1.0/config/paypal | Language: en -->

# Configure PayPal payments

---

This guide explains how to connect PayPal to EzDIS so customers can pay invoices from the payment link.

---

- [What this integration enables](#section-0)
- [Create a PayPal REST app](#section-1)
- [Configure PayPal in EzDIS](#section-2)
- [Configure the webhook](#section-3)
- [Test the integration](#section-4)
- [Automatic plan subscriptions](#section-5)
- [Charge a processing fee](#section-6)

<a name="section-0"></a>
## What this integration enables

When PayPal is enabled, the public payment page shows a PayPal button for invoices in supported currencies. If MercadoPago is also enabled, the customer can choose which method to use.

You can also send a PayPal subscription link from the plan assigned to a customer. The customer approves the subscription once, and PayPal automatically charges each billing period.

When the payment is confirmed:

1. EzDIS records the payment on the invoice.
2. The invoice becomes paid or partially paid depending on the remaining balance.
3. The customer can receive email and/or WhatsApp confirmation if those notifications are configured.

---

<a name="section-1"></a>
## Create a PayPal REST app

1. Open the [PayPal Developer Dashboard](https://developer.paypal.com/dashboard/).
2. Create or open a REST app.
3. Copy the **Client ID** and **Client Secret**.
4. Use **Sandbox** credentials for tests and **Live** credentials for real collections.

> **Important:** the Client Secret is private. Do not share it or paste it in public places.

---

<a name="section-2"></a>
## Configure PayPal in EzDIS

1. Open [EzDIS settings](/configuration).
2. Go to **PayPal**.
3. Complete:

| Field | Description | Example |
|---|---|---|
| **Enable PayPal payments** | Enables PayPal as a payment method | Yes |
| **PayPal Client ID** | Client ID from the REST app | `Abc...` |
| **PayPal Client Secret** | Client Secret from the REST app | `Efg...` |
| **PayPal environment** | `sandbox` for tests or `live` for production | `sandbox` |
| **PayPal Webhook ID** | Webhook ID created in PayPal | `WH-...` |
| **PayPal commission percentage** | Optional fee charged to the customer | `5` |

4. Save changes.

---

<a name="section-3"></a>
## Configure the webhook

The webhook lets PayPal notify EzDIS when a payment capture is completed or when a subscription changes/is charged.

Use this URL:

```text
https://www.ezdis.net/api/payment/paypal/webhook?domain=your-domain.ezdis.net
```

Replace `your-domain.ezdis.net` with your real app domain. Example:

```text
https://www.ezdis.net/api/payment/paypal/webhook?domain=midistribuidora.ezdis.net
```

In PayPal, subscribe to these events:

- **Payment capture completed**
- **Payment sale completed**
- **Billing subscription activated**
- **Billing subscription cancelled**
- **Billing subscription suspended**
- **Billing subscription payment failed**

Then copy the **Webhook ID** and paste it in the PayPal settings inside EzDIS.

---

<a name="section-4"></a>
## Test the integration

1. Configure PayPal in `sandbox` mode.
2. Create a test invoice in a PayPal-supported currency, such as USD, EUR or BRL.
3. Open the payment link.
4. Pay with a sandbox buyer account.
5. Confirm that the payment is recorded on the invoice.

---

<a name="section-5"></a>
## Automatic plan subscriptions

Subscriptions are created from the plan assigned to the customer. EzDIS generates its own secure link; when the customer opens it, they are sent to PayPal to approve recurring billing.

When PayPal confirms an automatic charge:

1. EzDIS creates or reuses the pending invoice for that plan.
2. Records the payment with **PayPal** as the method.
3. Marks the invoice as paid when applicable.
4. Advances the plan's next billing date.

> Do not expose PayPal access tokens in public links. The EzDIS subscription link uses an internal token and the backend talks to PayPal securely.

---

<a name="section-6"></a>
## Charge a processing fee

If you want to pass processing costs to the customer:

1. In PayPal settings, find **PayPal commission percentage charged to the user**.
2. Enter the percentage, for example `5` for 5%.
3. Save.

The customer pays the invoice total plus the fee. EzDIS records the original invoice amount as the payment.
