Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Osiris-Team committed Mar 31, 2021
2 parents b0fcb68 + 286175f commit 2515e24
Showing 1 changed file with 138 additions and 20 deletions.
158 changes: 138 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# PayHook
A Java-API for validating PayPals Webhooks.
# NOTE: STILL IN DEVELOPMENT! FEATURES ARE NOT FUNCTIONAL YET!
# PayHook [![](https://jitpack.io/v/Osiris-Team/PayHook.svg)](https://jitpack.io/#Osiris-Team/PayHook)
A Java-API for validating PayPals Webhook events/notifications.
# NOTE: STILL IN DEVELOPMENT! MAY NOT BE FULLY FUNCTIONAL YET!
## Links
- Support and chat over at [Discord](https://discord.com/invite/GGNmtCC)
## Installation
[Click here for maven/gradle/sbt/leinigen instructions.](https://jitpack.io/#Osiris-Team/PayHook/LATEST)
Java 8+ required.
Expand All @@ -9,8 +11,9 @@ Make sure to watch this repository to get notified of future updates.
Basically PayPals latest [Checkout v2 Java-SDK](https://github.com/paypal/Checkout-Java-SDK)
is missing the webhook event validation feature, which was available in the old, deprecated
[PayPal Java-SDK](https://github.com/paypal/PayPal-Java-SDK).
That's why PayHook exists. Its aim, is to provide an easy to use Java-API for validating
webhook events.
That's why PayHook exists. Its aim, is to provide a fast and easy to use Java-API for validating
webhook events, without the need of any extra dependencies.
PayHook is based on the official, old [PayPal Java-SDK](https://github.com/paypal/PayPal-Java-SDK).
## Usage example
This example uses spring(tomcat) to listen for POST requests.
Nevertheless, this can be easily ported to your web application.
Expand All @@ -26,35 +29,27 @@ public class PayHookExample {

System.out.println("Received webhook event at .../paypal-hook/...");
try{

// Get the header and body
Map<String, String> headerAsMap = getHeadersAsMap(request);
String bodyAsString = getBodyAsString(request);

PayHook payHook = new PayHook();
payHook.setSandboxMode(true); // Default is false. Remove this in production.

WebhookEventHeader header = payHook.parseAndGetHeader(headerAsMap);
JsonObject body = payHook.parseAndGetBody(bodyAsString);
// Get the header and body
WebhookEventHeader header = payHook.parseAndGetHeader(getHeadersAsMap(request));
JsonObject body = payHook.parseAndGetBody(getBodyAsString(request));

// Create this event
WebhookEvent event = new WebhookEvent(
"insert your valid webhook id here", // Get it from here: https://developer.paypal.com/developer/applications/
Arrays.asList("CHECKOUT.ORDER.APPROVED", "PAYMENTS.PAYMENT.CREATED"), // Insert your valid event type here. Full list of all event types/name here: https://developer.paypal.com/docs/api-basics/notifications/webhooks/event-names
Arrays.asList("CHECKOUT.ORDER.APPROVED", "PAYMENTS.PAYMENT.CREATED"), // Insert your valid event types/names here. Full list of all event types/names here: https://developer.paypal.com/docs/api-basics/notifications/webhooks/event-names
header,
body);

// Do event validation
try{
payHook.validateWebhookEvent(event);
// Do stuff on validation success here
} catch (Exception e) {
System.out.println("Validation failed: "+e.getMessage());
// Do stuff on validation fail here
}
payHook.validateWebhookEvent(event);
System.out.println("Validation successful!");

} catch (Exception e) {
e.printStackTrace();
System.out.println("Validation failed: "+e.getMessage());
}
return "OK";
}
Expand Down Expand Up @@ -109,3 +104,126 @@ The body is a json string with a bunch of event specific data.
For more details see the paypal docs: <a href="https://developer.paypal.com/docs/api-basics/notifications/webhooks/notification-messages/">webhooks/notification-messages</a>
</details>
</div>

## Tags
<div>
<details>
<summary>Open/Close tags</summary>
Tags are used to make this repository easier to find for others. <br>
paypal validate webhook java
paypal java webhook example
paypal webhook
webhook paypal
paypal java webhooks
paypal java webhook example
paypal webhook
java paypal integration
java paypal api
paypal validate webhook java
paypal java webhooks
paypal java webhook example
paypal webhook
java paypal integration
java paypal api
paypal validate webhook java
paypal webhook events
paypal webhooks tutorial
paypal webhook listener example
paypal webhook simulator
paypal webhook id
paypal webhook api
paypal webhook listener
paypal webhook localhost
paypal webhook authentication
paypal add webhook
paypal api webhook event
paypal webhook ip address
paypal billing agreement webhook
what is a paypal webhooks
webhook paypal
paypal button webhook
paypal smart button webhook
paypal webhook c#
paypal webhook custom field
paypal webhook certificate
paypal create webhook
paypal checkout webhook
paypal configure webhooks
paypal.com webhooks
paypal webhook payment.sale.completed
paypal webhook delay
paypal webhook documentation
paypal webhook discord
paypal donation webhook
paypal dispute webhook
webhook data paypal
paypal webhook example
paypal webhook event types
paypal webhook example php
paypal webhook endpoint
paypal webhook einrichten
paypal webhook example c#
paypal webhook events pending
paypal webhook for recurring payment
paypal webhook format
paypal webhook get
paypal api get webhook
paypal handle webhooks
paypal webhook ip
paypal webhook ipn
paypal webhook implementation
paypal webhook vs ipn
paypal webhooks interface
paypal payouts webhook id
paypal webhook java
paypal validate webhook java
paypal webhook node js
paypal java webhook example
paypal webhook listener php example
paypal webhook listener example c#
paypal webhook listener example nodejs
paypal webhook listener php
paypal webhooks laravel
paypal manage webhooks
paypal webhook not working
paypal webhook nodejs
paypal webhook .net
paypal webhook notifications not working
paypal webhook simulator not working
paypal sandbox webhook not working
paypal webhook event names
paypal ipn or webhook
paypal webhook php
paypal webhook python
paypal webhook pending
paypal webhook payload
paypal webhook port
paypal payment webhook
paypal plus webhook
paypal webhook url
paypal webhook retry
paypal webhook response
paypal webhook reference id
paypal webhook refund
paypal webhook recurring payment
paypal send webhook
paypal subscription renew webhook
paypal webhooks
paypal webhooks simulator
paypal webhooks example
paypal webhooks php
paypal webhooks localhost
paypal webhooks vs ipn
paypal webhook tutorial
paypal webhook test
paypal not a valid webhook url
paypal webhook verification
paypal webhook validation
paypal webhook validate
paypal webhook verify signature
paypal webhook validation php
woocommerce paypal webhook
magento 2 paypal webhook
shopware 6 paypal webhook
</details>
</div>

0 comments on commit 2515e24

Please sign in to comment.