Using Webhooks

To initiate webhook events using Fungies’s platform, whether you're a seasoned developer or a business owner with limited technical knowledge, this article is designed to help you understand webhooks.

Common Use Cases

Billing Notifications: Automatically notify your accounting system when a payment is processed. This can help streamline financial operations and ensure your records are always up-to-date.

Customer Management: Update your CRM system with new customer information whenever a subscription is created or modified. This keeps your customer data consistent and current across all platforms.

Inventory Management: Synchronize your inventory system with customer orders. When a new order is placed, the webhook can trigger updates to your inventory, helping you manage stock levels more efficiently.

Analytics and Reporting: Send event data to your analytics platform to track important metrics such as subscription renewals, cancellations, and other key performance indicators. This enables more accurate reporting and deeper insights into your business’s performance.

Preparing Your Software for Webhook Integration

Before implementing Fungies webhooks, you must prepare your software environment. This involves setting up an endpoint to receive the webhook data, ensuring your system can process the data, and configuring security measures to protect your webhook endpoint.

Step 1: Setting Up an Endpoint

What Is an Endpoint?

An endpoint is a URL on your server that listens for incoming webhook data. When an event occurs in Fungies that triggers a webhook, the data is sent to this endpoint.

How to Set Up an Endpoint

  1. Choose a URL: Decide on a URL for your webhook endpoint. This could be something like https://yourdomain.com/webhooks/fungies.

  2. Create a Route: In your software, create a route that corresponds to the endpoint URL. This route will handle incoming POST requests from Fungies.

Parse Incoming Data: Ensure your endpoint can parse the incoming JSON data. Most modern web frameworks, like Express for Node.js, Flask for Python, or Laravel for PHP, have built-in methods for handling JSON data.

Testing Example for Setting Up an Endpoint

  1. Login the https://webhook.site/ and it will be assigned a webhook handler that can accept webhook requests with POST/GET methods.

  2. Copy and store the “Your unique URL”.

Configuring Webhooks in Fungies

Now that your software is ready to receive webhooks, the next step is to configure the webhook settings in Fungies.

Step 1: Go to the Fungies platform at https://app.Fungies/login. Log in using your credentials and click on the 'Sign in with Email' button.

Step 2: Navigate to the Developers section, where you'll find the following options:

  1. Webhooks

  2. API Keys

Generating the API Keys

An API key (secret key) will be used to sign webhook events. While you can use any string for the key, it should be kept secret and used to verify the event signatures.

Step 1: To generate the API key, click on the 'API Keys' option and then select the 'Generate API Key' button.

Step 2: After clicking the 'Generate API Key' button, the Fungies system will instantly create a secret key. Click the 'Copy' button to save the secret key to your clipboard.

Creating a New Webhook

Step 1: Click on the 'Webhooks' option to access the webhook configuration page, then select the 'Create a webhook' button.

Step 2: Paste the URL you copied from 'Your unique URL' into the 'Testing Example for Setting Up an Endpoint.'

Note: This URL is for testing purposes only. You can use your custom application domain URL instead.

Step 3: Copy the secret key from the 'API Keys' page and paste it into the designated field.

Step 4: Select the webhook event you'd like to trigger. The chosen event will be triggered, providing real-time updates to your software application.

Step 5: Click on the “+ Create Webhook” button to set up the webhook.

You can view the successfully created webhooks on the Webhooks page.

Testing the Webhook

Before going live, use the “Test Webhook” feature in Fungies to send a sample payload to your endpoint.

Step 1: Click on the webhook which you want to test.

Step 2: A webhook configuration page will open. Click the 'Test' button to begin the webhook testing.

Step 3: Clicking the 'Test' button will open a window where you can choose the details for the webhook event you want to trigger for the test.

  • Select the webhook event type.

  • Choose the item name, if applicable.

  • Select the customer name, if applicable.

Step 4: Click the 'Send' button to trigger the webhook.

You can now view the trigger details (payload) on the endpoint handler you configured during the 'Setting Up an Endpoint' section.

Example of Request Payload Object (payment_success)

This is a request body payload object for the payment_success event

{
  "id": "f4cbd202-89c5-4538-b44b-11b2b7fa36ea",
  "type": "payment_success",
  "testMode": true,
  "data": {
    "items": [],
    "order": {
      "id": "47f68b70-898e-4dc8-99bd-9f30ce73c2f4",
      "totalItems": 0,
      "orderNumber": "2OJ3DJ0VP0CN"
    },
    "customer": {
      "id": "6e53e763-842e-4b19-872a-f02dfc8dc109",
      "email": "test@Fungies"
    }
  },
  "idempotencyKey": "f4cbd202-89c5-4538-b44b-11b2b7fa36ea"
}

Example of Response Object: 200

This is a response object for the payment_success event

{
"data":"This URL has no default content configured. <a href="https://webhook.site/#!/view/7b736426-27aa-4b85-bda3-5d84fbc401eb">View in Webhook.site</a>."
}

Last updated