Set up a webhook handler to listen for and process Parafin events. Test out your webhook handler by:
- using ngrok to create a temporary public URL to tunnel requests to your local application
- triggering events in sandbox mode with Parafin's Trigger Webhook endpoint
- Access to a Parafin dashboard
- Node.js
- ngrok
First, clone the repository and install dependencies:
$ git clone https://github.com/buildparafin/parafin-webhooks-quickstart.git
$ cd parafin-webhooks-quickstart
$ npm install
Start a new ngrok tunnel from your terminal, specifying the port you plan on using for your local server.
$ ngrok http 3000
⚠️ Heads up!
This ngrok forwarding URL has an exipiry of about two hours. You will need to refresh your session every time you plan on testing this.
Navigate to the Webhooks section of the Parafin dashboard. Using the forwarding URL generated from ngrok in the previous step, submit your webhook URL (e.g. https://097f-67-169-0-215.ngrok.io/parafin-webhook-handler
)
Copy the generated webhook secret key, rename the sample.env
file to .env
, and populate with your webhook secret key.
$ mv sample.env .env
# .env
WEBHOOK_SECRET="<your-webhook-secret-key>"
In a separate terminal tab, run the following to start listening for events:
$ npm start
Once your webhook handler is running and listening for events, Fetch your client ID and client secret from the Parafin dashboard and use our Trigger Webhook endpoint to simulate events.
curl https://api.parafin.com/v1/sandbox/trigger_webhook \
-u <your-client-id>:<your-client-secret> \
-d '{
"webhook_event_type": "flex_loan_offer_created"
}'
If everything succeeded, you should see the following response:
{
"success": "true"
}