|
| 1 | +from bitpay.models.facade import Facade |
| 2 | +from bitpay.models.invoice.buyer import Buyer |
| 3 | +from bitpay.models.invoice.invoice import Invoice |
| 4 | +from examples.client_provider import ClientProvider |
| 5 | + |
| 6 | + |
| 7 | +class InvoiceRequests: |
| 8 | + def create_invoice(self) -> None: |
| 9 | + invoice = Invoice() |
| 10 | + invoice.full_notifications = True |
| 11 | + invoice.extended_notifications = True |
| 12 | + invoice.notification_url = "https://test/lJnJg9WW7MtG9GZlPVdj" |
| 13 | + invoice.redirect_url = "https://test/lJnJg9WW7MtG9GZlPVdj" |
| 14 | + invoice. notification_email = "[email protected]" |
| 15 | + |
| 16 | + buyer = Buyer() |
| 17 | + buyer.name = "Test" |
| 18 | + |
| 19 | + buyer.address1 = "168 General Grove" |
| 20 | + buyer.country = "AD" |
| 21 | + buyer.locality = "Port Horizon" |
| 22 | + buyer.notify = True |
| 23 | + buyer.phone = "+990123456789" |
| 24 | + buyer.postal_code = "KY7 1TH" |
| 25 | + buyer.region = "New Port" |
| 26 | + |
| 27 | + invoice.buyer = buyer |
| 28 | + |
| 29 | + client = ClientProvider.create() |
| 30 | + |
| 31 | + result = client.create_invoice(invoice, Facade.MERCHANT) |
| 32 | + |
| 33 | + def get_invoice(self) -> None: |
| 34 | + client = ClientProvider.create() |
| 35 | + |
| 36 | + invoice_by_id = client.get_invoice('someInvoiceId') |
| 37 | + |
| 38 | + invoice_by_guid = client.get_invoice_by_guid('someGuid') |
| 39 | + |
| 40 | + invoices = client.get_invoices('2023-04-14', '2023-04-17') |
| 41 | + |
| 42 | + def update_invoice(self) -> None: |
| 43 | + client = ClientProvider.create() |
| 44 | + |
| 45 | + result = client.update_invoice('someInvoiceId', None, '123123213') |
| 46 | + |
| 47 | + def cancel_invoice(self) -> None: |
| 48 | + client = ClientProvider.create() |
| 49 | + |
| 50 | + client.cancel_invoice('someInvoiceId') |
| 51 | + |
| 52 | + client.cancel_invoice_by_guid('someGuid') |
| 53 | + |
| 54 | + def request_invoice_webhook_to_be_resent(self) -> None: |
| 55 | + client = ClientProvider.create() |
| 56 | + |
| 57 | + client.request_invoice_notifications('someInvoiceId') |
0 commit comments