Skip to content

getopenpay/webhooks-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Testing Application

This is a simple Express.js application for testing webhooks with OpenPay. It includes webhook signature verification to ensure the authenticity of incoming webhook requests.

Prerequisites

  • Node.js installed on your system
  • ngrok installed (for local development)
  • An OpenPay account with webhook configuration

Setup

  1. Install dependencies:
pnpm install
  1. Configure your webhook secret:

    • Open app.ts
    • Replace the empty string in WH_SECRET_KEY with your webhook secret from the OpenPay dashboard
  2. Start the application:

pnpm build
pnpm start

Using ngrok for Local Development

  1. Install ngrok if you haven't already:
npm install -g ngrok
  1. Start ngrok to create a public URL for your local server:
ngrok http 8080
  1. Copy the HTTPS URL provided by ngrok (it will look like https://xxxx-xx-xx-xxx-xx.ngrok.io)

  2. Configure your webhook in the OpenPay dashboard:

    • Go to your OpenPay dashboard
    • Navigate to the webhook settings
    • Set the webhook URL to your ngrok URL + /webhook (e.g., https://xxxx-xx-xx-xxx-xx.ngrok.io/webhook)

Testing Webhooks

  1. The application will listen for POST requests at /webhook
  2. Incoming webhooks will be automatically verified using the signature-digest header
  3. Valid webhooks will be logged to the console
  4. The application will respond with a 200 status code for successful webhook processing

Security

  • The application uses the @getopenpay/client package to verify webhook signatures
  • Make sure to keep your webhook secret key secure and never commit it to version control
  • The application will reject webhooks with invalid signatures

Troubleshooting

  • If you receive "Invalid webhook signature" errors, verify that:
    • Your webhook secret key is correctly set in the application
    • The signature-digest header is being sent with the webhook request
    • The request body matches exactly what was sent by OpenPay

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published