WebhookSubscriptionsApi webhookSubscriptionsApi = client.getWebhookSubscriptionsApi();
WebhookSubscriptionsApi
- List Webhook Event Types
- List Webhook Subscriptions
- Create Webhook Subscription
- Delete Webhook Subscription
- Retrieve Webhook Subscription
- Update Webhook Subscription
- Update Webhook Subscription Signature Key
- Test Webhook Subscription
Lists all webhook event types that can be subscribed to.
CompletableFuture<ListWebhookEventTypesResponse> listWebhookEventTypesAsync(
final String apiVersion)
Parameter | Type | Tags | Description |
---|---|---|---|
apiVersion |
String |
Query, Optional | The API version for which to list event types. Setting this field overrides the default version used by the application. |
webhookSubscriptionsApi.listWebhookEventTypesAsync(null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Lists all webhook subscriptions owned by your application.
CompletableFuture<ListWebhookSubscriptionsResponse> listWebhookSubscriptionsAsync(
final String cursor,
final Boolean includeDisabled,
final String sortOrder,
final Integer limit)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
String |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. For more information, see Pagination. |
includeDisabled |
Boolean |
Query, Optional | Includes disabled Subscriptions. By default, all enabled Subscriptions are returned. Default: false |
sortOrder |
String |
Query, Optional | Sorts the returned list by when the Subscription was created with the specified order. This field defaults to ASC. |
limit |
Integer |
Query, Optional | The maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default value of 100 is also the maximum allowed value. Default: 100 |
ListWebhookSubscriptionsResponse
Boolean includeDisabled = false;
webhookSubscriptionsApi.listWebhookSubscriptionsAsync(null, includeDisabled, null, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Creates a webhook subscription.
CompletableFuture<CreateWebhookSubscriptionResponse> createWebhookSubscriptionAsync(
final CreateWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
CreateWebhookSubscriptionResponse
CreateWebhookSubscriptionRequest body = new CreateWebhookSubscriptionRequest.Builder(
new WebhookSubscription.Builder()
.name("Example Webhook Subscription")
.eventTypes(Arrays.asList(
"payment.created",
"payment.updated"
))
.notificationUrl("https://example-webhook-url.com")
.apiVersion("2021-12-15")
.build()
)
.idempotencyKey("63f84c6c-2200-4c99-846c-2670a1311fbf")
.build();
webhookSubscriptionsApi.createWebhookSubscriptionAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Deletes a webhook subscription.
CompletableFuture<DeleteWebhookSubscriptionResponse> deleteWebhookSubscriptionAsync(
final String subscriptionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
String |
Template, Required | [REQUIRED] The ID of the Subscription to delete. |
DeleteWebhookSubscriptionResponse
String subscriptionId = "subscription_id0";
webhookSubscriptionsApi.deleteWebhookSubscriptionAsync(subscriptionId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves a webhook subscription identified by its ID.
CompletableFuture<RetrieveWebhookSubscriptionResponse> retrieveWebhookSubscriptionAsync(
final String subscriptionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
String |
Template, Required | [REQUIRED] The ID of the Subscription to retrieve. |
RetrieveWebhookSubscriptionResponse
String subscriptionId = "subscription_id0";
webhookSubscriptionsApi.retrieveWebhookSubscriptionAsync(subscriptionId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Updates a webhook subscription.
CompletableFuture<UpdateWebhookSubscriptionResponse> updateWebhookSubscriptionAsync(
final String subscriptionId,
final UpdateWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
String |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
UpdateWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
UpdateWebhookSubscriptionResponse
String subscriptionId = "subscription_id0";
UpdateWebhookSubscriptionRequest body = new UpdateWebhookSubscriptionRequest.Builder()
.subscription(new WebhookSubscription.Builder()
.name("Updated Example Webhook Subscription")
.enabled(false)
.build())
.build();
webhookSubscriptionsApi.updateWebhookSubscriptionAsync(subscriptionId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Updates a webhook subscription by replacing the existing signature key with a new one.
CompletableFuture<UpdateWebhookSubscriptionSignatureKeyResponse> updateWebhookSubscriptionSignatureKeyAsync(
final String subscriptionId,
final UpdateWebhookSubscriptionSignatureKeyRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
String |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
UpdateWebhookSubscriptionSignatureKeyRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
UpdateWebhookSubscriptionSignatureKeyResponse
String subscriptionId = "subscription_id0";
UpdateWebhookSubscriptionSignatureKeyRequest body = new UpdateWebhookSubscriptionSignatureKeyRequest.Builder()
.idempotencyKey("ed80ae6b-0654-473b-bbab-a39aee89a60d")
.build();
webhookSubscriptionsApi.updateWebhookSubscriptionSignatureKeyAsync(subscriptionId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Tests a webhook subscription by sending a test event to the notification URL.
CompletableFuture<TestWebhookSubscriptionResponse> testWebhookSubscriptionAsync(
final String subscriptionId,
final TestWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
String |
Template, Required | [REQUIRED] The ID of the Subscription to test. |
body |
TestWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
TestWebhookSubscriptionResponse
String subscriptionId = "subscription_id0";
TestWebhookSubscriptionRequest body = new TestWebhookSubscriptionRequest.Builder()
.eventType("payment.created")
.build();
webhookSubscriptionsApi.testWebhookSubscriptionAsync(subscriptionId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});