Listing payments

To view your payment history you can list and filter 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
try {
  const payments = await listPayments({})
} catch (err) {
  console.error(err)
}
Dart
ListPaymentsRequest req = ListPaymentsRequest();
List<Payment> paymentsList = await breezSDK.listPayments(req: req);
print(paymentsList);
Python
sdk_services.list_payments(breez_sdk.ListPaymentsRequest(breez_sdk.PaymentTypeFilter.All))
Go
if payments, err := sdk.ListPayments(breez_sdk.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 include failed payments.

Rust
let payments = sdk
    .list_payments(ListPaymentsRequest {
        filters: Some(vec![PaymentTypeFilter::Sent]),
        from_timestamp: Some(1696880000),
        include_failures: Some(true),
        ..Default::default()
    })
    .await?;
Swift
let payments = try? sdk.listPayments(
    req: ListPaymentsRequest(
        filters: [.sent],
        fromTimestamp: 1_696_880_000,
        includeFailures: true
    ))
Kotlin
try {
    val payments = sdk.listPayments(
        ListPaymentsRequest(
            listOf(PaymentTypeFilter.SENT),
            fromTimestamp = 1696880000,
            includeFailures = true
        ))
} catch (e: Exception) {
    // handle error
}
React Native
try {
  const payments = await listPayments({
    filters: [PaymentTypeFilter.SENT],
    fromTimestamp: 1696880000,
    includeFailures: true
  })
} catch (err) {
  console.error(err)
}
Dart
/// Get the desired epoch timestamp in seconds
int fromTimestamp = DateTime.now().subtract(const Duration(minutes: 30)).millisecondsSinceEpoch ~/ 1000;

ListPaymentsRequest req = ListPaymentsRequest(
  filters: [PaymentTypeFilter.Sent],
  fromTimestamp: fromTimestamp,
  toTimestamp: toTimestamp,
  includeFailures: includeFailures,
  offset: offset,
  limit: limit,
);
List<Payment> paymentsList = await breezSDK.listPayments(req: req);
print(paymentsList);
Python
req = breez_sdk.ListPaymentsRequest(
    breez_sdk.PaymentTypeFilter.Sent, 
    from_timestamp = 1696880000, 
    include_failures = True)
sdk_services.list_payments(req)
Go
filters := []breez_sdk.PaymentTypeFilter{breez_sdk.PaymentTypeFilterSent}
fromTimestamp := int64(1696880000)
includeFailures := true
listPaymentsRequest := breez_sdk.ListPaymentsRequest{
    Filters:         &filters,
    FromTimestamp:   &fromTimestamp,
    IncludeFailures: &includeFailures,
}
if payments, err := sdk.ListPayments(listPaymentsRequest); err == nil {
    log.Printf("%#v", payments)
}
C#
try
{
    var payments = sdk.ListPayments(
        new ListPaymentsRequest(
            new() { PaymentTypeFilter.SENT },
            fromTimestamp: 1696880000,
            includeFailures: true));
}
catch (Exception)
{
    // Handle error
}