Struct squareup::api::InvoicesApi
source · pub struct InvoicesApi { /* private fields */ }Expand description
Create and manage invoices.
Implementations§
source§impl InvoicesApi
impl InvoicesApi
sourcepub fn new(square_client: SquareClient) -> InvoicesApi
pub fn new(square_client: SquareClient) -> InvoicesApi
Instantiates a new InvoicesApi
sourcepub async fn list_invoices(
&self,
params: &ListInvoicesParameters
) -> Result<ListInvoicesResponse, SquareApiError>
pub async fn list_invoices( &self, params: &ListInvoicesParameters ) -> Result<ListInvoicesResponse, SquareApiError>
Returns a list of invoices for a given location.
The response is paginated. If truncated, the response includes a cursor that you use in a
subsequent request to retrieve the next set of invoices.
sourcepub async fn create_invoice(
&self,
body: &CreateInvoiceRequest
) -> Result<CreateInvoiceResponse, SquareApiError>
pub async fn create_invoice( &self, body: &CreateInvoiceRequest ) -> Result<CreateInvoiceResponse, SquareApiError>
Creates a draft [Invoice] for an order created using the Orders API.
A draft invoice remains in your account and no action is taken. You must publish the invoice before Square can process it (send it to the customer’s email address or charge the customer’s card on file).
sourcepub async fn search_invoices(
&self,
body: &SearchInvoicesRequest
) -> Result<SearchInvoicesResponse, SquareApiError>
pub async fn search_invoices( &self, body: &SearchInvoicesRequest ) -> Result<SearchInvoicesResponse, SquareApiError>
Searches for invoices from a location specified in the filter.
You can optionally specify customers in the filter for whom to retrieve invoices. In the current implementation, you can only specify one location and optionally one customer.
The response is paginated. If truncated, the response includes a cursor that you use in a
subsequent request to retrieve the next set of invoices.
sourcepub async fn delete_invoice(
&self,
invoice_id: impl AsRef<str>,
params: &DeleteInvoiceParameters
) -> Result<DeleteInvoiceResponse, SquareApiError>
pub async fn delete_invoice( &self, invoice_id: impl AsRef<str>, params: &DeleteInvoiceParameters ) -> Result<DeleteInvoiceResponse, SquareApiError>
Deletes the specified invoice.
When an invoice is deleted, the associated order status changes to CANCELED. You can only delete a draft invoice (you cannot delete a published invoice, including one that is scheduled for processing).
sourcepub async fn get_invoice(
&self,
invoice_id: impl AsRef<str>
) -> Result<GetInvoiceResponse, SquareApiError>
pub async fn get_invoice( &self, invoice_id: impl AsRef<str> ) -> Result<GetInvoiceResponse, SquareApiError>
Retrieves an invoice by invoice ID.
sourcepub async fn update_invoice(
&self,
invoice_id: impl AsRef<str>,
body: &UpdateInvoiceRequest
) -> Result<UpdateInvoiceResponse, SquareApiError>
pub async fn update_invoice( &self, invoice_id: impl AsRef<str>, body: &UpdateInvoiceRequest ) -> Result<UpdateInvoiceResponse, SquareApiError>
Updates an invoice by modifying fields, clearing fields, or both.
For most updates, you can use a sparse [Invoice] object to add fields or change values and
use the fields_to_clear field to specify fields to clear. However, some restrictions
apply. For example, you cannot change the order_id or location_id field and you must
provide the complete custom_fields list to update a custom field. Published invoices have
additional restrictions.
sourcepub async fn cancel_invoice(
&self,
invoice_id: impl AsRef<str>,
body: &CancelInvoiceRequest
) -> Result<CancelInvoiceResponse, SquareApiError>
pub async fn cancel_invoice( &self, invoice_id: impl AsRef<str>, body: &CancelInvoiceRequest ) -> Result<CancelInvoiceResponse, SquareApiError>
Cancels an invoice.
The seller cannot collect payments for the canceled invoice.
You cannot cancel an invoice in the DRAFT state or in a terminal state: PAID,
REFUNDED, CANCELED, or FAILED.
sourcepub async fn publish_invoice(
&self,
invoice_id: impl AsRef<str>,
body: &PublishInvoiceRequest
) -> Result<PublishInvoiceResponse, SquareApiError>
pub async fn publish_invoice( &self, invoice_id: impl AsRef<str>, body: &PublishInvoiceRequest ) -> Result<PublishInvoiceResponse, SquareApiError>
Publishes the specified draft invoice.
After an invoice is published, Square follows up based on the invoice configuration. For example, Square sends the invoice to the customer’s email address, charges the customer’s card on file, or does nothing. Square also makes the invoice available on a Square-hosted invoice page.
The invoice status also changes from DRAFT to a status based on the invoice
configuration. For example, the status changes to UNPAID if Square emails the invoice or
PARTIALLY_PAID if Square charge a card on file for a portion of the invoice amount.
sourcepub async fn create_invoice_attachment(
&self,
invoice_id: impl AsRef<str>,
body: &CreateInvoiceAttachmentRequest,
filepath: impl AsRef<str>
) -> Result<CreateInvoiceAttachmentResponse, SquareApiError>
pub async fn create_invoice_attachment( &self, invoice_id: impl AsRef<str>, body: &CreateInvoiceAttachmentRequest, filepath: impl AsRef<str> ) -> Result<CreateInvoiceAttachmentResponse, SquareApiError>
Uploads a file and attaches it to an invoice.
This endpoint accepts HTTP multipart/form-data file uploads with a JSON request part and a file part. The file part must be a readable stream that contains a file in a supported format: GIF, JPEG, PNG, TIFF, BMP, or PDF.
Invoices can have up to 10 attachments with a total file size of 25 MB. Attachments can be added only to invoices in the DRAFT, SCHEDULED, UNPAID, or PARTIALLY_PAID state
sourcepub async fn delete_invoice_attachment(
&self,
invoice_id: impl AsRef<str>,
attachment_id: impl AsRef<str>
) -> Result<DeleteInvoiceAttachmentResponse, SquareApiError>
pub async fn delete_invoice_attachment( &self, invoice_id: impl AsRef<str>, attachment_id: impl AsRef<str> ) -> Result<DeleteInvoiceAttachmentResponse, SquareApiError>
Removes an attachment from an invoice and permanently deletes the file.
Attachments can be removed only from invoices in the DRAFT, SCHEDULED, UNPAID, or PARTIALLY_PAID state.