mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Add snippets
This commit is contained in:
32
snippets/csharp/Webhook.cs
Normal file
32
snippets/csharp/Webhook.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Breez.Sdk;
|
||||||
|
|
||||||
|
public class ServiceStatusSnippets
|
||||||
|
{
|
||||||
|
public void Webhook(BlockingBreezServices sdk)
|
||||||
|
{
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sdk.RegisterWebhook("https://yourapplication.com");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PaymentWebhook(BlockingBreezServices sdk)
|
||||||
|
{
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
|
}
|
||||||
14
snippets/dart_snippets/lib/webhook.dart
Normal file
14
snippets/dart_snippets/lib/webhook.dart
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import 'package:breez_sdk/breez_sdk.dart';
|
||||||
|
import 'package:breez_sdk/bridge_generated.dart';
|
||||||
|
|
||||||
|
Future<void> webhook() async {
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
await BreezSDK().registerWebhook("https://yourapplication.com");
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> paymentWebhook({required String paymentHash}) async {
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
await BreezSDK().registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
21
snippets/go/webhook.go
Normal file
21
snippets/go/webhook.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Webhook() {
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
if err := sdk.RegisterWebhook("https://yourapplication.com"); err != nil {
|
||||||
|
log.Printf("Webhook registration failed: %v", err)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
func PaymentWebhook() {
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
|
||||||
|
log.Printf("Webhook registration failed: %v", err)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.example.kotlinmpplib
|
||||||
|
|
||||||
|
import breez_sdk.*
|
||||||
|
class ServiceStatus {
|
||||||
|
fun Webhook(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
try {
|
||||||
|
sdk.registerWebhook("https://yourapplication.com")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
fun paymentWebhook(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
try {
|
||||||
|
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
|
}
|
||||||
19
snippets/python/src/webhook.py
Normal file
19
snippets/python/src/webhook.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import breez_sdk
|
||||||
|
|
||||||
|
def webhook(sdk_services):
|
||||||
|
try:
|
||||||
|
# ANCHOR: register-webook
|
||||||
|
sdk_services.registerWebhook("https://yourapplication.com")
|
||||||
|
# ANCHOR_END: register-webook
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def paymentWebhook(sdk_services):
|
||||||
|
try:
|
||||||
|
# ANCHOR: register-payment-webook
|
||||||
|
sdk_services.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
|
||||||
|
# ANCHOR_END: register-payment-webook
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
13
snippets/react-native/webhook.ts
Normal file
13
snippets/react-native/webhook.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { registerWebhook } from '@breeztech/react-native-breez-sdk'
|
||||||
|
|
||||||
|
const webhook = async () => {
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
await registerWebhook("https://yourapplication.com")
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
const paymentWebhook = async () => {
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
20
snippets/swift/BreezSDKExamples/Sources/Webhook.swift
Normal file
20
snippets/swift/BreezSDKExamples/Sources/Webhook.swift
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// ServiceStatus.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import BreezSDK
|
||||||
|
|
||||||
|
func webhook(sdk: BlockingBreezServices) throws {
|
||||||
|
// ANCHOR: register-webook
|
||||||
|
sdk.registerWebhook("https://yourapplication.com")
|
||||||
|
// ANCHOR_END: register-webook
|
||||||
|
}
|
||||||
|
|
||||||
|
func paymentWebhook(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: register-payment-webook
|
||||||
|
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>").await?
|
||||||
|
// ANCHOR_END: register-payment-webook
|
||||||
|
}
|
||||||
@@ -20,6 +20,63 @@ Next, register this URL with the Breez SDK. This step involves calling a specifi
|
|||||||
{{#include ../../snippets/rust/src/webhook.rs:register-webook}}
|
{{#include ../../snippets/rust/src/webhook.rs:register-webook}}
|
||||||
```
|
```
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/Webhook.swift:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/webhook.ts:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/webhook.dart:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/webhook.py:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/webhook.go:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/Webhook.cs:register-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
</custom-tabs>
|
</custom-tabs>
|
||||||
|
|
||||||
## Handling Incoming Notifications
|
## Handling Incoming Notifications
|
||||||
@@ -71,6 +128,63 @@ Register the constructed URL with the Breez SDK By calling an SDK function.
|
|||||||
{{#include ../../snippets/rust/src/webhook.rs:register-payment-webook}}
|
{{#include ../../snippets/rust/src/webhook.rs:register-payment-webook}}
|
||||||
```
|
```
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/Webhook.swift:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/webhook.ts:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/webhook.dart:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/webhook.py:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/webhook.go:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/Webhook.cs:register-payment-webook}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
</custom-tabs>
|
</custom-tabs>
|
||||||
|
|
||||||
## Step 4: Handling Notifications When the App is Not Running
|
## Step 4: Handling Notifications When the App is Not Running
|
||||||
|
|||||||
Reference in New Issue
Block a user