All URIs are relative to https://connect.squareup.com
Method | HTTP request | Description |
---|---|---|
cancelPayment | POST /v2/payments/{payment_id}/cancel | CancelPayment |
cancelPaymentByIdempotencyKey | POST /v2/payments/cancel | CancelPaymentByIdempotencyKey |
completePayment | POST /v2/payments/{payment_id}/complete | CompletePayment |
createPayment | POST /v2/payments | CreatePayment |
getPayment | GET /v2/payments/{payment_id} | GetPayment |
listPayments | GET /v2/payments | ListPayments |
CancelPaymentResponse cancelPayment(paymentId)
CancelPayment
Cancels (voids) a payment. If you set `autocomplete` to false when creating a payment, you can cancel the payment using this endpoint. For more information, see Delayed Payments.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
String paymentId = "paymentId_example"; // String | `payment_id` identifying the payment to be canceled.
try {
CancelPaymentResponse result = apiInstance.cancelPayment(paymentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#cancelPayment");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
paymentId | String | `payment_id` identifying the payment to be canceled. |
- Content-Type: application/json
- Accept: application/json
CancelPaymentByIdempotencyKeyResponse cancelPaymentByIdempotencyKey(body)
CancelPaymentByIdempotencyKey
Cancels (voids) a payment identified by the idempotency key that is specified in the request. Use this method when status of a CreatePayment request is unknown. For example, after you send a CreatePayment request a network error occurs and you don't get a response. In this case, you can direct Square to cancel the payment using this endpoint. In the request, you provide the same idempotency key that you provided in your CreatePayment request you want to cancel. After cancelling the payment, you can submit your CreatePayment request again. Note that if no payment with the specified idempotency key is found, no action is taken, the end point returns successfully.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
CancelPaymentByIdempotencyKeyRequest body = new CancelPaymentByIdempotencyKeyRequest(); // CancelPaymentByIdempotencyKeyRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
CancelPaymentByIdempotencyKeyResponse result = apiInstance.cancelPaymentByIdempotencyKey(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#cancelPaymentByIdempotencyKey");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | CancelPaymentByIdempotencyKeyRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
CancelPaymentByIdempotencyKeyResponse
- Content-Type: application/json
- Accept: application/json
CompletePaymentResponse completePayment(paymentId)
CompletePayment
Completes (captures) a payment. By default, payments are set to complete immediately after they are created. If you set autocomplete to false when creating a payment, you can complete (capture) the payment using this endpoint. For more information, see Delayed Payments.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
String paymentId = "paymentId_example"; // String | Unique ID identifying the payment to be completed.
try {
CompletePaymentResponse result = apiInstance.completePayment(paymentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#completePayment");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
paymentId | String | Unique ID identifying the payment to be completed. |
- Content-Type: application/json
- Accept: application/json
CreatePaymentResponse createPayment(body)
CreatePayment
Charges a payment source, for example, a card represented by customer's card on file or a card nonce. In addition to the payment source, the request must also include the amount to accept for the payment. There are several optional parameters that you can include in the request. For example, tip money, whether to autocomplete the payment, or a reference ID to correlate this payment with another system. For more information about these payment options, see Take Payments. The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required to enable application fees.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
CreatePaymentRequest body = new CreatePaymentRequest(); // CreatePaymentRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
CreatePaymentResponse result = apiInstance.createPayment(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#createPayment");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | CreatePaymentRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
GetPaymentResponse getPayment(paymentId)
GetPayment
Retrieves details for a specific Payment.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
String paymentId = "paymentId_example"; // String | Unique ID for the desired `Payment`.
try {
GetPaymentResponse result = apiInstance.getPayment(paymentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#getPayment");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
paymentId | String | Unique ID for the desired `Payment`. |
- Content-Type: application/json
- Accept: application/json
ListPaymentsResponse listPayments(beginTime, endTime, sortOrder, cursor, locationId, total, last4, cardBrand)
ListPayments
Retrieves a list of payments taken by the account making the request. Max results per page: 100
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.PaymentsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
PaymentsApi apiInstance = new PaymentsApi();
String beginTime = "beginTime_example"; // String | Timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year.
String endTime = "endTime_example"; // String | Timestamp for the end of the requested reporting period, in RFC 3339 format. Default: The current time.
String sortOrder = "sortOrder_example"; // String | The order in which results are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest (default).
String cursor = "cursor_example"; // String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See [Pagination](https://developer.squareup.com/docs/basics/api101/pagination) for more information.
String locationId = "locationId_example"; // String | ID of location associated with payment
Long total = 789L; // Long | The exact amount in the total_money for a `Payment`.
String last4 = "last4_example"; // String | The last 4 digits of `Payment` card.
String cardBrand = "cardBrand_example"; // String | The brand of `Payment` card. For example, `VISA`
try {
ListPaymentsResponse result = apiInstance.listPayments(beginTime, endTime, sortOrder, cursor, locationId, total, last4, cardBrand);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentsApi#listPayments");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
beginTime | String | Timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year. | [optional] |
endTime | String | Timestamp for the end of the requested reporting period, in RFC 3339 format. Default: The current time. | [optional] |
sortOrder | String | The order in which results are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest (default). | [optional] |
cursor | String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See Pagination for more information. | [optional] |
locationId | String | ID of location associated with payment | [optional] |
total | Long | The exact amount in the total_money for a `Payment`. | [optional] |
last4 | String | The last 4 digits of `Payment` card. | [optional] |
cardBrand | String | The brand of `Payment` card. For example, `VISA` | [optional] |
- Content-Type: application/json
- Accept: application/json