|
| 1 | +--- |
| 2 | +title: Webhook Integration Overview |
| 3 | +authors: |
| 4 | + - MiataVxbe |
| 5 | +--- |
| 6 | +# Webhook Setup |
| 7 | + |
| 8 | +This guide will walk you through setting up the Payhip webhook integration for the Integrations Bot. Follow each step carefully to ensure your sales, refunds, and subscriptions are delivered to your Discord server in real time. |
| 9 | + |
| 10 | +## 1. Configure Your Bot |
| 11 | + |
| 12 | +Before setting up the webhook, make sure your bot is configured and running. You should have already completed the steps in [Getting Started > Configuration](../get-started/configuration.md). |
| 13 | + |
| 14 | +**Key config section:** |
| 15 | + |
| 16 | +```json |
| 17 | +{ |
| 18 | + "webhookConfig": { |
| 19 | + "webhookPort": 3000, |
| 20 | + "webhookPath": "/webhook/payhip", |
| 21 | + "webhookURL": "http://yourdomain.com/webhook/payhip" |
| 22 | + } |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +> **Note:** The `webhookURL` should be accessible from the public internet if you want Payhip to reach your bot. If you are testing locally, use a tool like [ngrok](https://ngrok.com/) to expose your local server. |
| 27 | +
|
| 28 | +## 2. Start the Bot |
| 29 | + |
| 30 | +Run the bot using: |
| 31 | + |
| 32 | +```sh |
| 33 | +npm start |
| 34 | +``` |
| 35 | + |
| 36 | +or for development with auto-reload: |
| 37 | + |
| 38 | +```sh |
| 39 | +npm run dev |
| 40 | +``` |
| 41 | + |
| 42 | +The bot will start an Express server and listen for incoming webhook events on the configured port and path. |
| 43 | + |
| 44 | +## 3. Expose Your Webhook (Local Testing) |
| 45 | + |
| 46 | +If you are running the bot locally, you need to expose your webhook endpoint to the internet. The easiest way is to use [ngrok](https://ngrok.com/): |
| 47 | + |
| 48 | +```sh |
| 49 | +ngrok http 3000 |
| 50 | +``` |
| 51 | + |
| 52 | +This will give you a public URL (e.g., `https://abc123.ngrok.io/webhook/payhip`). Use this as your webhook URL in Payhip. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## 4. Set Up the Webhook in Payhip |
| 57 | + |
| 58 | +1. Log in to your Payhip dashboard. |
| 59 | +2. Go to **Account > Settings > Webhooks**. |
| 60 | +3. Click **Add Webhook**. |
| 61 | +4. Enter your webhook URL (from your config or ngrok) in the **Webhook URL** field. |
| 62 | +5. Select the events you want to receive (recommended: all sales, refunds, and subscriptions). |
| 63 | +6. Save the webhook. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +## 5. Test the Webhook |
| 68 | + |
| 69 | +You can test your webhook setup using the `/test` command in Discord: |
| 70 | + |
| 71 | +``` |
| 72 | +/test type:paid |
| 73 | +``` |
| 74 | + |
| 75 | +Or by making a real purchase/refund on Payhip. The bot will log incoming events and post them to the configured Discord channels. |
| 76 | + |
| 77 | +## 6. Troubleshooting |
| 78 | + |
| 79 | +- Make sure your bot is running and accessible from the internet. |
| 80 | +- Check your config for correct `webhookPort`, `webhookPath`, and `webhookURL`. |
| 81 | +- If using ngrok, ensure it is running and the URL matches what you set in Payhip. |
| 82 | +- Check the bot logs for errors (see the `logs/` directory). |
| 83 | +- Ensure your Discord channel IDs are set in the config and the bot has permission to post in those channels. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +For advanced configuration, see [Configuration](../get-started/configuration.md) and [Database](../database/config.md). |
| 88 | + |
| 89 | +> **Need help?** Join our [Discord support server](https://discord.gg/Eb384Xw). |
0 commit comments