Using Webhooks

Registering a Webhook

Once your vendor NDS is set up and can accept POST requests from the SDK services, you can register the webhook URL within your main application by calling the register webhook API as follows

Rust
sdk.register_webhook(
    "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string(),
)
.await?;
Swift
try sdk.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")  
Kotlin
try {
    sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
} catch (e: Exception) {
    // Handle error
}
React Native
try {
  await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
} catch (err) {
  console.error(err)
}
Dart
await breezSDKLiquid.instance!.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
Python
try:
    sdk.register_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
except Exception as error:
    logging.error(error)
    raise
Go
if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
    log.Printf("Webhook register failed: %v", err)
}
C#
try
{
    sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
    // Handle error
}

When the NDS receives a POST request for the registered webhook URL, it will forward the request data via push notification to the applications Service Extension (iOS) or Foreground Service (Android) to be handled by the Notification Plugin.

Unregistering a Webhook

When a webhook is no longer needed you can unregister the webhook as follows:

Rust
sdk.unregister_webhook().await?;
Swift
try sdk.unregisterWebhook()  
Kotlin
try {
    sdk.unregisterWebhook()
} catch (e: Exception) {
    // Handle error
}
React Native
try {
  await unregisterWebhook()
} catch (err) {
  console.error(err)
}
Dart
await breezSDKLiquid.instance!.unregisterWebhook();
Python
try:
    sdk.unregister_webhook()
except Exception as error:
    logging.error(error)
    raise
Go
if err := sdk.UnregisterWebhook(); err != nil {
    log.Printf("Webhook unregister failed: %v", err)
}
C#
try
{
    sdk.UnregisterWebhook();
}
catch (Exception)
{
    // Handle error
}

Developer note

Any payments that use a swap service will use the same registered webhook URL until the swap is complete.