|
30 | 30 | from lightspark.objects.FeeEstimate import from_json as FeeEstimate_from_json
|
31 | 31 | from lightspark.objects.IncomingPayment import IncomingPayment
|
32 | 32 | from lightspark.objects.IncomingPayment import from_json as IncomingPayment_from_json
|
| 33 | +from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import ( |
| 34 | + from_json as IncomingPaymentsForInvoiceQueryOutput_from_json, |
| 35 | +) |
33 | 36 | from lightspark.objects.Invoice import Invoice
|
34 | 37 | from lightspark.objects.Invoice import from_json as Invoice_from_json
|
35 | 38 | from lightspark.objects.InvoiceData import InvoiceData
|
|
83 | 86 | from lightspark.scripts.delete_api_token import DELETE_API_TOKEN_MUTATION
|
84 | 87 | from lightspark.scripts.fetch_uma_invitation import FETCH_UMA_INVITATION_QUERY
|
85 | 88 | from lightspark.scripts.fund_node import FUND_NODE_MUTATION
|
| 89 | +from lightspark.scripts.incoming_payments_for_invoice import ( |
| 90 | + INCOMING_PAYMENTS_FOR_INVOICE_QUERY, |
| 91 | +) |
86 | 92 | from lightspark.scripts.lightning_fee_estimate_for_invoice import (
|
87 | 93 | LIGHTNING_FEE_ESTIMATE_FOR_INVOICE_QUERY,
|
88 | 94 | )
|
@@ -686,6 +692,32 @@ def outgoing_payments_for_invoice(
|
686 | 692 | for payment in json["outgoing_payments_for_invoice"]["payments"]
|
687 | 693 | ]
|
688 | 694 |
|
| 695 | + def incoming_payments_for_invoice( |
| 696 | + self, |
| 697 | + invoice_id: str, |
| 698 | + transaction_statuses: Optional[List[TransactionStatus]] = None, |
| 699 | + ) -> List[IncomingPayment]: |
| 700 | + """ |
| 701 | + Fetches the incoming payments (if any) which have been made for a given invoice. |
| 702 | +
|
| 703 | + Args: |
| 704 | + invoice_id: The encoded invoice for which to fetch the incoming payments. |
| 705 | + transaction_statuses: The statuses of the transactions to fetch. If not specified, all transactions will be fetched. |
| 706 | + """ |
| 707 | + |
| 708 | + variables: Dict[str, Any] = {"invoice_id": invoice_id} |
| 709 | + if transaction_statuses is not None: |
| 710 | + variables["transaction_statuses"] = transaction_statuses |
| 711 | + json = self._requester.execute_graphql( |
| 712 | + INCOMING_PAYMENTS_FOR_INVOICE_QUERY, variables |
| 713 | + ) |
| 714 | + if "incoming_payments_for_invoice" not in json: |
| 715 | + return [] |
| 716 | + output = IncomingPaymentsForInvoiceQueryOutput_from_json( |
| 717 | + self._requester, json["incoming_payments_for_invoice"] |
| 718 | + ) |
| 719 | + return output.payments |
| 720 | + |
689 | 721 | def create_uma_invitation(
|
690 | 722 | self,
|
691 | 723 | inviter_uma: str,
|
|
0 commit comments