1.1.5 • Published 7 months ago

feresbr-webhooktester v1.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Webhook Tester

A simple real-time tool for testing webhooks in your local development environment. It allows you to inspect webhook data sent from services like Stripe, PayPal, WhatsApp, and others, making webhook integration debugging a breeze.

Installation

Prerequisites:

  • Node.js and npm (or yarn) installed on your system.

Steps:

  1. Open your terminal and navigate to your project directory.
  2. Run the following command to install the feresbr-webhooktester package:
npm install feresbr-webhooktester 

You must use a Tunneling Service (for Local Testing) Since services like Paypal, Stripe, Whatsapp needs to send webhooks to a publicly accessible URL, and your tester is running on localhost, you need a tunneling service. Popular options include ngrok Very easy to use. After installing ngrok, run ngrok http 3001 (replace 3001 with your chosen port). Ngrok will give you a public URL (e.g., https://xxxxxx.ngrok.io) that forwards requests to your local port.

Trigger a PayPal Event for example, The user then performs an action that would trigger a webhook from PayPal (e.g., completes a test payment in the PayPal sandbox).

Inspect the Webhook The webhook will be sent from PayPal to the ngrok URL, which will forward it to the local webhook tester. The user can then view the received webhook data in their browser at http://localhost:3001.

Example Workflow:

Steps:

  1. User starts the webhook tester (listening on port 3001).
  2. User runs ngrok http 3001. ngrok provides the URL https://12345.ngrok.io.
  3. User goes to their PayPal developer dashboard and sets the webhook URL to https://12345.ngrok.io/webhook.
  4. User performs a test payment in PayPal.
  5. PayPal sends the webhook to https://12345.ngrok.io/webhook.
  6. ngrok forwards the webhook to http://localhost:3001/webhook.
  7. The webhook tester receives the webhook and displays it in the user's browser at http://localhost:3001.
  8. In summary The webhook-tester provides the receiving end of the webhook communication. The tunneling service (like ngrok) bridges the gap between the local development environment and the external service (like PayPal), allowing the webhooks to reach the tester. The user needs to configure the external service to send webhooks to the ngrok URL.

Usage:

    const webhookTester = require('feresbr-webhooktester');
    
    async function testWebhook() {

    const tester = webhookTester({ port: 3001, path: '/my-webhook' });

    const url = await tester.start();

    console.log(`Tester started at: ${url}`);

      //Send a webhook to http://localhost:3001/my-webhook using Postman or curl...

     // Get the received webhooks
     const receivedWebhooks = tester.getWebhooks();
     console.log("Received data:", receivedWebhooks);

    //stop the server when you're done
    // tester.stop();
    }

testWebhook();
1.1.5

7 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.0

7 months ago