If you have feedback about the new SDKs, or just want to talk to other Square Developers, request an invite to the new slack community for Square Developers
This repository contains the released C# client SDK. Check out our API specification repository for the specification and template files we used to generate this.
- .NET 4.5 or later
Obtain from NuGet package manager (Recommended)
PM> Install-Package Square.Connect
- [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742
The DLLs included in the package may not be the latest version. We recommned using NuGet to obtain the latest version of the packages:
PM> Install-Package RestSharp
PM> Install-Package Newtonsoft.Json
Option 1: Run the following command to generate the DLL
- [Mac/Linux]
/bin/sh build.sh
- [Windows]
build.bat
Option 2: Import the Square.Connect/Square.Connect.csproj
to your solution and build from VS
Then include the DLLs (under the bin
folder) in the C# project,
- RestSharp.dll
- Newtonsoft.Json.dll
- Square.Connect.dll
Use the namespaces:
using Square.Connect.Api;
using Square.Connect.Client;
using Square.Connect.Model;
using System;
using System.Diagnostics;
using Square.Connect.Api;
using Square.Connect.Client;
using Square.Connect.Model;
namespace Example
{
public class Example
{
public Example()
{
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
}
// Retrieving your location IDs
public void RetrieveLocations()
{
LocationsApi _locationsApi = new LocationsApi();
var response = _locationsApi.ListLocations();
}
// Charge the card nonce
public void ChargeNonce()
{
// Every payment you process for a given business have a unique idempotency key.
// If you're unsure whether a particular payment succeeded, you can reattempt
// it with the same idempotency key without worrying about double charging
// the buyer.
string idempotencyKey = Guid.NewGuid().ToString();
// Monetary amounts are specified in the smallest unit of the applicable currency.
// This amount is in cents. It's also hard-coded for $1, which is not very useful.
int amount = 100;
string currency = "USD";
Money money = new Money(amount, Money.ToCurrencyEnum(currency));
string nonce = "YOUR_NONCE";
string locationId = "YOUR_LOCATION_ID";
ChargeRequest body = new ChargeRequest(AmountMoney: money, IdempotencyKey: idempotencyKey, CardNonce: nonce);
TransactionsApi transactionsApi = new TransactionsApi();
var response = transactionsApi.Charge(locationId, body);
}
}
}
More examples are available at connect-api-examples
All URIs are relative to Square Connect Documentation
Class | Method | HTTP request |
---|---|---|
ApplePayApi | RegisterDomain | POST /v2/apple-pay/domains |
CatalogApi | BatchDeleteCatalogObjects | POST /v2/catalog/batch-delete |
CatalogApi | BatchRetrieveCatalogObjects | POST /v2/catalog/batch-retrieve |
CatalogApi | BatchUpsertCatalogObjects | POST /v2/catalog/batch-upsert |
CatalogApi | CatalogInfo | GET /v2/catalog/info |
CatalogApi | DeleteCatalogObject | DELETE /v2/catalog/object/{object_id} |
CatalogApi | ListCatalog | GET /v2/catalog/list |
CatalogApi | RetrieveCatalogObject | GET /v2/catalog/object/{object_id} |
CatalogApi | SearchCatalogObjects | POST /v2/catalog/search |
CatalogApi | UpdateItemModifierLists | POST /v2/catalog/update-item-modifier-lists |
CatalogApi | UpdateItemTaxes | POST /v2/catalog/update-item-taxes |
CatalogApi | UpsertCatalogObject | POST /v2/catalog/object |
CheckoutApi | CreateCheckout | POST /v2/locations/{location_id}/checkouts |
CustomersApi | CreateCustomer | POST /v2/customers |
CustomersApi | CreateCustomerCard | POST /v2/customers/{customer_id}/cards |
CustomersApi | DeleteCustomer | DELETE /v2/customers/{customer_id} |
CustomersApi | DeleteCustomerCard | DELETE /v2/customers/{customer_id}/cards/{card_id} |
CustomersApi | ListCustomers | GET /v2/customers |
CustomersApi | RetrieveCustomer | GET /v2/customers/{customer_id} |
CustomersApi | UpdateCustomer | PUT /v2/customers/{customer_id} |
LocationsApi | ListLocations | GET /v2/locations |
OrdersApi | BatchRetrieveOrders | POST /v2/locations/{location_id}/orders/batch-retrieve |
OrdersApi | CreateOrder | POST /v2/locations/{location_id}/orders |
ReportingApi | ListAdditionalRecipientReceivableRefunds | GET /v2/locations/{location_id}/additional-recipient-receivable-refunds |
ReportingApi | ListAdditionalRecipientReceivables | GET /v2/locations/{location_id}/additional-recipient-receivables |
TransactionsApi | CaptureTransaction | POST /v2/locations/{location_id}/transactions/{transaction_id}/capture |
TransactionsApi | Charge | POST /v2/locations/{location_id}/transactions |
TransactionsApi | CreateRefund | POST /v2/locations/{location_id}/transactions/{transaction_id}/refund |
TransactionsApi | ListRefunds | GET /v2/locations/{location_id}/refunds |
TransactionsApi | ListTransactions | GET /v2/locations/{location_id}/transactions |
TransactionsApi | RetrieveTransaction | GET /v2/locations/{location_id}/transactions/{transaction_id} |
TransactionsApi | VoidTransaction | POST /v2/locations/{location_id}/transactions/{transaction_id}/void |
V1EmployeesApi | CreateEmployee | POST /v1/me/employees |
V1EmployeesApi | CreateEmployeeRole | POST /v1/me/roles |
V1EmployeesApi | CreateTimecard | POST /v1/me/timecards |
V1EmployeesApi | DeleteTimecard | DELETE /v1/me/timecards/{timecard_id} |
V1EmployeesApi | ListCashDrawerShifts | GET /v1/{location_id}/cash-drawer-shifts |
V1EmployeesApi | ListEmployeeRoles | GET /v1/me/roles |
V1EmployeesApi | ListEmployees | GET /v1/me/employees |
V1EmployeesApi | ListTimecardEvents | GET /v1/me/timecards/{timecard_id}/events |
V1EmployeesApi | ListTimecards | GET /v1/me/timecards |
V1EmployeesApi | RetrieveCashDrawerShift | GET /v1/{location_id}/cash-drawer-shifts/{shift_id} |
V1EmployeesApi | RetrieveEmployee | GET /v1/me/employees/{employee_id} |
V1EmployeesApi | RetrieveEmployeeRole | GET /v1/me/roles/{role_id} |
V1EmployeesApi | RetrieveTimecard | GET /v1/me/timecards/{timecard_id} |
V1EmployeesApi | UpdateEmployee | PUT /v1/me/employees/{employee_id} |
V1EmployeesApi | UpdateEmployeeRole | PUT /v1/me/roles/{role_id} |
V1EmployeesApi | UpdateTimecard | PUT /v1/me/timecards/{timecard_id} |
V1ItemsApi | AdjustInventory | POST /v1/{location_id}/inventory/{variation_id} |
V1ItemsApi | ApplyFee | PUT /v1/{location_id}/items/{item_id}/fees/{fee_id} |
V1ItemsApi | ApplyModifierList | PUT /v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id} |
V1ItemsApi | CreateCategory | POST /v1/{location_id}/categories |
V1ItemsApi | CreateDiscount | POST /v1/{location_id}/discounts |
V1ItemsApi | CreateFee | POST /v1/{location_id}/fees |
V1ItemsApi | CreateItem | POST /v1/{location_id}/items |
V1ItemsApi | CreateModifierList | POST /v1/{location_id}/modifier-lists |
V1ItemsApi | CreateModifierOption | POST /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options |
V1ItemsApi | CreatePage | POST /v1/{location_id}/pages |
V1ItemsApi | CreateVariation | POST /v1/{location_id}/items/{item_id}/variations |
V1ItemsApi | DeleteCategory | DELETE /v1/{location_id}/categories/{category_id} |
V1ItemsApi | DeleteDiscount | DELETE /v1/{location_id}/discounts/{discount_id} |
V1ItemsApi | DeleteFee | DELETE /v1/{location_id}/fees/{fee_id} |
V1ItemsApi | DeleteItem | DELETE /v1/{location_id}/items/{item_id} |
V1ItemsApi | DeleteModifierList | DELETE /v1/{location_id}/modifier-lists/{modifier_list_id} |
V1ItemsApi | DeleteModifierOption | DELETE /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id} |
V1ItemsApi | DeletePage | DELETE /v1/{location_id}/pages/{page_id} |
V1ItemsApi | DeletePageCell | DELETE /v1/{location_id}/pages/{page_id}/cells |
V1ItemsApi | DeleteVariation | DELETE /v1/{location_id}/items/{item_id}/variations/{variation_id} |
V1ItemsApi | ListCategories | GET /v1/{location_id}/categories |
V1ItemsApi | ListDiscounts | GET /v1/{location_id}/discounts |
V1ItemsApi | ListFees | GET /v1/{location_id}/fees |
V1ItemsApi | ListInventory | GET /v1/{location_id}/inventory |
V1ItemsApi | ListItems | GET /v1/{location_id}/items |
V1ItemsApi | ListModifierLists | GET /v1/{location_id}/modifier-lists |
V1ItemsApi | ListPages | GET /v1/{location_id}/pages |
V1ItemsApi | RemoveFee | DELETE /v1/{location_id}/items/{item_id}/fees/{fee_id} |
V1ItemsApi | RemoveModifierList | DELETE /v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id} |
V1ItemsApi | RetrieveItem | GET /v1/{location_id}/items/{item_id} |
V1ItemsApi | RetrieveModifierList | GET /v1/{location_id}/modifier-lists/{modifier_list_id} |
V1ItemsApi | UpdateCategory | PUT /v1/{location_id}/categories/{category_id} |
V1ItemsApi | UpdateDiscount | PUT /v1/{location_id}/discounts/{discount_id} |
V1ItemsApi | UpdateFee | PUT /v1/{location_id}/fees/{fee_id} |
V1ItemsApi | UpdateItem | PUT /v1/{location_id}/items/{item_id} |
V1ItemsApi | UpdateModifierList | PUT /v1/{location_id}/modifier-lists/{modifier_list_id} |
V1ItemsApi | UpdateModifierOption | PUT /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id} |
V1ItemsApi | UpdatePage | PUT /v1/{location_id}/pages/{page_id} |
V1ItemsApi | UpdatePageCell | PUT /v1/{location_id}/pages/{page_id}/cells |
V1ItemsApi | UpdateVariation | PUT /v1/{location_id}/items/{item_id}/variations/{variation_id} |
V1LocationsApi | ListLocations | GET /v1/me/locations |
V1LocationsApi | RetrieveBusiness | GET /v1/me |
V1TransactionsApi | CreateRefund | POST /v1/{location_id}/refunds |
V1TransactionsApi | ListBankAccounts | GET /v1/{location_id}/bank-accounts |
V1TransactionsApi | ListOrders | GET /v1/{location_id}/orders |
V1TransactionsApi | ListPayments | GET /v1/{location_id}/payments |
V1TransactionsApi | ListRefunds | GET /v1/{location_id}/refunds |
V1TransactionsApi | ListSettlements | GET /v1/{location_id}/settlements |
V1TransactionsApi | RetrieveBankAccount | GET /v1/{location_id}/bank-accounts/{bank_account_id} |
V1TransactionsApi | RetrieveOrder | GET /v1/{location_id}/orders/{order_id} |
V1TransactionsApi | RetrievePayment | GET /v1/{location_id}/payments/{payment_id} |
V1TransactionsApi | RetrieveSettlement | GET /v1/{location_id}/settlements/{settlement_id} |
V1TransactionsApi | UpdateOrder | PUT /v1/{location_id}/orders/{order_id} |
- Model.AdditionalRecipient
- Model.AdditionalRecipientReceivable
- Model.AdditionalRecipientReceivableRefund
- Model.Address
- Model.BatchDeleteCatalogObjectsRequest
- Model.BatchDeleteCatalogObjectsResponse
- Model.BatchRetrieveCatalogObjectsRequest
- Model.BatchRetrieveCatalogObjectsResponse
- Model.BatchRetrieveOrdersRequest
- Model.BatchRetrieveOrdersResponse
- Model.BatchUpsertCatalogObjectsRequest
- Model.BatchUpsertCatalogObjectsResponse
- Model.CaptureTransactionRequest
- Model.CaptureTransactionResponse
- Model.Card
- Model.CatalogCategory
- Model.CatalogDiscount
- Model.CatalogIdMapping
- Model.CatalogInfoRequest
- Model.CatalogInfoResponse
- Model.CatalogInfoResponseLimits
- Model.CatalogItem
- Model.CatalogItemModifierListInfo
- Model.CatalogItemVariation
- Model.CatalogModifier
- Model.CatalogModifierList
- Model.CatalogModifierOverride
- Model.CatalogObject
- Model.CatalogObjectBatch
- Model.CatalogQuery
- Model.CatalogQueryExact
- Model.CatalogQueryItemsForModifierList
- Model.CatalogQueryItemsForTax
- Model.CatalogQueryPrefix
- Model.CatalogQueryRange
- Model.CatalogQuerySortedAttribute
- Model.CatalogQueryText
- Model.CatalogTax
- Model.CatalogV1Id
- Model.ChargeRequest
- Model.ChargeRequestAdditionalRecipient
- Model.ChargeResponse
- Model.Checkout
- Model.CreateCheckoutRequest
- Model.CreateCheckoutResponse
- Model.CreateCustomerCardRequest
- Model.CreateCustomerCardResponse
- Model.CreateCustomerRequest
- Model.CreateCustomerResponse
- Model.CreateOrderRequest
- Model.CreateOrderRequestDiscount
- Model.CreateOrderRequestLineItem
- Model.CreateOrderRequestModifier
- Model.CreateOrderRequestTax
- Model.CreateOrderResponse
- Model.CreateRefundRequest
- Model.CreateRefundResponse
- Model.Customer
- Model.CustomerGroupInfo
- Model.CustomerPreferences
- Model.DeleteCatalogObjectRequest
- Model.DeleteCatalogObjectResponse
- Model.DeleteCustomerCardRequest
- Model.DeleteCustomerCardResponse
- Model.DeleteCustomerRequest
- Model.DeleteCustomerResponse
- Model.Device
- Model.Error
- Model.ItemVariationLocationOverrides
- Model.ListAdditionalRecipientReceivableRefundsRequest
- Model.ListAdditionalRecipientReceivableRefundsResponse
- Model.ListAdditionalRecipientReceivablesRequest
- Model.ListAdditionalRecipientReceivablesResponse
- Model.ListCatalogRequest
- Model.ListCatalogResponse
- Model.ListCustomersRequest
- Model.ListCustomersResponse
- Model.ListLocationsRequest
- Model.ListLocationsResponse
- Model.ListRefundsRequest
- Model.ListRefundsResponse
- Model.ListTransactionsRequest
- Model.ListTransactionsResponse
- Model.Location
- Model.Money
- Model.Order
- Model.OrderLineItem
- Model.OrderLineItemDiscount
- Model.OrderLineItemModifier
- Model.OrderLineItemTax
- Model.Refund
- Model.RegisterDomainRequest
- Model.RegisterDomainResponse
- Model.RetrieveCatalogObjectRequest
- Model.RetrieveCatalogObjectResponse
- Model.RetrieveCustomerRequest
- Model.RetrieveCustomerResponse
- Model.RetrieveTransactionRequest
- Model.RetrieveTransactionResponse
- Model.SearchCatalogObjectsRequest
- Model.SearchCatalogObjectsResponse
- Model.Tender
- Model.TenderCardDetails
- Model.TenderCashDetails
- Model.Transaction
- Model.UpdateCustomerRequest
- Model.UpdateCustomerResponse
- Model.UpdateItemModifierListsRequest
- Model.UpdateItemModifierListsResponse
- Model.UpdateItemTaxesRequest
- Model.UpdateItemTaxesResponse
- Model.UpsertCatalogObjectRequest
- Model.UpsertCatalogObjectResponse
- Model.V1AdjustInventoryRequest
- Model.V1BankAccount
- Model.V1CashDrawerEvent
- Model.V1CashDrawerShift
- Model.V1Category
- Model.V1CreateRefundRequest
- Model.V1Discount
- Model.V1Employee
- Model.V1EmployeeRole
- Model.V1Fee
- Model.V1InventoryEntry
- Model.V1Item
- Model.V1ItemImage
- Model.V1Merchant
- Model.V1MerchantLocationDetails
- Model.V1ModifierList
- Model.V1ModifierOption
- Model.V1Money
- Model.V1Order
- Model.V1OrderHistoryEntry
- Model.V1Page
- Model.V1PageCell
- Model.V1Payment
- Model.V1PaymentDiscount
- Model.V1PaymentItemDetail
- Model.V1PaymentItemization
- Model.V1PaymentModifier
- Model.V1PaymentSurcharge
- Model.V1PaymentTax
- Model.V1PhoneNumber
- Model.V1Refund
- Model.V1Settlement
- Model.V1SettlementEntry
- Model.V1Tender
- Model.V1Timecard
- Model.V1TimecardEvent
- Model.V1UpdateModifierListRequest
- Model.V1UpdateOrderRequest
- Model.V1Variation
- Model.VoidTransactionRequest
- Model.VoidTransactionResponse
- Type: OAuth
- Flow: accessCode
- Authorization URL:
https://connect.squareup.com/oauth2/authorize
- Scopes:
- MERCHANT_PROFILE_READ: GET endpoints related to a merchant's business and location entities. Almost all Connect API applications need this permission in order to obtain a merchant's location IDs
- PAYMENTS_READ: GET endpoints related to transactions and refunds
- PAYMENTS_WRITE: POST, PUT, and DELETE endpoints related to transactions and refunds. E-commerce applications must request this permission
- CUSTOMERS_READ: GET endpoints related to customer management
- CUSTOMERS_WRITE: POST, PUT, and DELETE endpoints related to customer management
- SETTLEMENTS_READ: GET endpoints related to settlements (deposits)
- BANK_ACCOUNTS_READ: GET endpoints related to a merchant's bank accounts
- ITEMS_READ: GET endpoints related to a merchant's item library
- ITEMS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's item library
- ORDERS_READ: GET endpoints related to a merchant's orders
- ORDERS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's orders
- EMPLOYEES_READ: GET endpoints related to employee management
- EMPLOYEES_WRITE: POST, PUT, and DELETE endpoints related to employee management
- TIMECARDS_READ: GET endpoints related to employee timecards
- TIMECARDS_WRITE: POST, PUT, and DELETE endpoints related to employee timecards
- PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS: Allow third party applications to deduct a portion of each transaction amount.
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
V1 Endpoints return pagination information via HTTP headers. In order to obtain
response headers and extract the batch_token
parameter you will need to follow
the following steps:
-
Use the full information endpoint methods of each API to get the ApiResponse object. They are named as their simple counterpart with a
WithHttpInfo
suffix. HenceListEmployeeRoles
would be calledListEmployeeRolesWithHttpInfo
. This method returns anApiResponse<List<V1EmployeeRole>>
object. -
Use
string batchToken = response.BatchToken
to get the token and proceed to get the following page if a token is present.
using System;
using System.Diagnostics;
using Square.Connect.Api;
using Square.Connect.Client;
using Square.Connect.Model;
namespace Example
{
public class ListEmployeeRolesExample
{
public void main()
{
// Configure OAuth2 access token for authorization: oauth2
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new V1EmployeesApi();
var order = order_example; // string | The order in which employees are listed in the response, based on their created_at field.Default value: ASC (optional)
var limit = 56; // int? | The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. (optional)
string batchToken = null;
try
{
do {
// Provides summary information for all of a business's employee roles.
ApiResponse<List<V1EmployeeRole>> response = apiInstance.ListEmployeeRolesWithHttpInfo(order, limit, batchToken);
batchToken = response.BatchToken
Debug.WriteLine(response.Data);
} while (batchToken != null);
}
catch (Exception e)
{
Debug.Print("Exception when calling V1EmployeesApi.ListEmployeeRolesWithHttpInfo: " + e.Message );
}
}
}
}
Send bug reports, feature requests, and code contributions to the API specifications repository, as this repository contains only the generated SDK code.
Copyright 2017 Square, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.