Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
427 lines (284 loc) · 15.7 KB

InvoicesApi.md

File metadata and controls

427 lines (284 loc) · 15.7 KB

SquareConnect.InvoicesApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
cancelInvoice POST /v2/invoices/{invoice_id}/cancel CancelInvoice
createInvoice POST /v2/invoices CreateInvoice
deleteInvoice DELETE /v2/invoices/{invoice_id} DeleteInvoice
getInvoice GET /v2/invoices/{invoice_id} GetInvoice
listInvoices GET /v2/invoices ListInvoices
publishInvoice POST /v2/invoices/{invoice_id}/publish PublishInvoice
searchInvoices POST /v2/invoices/search SearchInvoices
updateInvoice PUT /v2/invoices/{invoice_id} UpdateInvoice

cancelInvoice

Note: This endpoint is in beta.

CancelInvoiceResponse cancelInvoice(invoiceId, body)

CancelInvoice

Cancels an invoice. The seller cannot collect payments for the canceled invoice. You cannot cancel an invoice in a terminal state: `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var invoiceId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The ID of the `invoice` to cancel.

var body = SquareConnect.InvoicesApi.constructFromObject({}); // CancelInvoiceRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.cancelInvoice(invoiceId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
invoiceId String The ID of the `invoice` to cancel.
body CancelInvoiceRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CancelInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

createInvoice

Note: This endpoint is in beta.

CreateInvoiceResponse createInvoice(body)

CreateInvoice

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).

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var body = SquareConnect.InvoicesApi.constructFromObject({}); // CreateInvoiceRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createInvoice(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body CreateInvoiceRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

deleteInvoice

Note: This endpoint is in beta.

DeleteInvoiceResponse deleteInvoice(invoiceId, opts)

DeleteInvoice

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).

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var invoiceId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The ID of the invoice to delete.

var opts = { 
  'version': SquareConnect.InvoicesApi.constructFromObject({}); // Number | The version of the `invoice` to delete. If you do not know the version, you can call `GetInvoice` or  `ListInvoices`.
};
apiInstance.deleteInvoice(invoiceId, opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
invoiceId String The ID of the invoice to delete.
version Number The version of the `invoice` to delete. If you do not know the version, you can call `GetInvoice` or `ListInvoices`. [optional]

Return type

DeleteInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

getInvoice

Note: This endpoint is in beta.

GetInvoiceResponse getInvoice(invoiceId)

GetInvoice

Retrieves an invoice by invoice ID.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var invoiceId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The id of the invoice to retrieve.

apiInstance.getInvoice(invoiceId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
invoiceId String The id of the invoice to retrieve.

Return type

GetInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listInvoices

Note: This endpoint is in beta.

ListInvoicesResponse listInvoices(locationId, opts)

ListInvoices

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 fetch the next set of invoices.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var locationId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The ID of the location for which to list invoices.

var opts = { 
  'cursor': SquareConnect.InvoicesApi.constructFromObject({});, // String | A pagination cursor returned by a previous call to this endpoint.  Provide this cursor to retrieve the next set of results for your original query.  For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination).
  'limit': SquareConnect.InvoicesApi.constructFromObject({}); // Number | The maximum number of invoices to return (200 is the maximum `limit`).  If not provided, the server  uses a default limit of 100 invoices.
};
apiInstance.listInvoices(locationId, opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
locationId String The ID of the location for which to list invoices.
cursor String A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of results for your original query. For more information, see Pagination. [optional]
limit Number The maximum number of invoices to return (200 is the maximum `limit`). If not provided, the server uses a default limit of 100 invoices. [optional]

Return type

ListInvoicesResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

publishInvoice

Note: This endpoint is in beta.

PublishInvoiceResponse publishInvoice(invoiceId, body)

PublishInvoice

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).

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var invoiceId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The id of the invoice to publish.

var body = SquareConnect.InvoicesApi.constructFromObject({}); // PublishInvoiceRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.publishInvoice(invoiceId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
invoiceId String The id of the invoice to publish.
body PublishInvoiceRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

PublishInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

searchInvoices

Note: This endpoint is in beta.

SearchInvoicesResponse searchInvoices(body)

SearchInvoices

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 fetch the next set of invoices.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var body = SquareConnect.InvoicesApi.constructFromObject({}); // SearchInvoicesRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.searchInvoices(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body SearchInvoicesRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

SearchInvoicesResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateInvoice

Note: This endpoint is in beta.

UpdateInvoiceResponse updateInvoice(invoiceId, body)

UpdateInvoice

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.InvoicesApi();

var invoiceId = SquareConnect.InvoicesApi.constructFromObject({}); // String | The ID of the invoice to update.

var body = SquareConnect.InvoicesApi.constructFromObject({}); // UpdateInvoiceRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.updateInvoice(invoiceId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
invoiceId String The ID of the invoice to update.
body UpdateInvoiceRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateInvoiceResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json