# PayPal

PayPal takes payments from players all over the world, with a PayPal account or a
card, and the money goes to your PayPal account.

You need a **PayPal Business account**: it is free and different from a personal
account. If you do not have one, create it at
[paypal.com](https://www.paypal.com/br/business) and confirm the email before
going on.

![The PayPal step by step open in the dashboard](shots/payments-paypal.webp)

## 1. Log in to the developer portal

1. Go to [developer.paypal.com](https://developer.paypal.com/).
2. Click **Log in to Dashboard** and log in with the Business account email and
   password.

## 2. Create the app and copy the credentials

1. In the left menu, click **Apps & Credentials**.
2. Click **Create App**, give it a name (for example, `Rede Pixel`) and click
   **Create App**.
3. Copy the **Client ID** and paste it into the dashboard field.
4. Click **Show**, below the Client ID, to reveal the **Client Secret**. Copy it
   and paste it into the dashboard field.

> [!WARNING]
> Keep the Client Secret somewhere safe. If you close the page without copying it,
> you will need to generate another one.

## 3. Register the webhook

1. On the same app page, scroll to **Webhooks** and click **Add Webhook**.
2. In **Webhook URL**, paste the URL the dashboard shows. It looks like this:

   ```text Webhook URL
   https://webhooks.hystore.com.br/api/v1/webhooks/paypal/<your store id>
   ```

3. In **Event types**, check only these events:

   ```text Webhook events
   Checkout order approved
   Payment capture completed
   Payment capture denied
   Payment capture refunded
   Payment capture reversed
   ```

4. Click **Save Webhook**.
5. PayPal shows the new webhook with a code, like `5XA12345ABCDE`. Copy it and
   paste it into the **Webhook ID** field of the dashboard.

## 4. Sandbox or production

The PayPal portal starts in **Sandbox** mode (testing with fake money). Make a test
purchase. When everything works, go back to the portal, switch to **Live** at the
top, and repeat steps 2 and 3 to get the production credentials and Webhook ID.
In the dashboard, the PayPal card shows **PRODUCTION** or **SANDBOX**.

> [!TIP]
> Sandbox and Live credentials are different, and so is the webhook. If the store
> is in production and orders do not get approved, check that the Webhook ID you
> pasted is the Live one.

## Guide for players

The **Add payment guide to store Wiki** button creates in your store's wiki an
article explaining to players how to pay with PayPal, step by step.
