Listing payments
To view your payment history you can list all the sent and received payments made.
Rust
let payments = sdk.list_payments(&ListPaymentsRequest::default()).await?;
Swift
let payments = try? sdk.listPayments(req: ListPaymentsRequest())
Kotlin
try {
val payments = sdk.listPayments(ListPaymentsRequest())
} catch (e: Exception) {
// handle error
}
React Native
const payments = await listPayments({})
Dart
ListPaymentsRequest req = ListPaymentsRequest();
List<Payment> paymentsList = await breezSDKLiquid.instance!.listPayments(req: req);
Python
sdk.list_payments(ListPaymentsRequest())
Go
if payments, err := sdk.ListPayments(breez_sdk_liquid.ListPaymentsRequest{}); err == nil {
log.Printf("%#v", payments)
}
C#
try
{
var payments = sdk.ListPayments(new ListPaymentsRequest());
}
catch (Exception)
{
// Handle error
}
You can optionally filter payments by timestamp and type.
Rust
let payments = sdk
.list_payments(&ListPaymentsRequest {
filters: Some(vec![PaymentType::Send]),
from_timestamp: Some(1696880000),
to_timestamp: Some(1696959200),
offset: Some(0),
limit: Some(50),
details: None,
})
.await?;
Swift
let payments = try? sdk.listPayments(
req: ListPaymentsRequest(
filters: [.send],
fromTimestamp: 1696880000,
toTimestamp: 1696959200,
offset: 0,
limit: 50
))
Kotlin
try {
val payments = sdk.listPayments(
ListPaymentsRequest(
listOf(PaymentType.SEND),
fromTimestamp = 1696880000,
toTimestamp = 1696959200,
offset = 0u,
limit = 50u
))
} catch (e: Exception) {
// handle error
}
React Native
try {
const payments = await listPayments({
filters: [PaymentType.SEND],
fromTimestamp: 1696880000,
toTimestamp: 1696959200,
offset: 0,
limit: 50
})
} catch (err) {
console.error(err)
}
Dart
ListPaymentsRequest req = ListPaymentsRequest(
filters: [PaymentType.send],
fromTimestamp: 1696880000,
toTimestamp: 1696959200,
offset: 0,
limit: 50,
);
List<Payment> paymentsList = await breezSDKLiquid.instance!.listPayments(req: req);
Python
req = ListPaymentsRequest(
[PaymentType.SEND],
from_timestamp = 1696880000,
to_timestamp = 1696959200,
offset = 0,
limit = 50)
sdk.list_payments(req)
Go
filters := []breez_sdk_liquid.PaymentType{breez_sdk_liquid.PaymentTypeSend}
fromTimestamp := int64(1696880000)
toTimestamp := int64(1696959200)
limit := uint32(50)
offset := uint32(0)
listPaymentsRequest := breez_sdk_liquid.ListPaymentsRequest{
Filters: &filters,
FromTimestamp: &fromTimestamp,
ToTimestamp: &toTimestamp,
Offset: &offset,
Limit: &limit,
}
if payments, err := sdk.ListPayments(listPaymentsRequest); err == nil {
log.Printf("%#v", payments)
}
C#
try
{
var payments = sdk.ListPayments(
new ListPaymentsRequest(
new() { PaymentType.Send },
fromTimestamp: 1696880000,
toTimestamp: 1696959200,
offset: 0,
limit: 50
));
}
catch (Exception)
{
// Handle error
}
Get Payment
You can also retrieve a single Lightning payment using the invoice payment hash.
Rust
let payment_hash = "<payment hash>".to_string();
let payment = sdk.get_payment(&GetPaymentRequest::Lightning {
payment_hash
}).await?;
Swift
let paymentHash = "<payment hash>"
let payment = try? sdk.getPayment(
req: GetPaymentRequest.lightning(paymentHash: paymentHash)
)
Kotlin
try {
val paymentHash = "<payment hash>";
val payment = sdk.getPayment(GetPaymentRequest.Lightning(paymentHash))
} catch (e: Exception) {
// handle error
}
React Native
const paymentHash = '<payment hash>'
const payment = await getPayment({
type: GetPaymentRequestVariant.LIGHTNING,
paymentHash
})
Dart
String paymentHash = "<payment hash>";
GetPaymentRequest req = GetPaymentRequest.lightning(paymentHash: paymentHash);
Payment? payment = await breezSDKLiquid.instance!.getPayment(req: req);
Python
payment_hash = "<payment hash>"
sdk.get_payment(GetPaymentRequest.LIGHTNING(payment_hash))
Go
paymentHash := "<payment hash>"
req := breez_sdk_liquid.GetPaymentRequestLightning{
PaymentHash: paymentHash,
}
if payment, err := sdk.GetPayment(req); err == nil {
log.Printf("%#v", payment)
}
C#
try
{
var paymentHash = "<payment hash>";
var payment = sdk.GetPayment(
new GetPaymentRequest.Lightning(paymentHash)
);
}
catch (Exception)
{
// Handle error
}