Skip to content
Rebel 4 StarUML edited this page May 9, 2019 · 26 revisions

Welcome to the fastspring-webhooks wiki!

This page briefly introduces concepts needed to get started with processing FastSpring webhooks within your project. For more information about FastSpring webhooks, please see the official guide.

Overview

Webhooks can be easily imagined as event notifications, emitted by an event producer - in this case, the FastSpring. These event notifications are transferred as JSON objects, carried by the HTTP protocol, to the predefined web endpoints - event message consumers.

All webhooks share the same structure:

  • common header and
  • event-specific message payload.

Maven Dependency

To get started with the library, download it and build using maven: mvn clean install.

Then you can add the dependency to your project:

<dependency>
    <groupId>com.archetypesoftware</groupId>
    <artifactId>fastspring-webhooks</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Description of Concepts

The clear structure of webhooks events was the reason why we have introduced a class hierarchy to model them:

The base class of all webhook events, the WebHookEvent, defines attributes common for all types of events. On the other hand, each subclass shown in the diagram defines its own specific payload and is meant to represent a particular event kind.

Webhook events are always encapsulated within the Notification structure, and one Notification may include several WebHookEvents at once.

In order to make event processing an easy task for the consuming application, we have defined EventVisitor interface that needs to be implemented by a webhook consumer. Following the Visitor design pattern, it defines a method for processing each concrete WebHookEvent.

As an example, please see the diagram below, showing the definition of SubscriptionActivatedEvent:

The SubscriptionActivatedEvent simply subclasses WebHookEvent and defines template substitution relation that specifies SubscriptionActivatedPayload as the payload of this particular kind of event.

For more information, do not hesitate to contact us or to browse the UML model and the source code of the project.

Clone this wiki locally