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

Latest commit

 

History

History
346 lines (252 loc) · 13.8 KB

PaymentsApi.md

File metadata and controls

346 lines (252 loc) · 13.8 KB

PaymentsApi

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

cancelPayment

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.

Example

// 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();
}

Parameters

Name Type Description Notes
paymentId String `payment_id` identifying the payment to be canceled.

Return type

CancelPaymentResponse

Authorization

oauth2

HTTP request headers

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

cancelPaymentByIdempotencyKey

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.

Example

// 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();
}

Parameters

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

Return type

CancelPaymentByIdempotencyKeyResponse

Authorization

oauth2

HTTP request headers

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

completePayment

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.

Example

// 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();
}

Parameters

Name Type Description Notes
paymentId String Unique ID identifying the payment to be completed.

Return type

CompletePaymentResponse

Authorization

oauth2

HTTP request headers

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

createPayment

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.

Example

// 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();
}

Parameters

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

Return type

CreatePaymentResponse

Authorization

oauth2

HTTP request headers

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

getPayment

GetPaymentResponse getPayment(paymentId)

GetPayment

Retrieves details for a specific Payment.

Example

// 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();
}

Parameters

Name Type Description Notes
paymentId String Unique ID for the desired `Payment`.

Return type

GetPaymentResponse

Authorization

oauth2

HTTP request headers

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

listPayments

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

Example

// 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();
}

Parameters

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]

Return type

ListPaymentsResponse

Authorization

oauth2

HTTP request headers

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