Skip to content

ob-stripe/example-stripe-java7-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stripe webhook Java 7 example

This is a simple example project illustrating how to implement a Stripe webhooks endpoint.

It will also verify the events by using Stripe's Java library to check the events' signatures.

Note: If you're using Java 8 or higher, you should look at the example for Java 8 instead.

Use with Heroku

Head to your webhooks settings and create an endpoint with any URL (you'll change it later). Click on the button to reveal the signing secret.

Then deploy the project on your Heroku account:

Deploy

When deploying, you'll be prompted for the webhook signing secret.

Once the app is running on Heroku, head back to the webhooks settings and update the endpoint's URL with your app's URL followed by /webhook. E.g. if the URL of the Heroku app is https://thawing-crag-63114.herokuapp.com, set the endpoint's URL to be https://thawing-crag-63114.herokuapp.com/webhook.

You can then create test events and view the logs of your Heroku app to check that the events were correctly received and verified.

Use as a standalone project

Requirements

  • Java 1.7 or later
  • Maven

Instructions

Clone the repository:

git clone https://github.com/ob-stripe/example-stripe-java7-webhook.git

Compile the project:

mvn compile

Head to your webhooks settings and add a test webhook endpoint with URL set to your server's URL followed by /webhook. The server runs on port 4567 by default (you can use the PORT environment variable to change this), so for instance if your server is accessible at myserver.com, set the endpoint's URL to be http://myserver.com:4567/webhook.

If your server is not directly visible from the internet, you can use ngrok to create a tunnel:

ngrok http 4567

then set the endpoint's URL to the one provided by ngrok followed by /webhook, e.g. http://87fe9a4d.ngrok.io/webhook.

Once the endpoint is created, you can reveal the signing secret and use its value to run the project:

STRIPE_ENDPOINT_SECRET=whsec_... \
mvn exec:java

You can then create test events on your Stripe account and view the logs of the app to check that the events were correctly received and verified.

About

Stripe webhook Java 7 example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages