RefundsApi

November 20, 2019 ยท View on GitHub

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

MethodHTTP requestDescription
getPaymentRefundGET /v2/refunds/{refund_id}GetPaymentRefund
listPaymentRefundsGET /v2/refundsListPaymentRefunds
refundPaymentPOST /v2/refundsRefundPayment

getPaymentRefund

GetPaymentRefundResponse getPaymentRefund(refundId)

GetPaymentRefund

Retrieves a specific `Refund` using the `refund_id`.

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.RefundsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

RefundsApi apiInstance = new RefundsApi();
String refundId = "refundId_example"; // String | Unique ID for the desired `PaymentRefund`.
try {
    GetPaymentRefundResponse result = apiInstance.getPaymentRefund(refundId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling RefundsApi#getPaymentRefund");
    e.printStackTrace();
}

Parameters

NameTypeDescriptionNotes
refundIdStringUnique ID for the desired `PaymentRefund`.

Return type

GetPaymentRefundResponse

Authorization

oauth2

HTTP request headers

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

listPaymentRefunds

ListPaymentRefundsResponse listPaymentRefunds(beginTime, endTime, sortOrder, cursor, locationId, status, sourceType)

ListPaymentRefunds

Retrieves a list of refunds for 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.RefundsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

RefundsApi apiInstance = new RefundsApi();
String beginTime = "beginTime_example"; // String | Timestamp for the beginning of the requested reporting period, in RFC 3339 format.  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.
String status = "status_example"; // String | If provided, only refunds with the given status are returned. For a list of refund status values, see `PaymentRefund`.  Default: If omitted refunds are returned regardless of status.
String sourceType = "sourceType_example"; // String | If provided, only refunds with the given source type are returned. - `CARD` - List refunds only for payments where card was specified as payment source.  Default: If omitted refunds are returned regardless of source type.
try {
    ListPaymentRefundsResponse result = apiInstance.listPaymentRefunds(beginTime, endTime, sortOrder, cursor, locationId, status, sourceType);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling RefundsApi#listPaymentRefunds");
    e.printStackTrace();
}

Parameters

NameTypeDescriptionNotes
beginTimeStringTimestamp for the beginning of the requested reporting period, in RFC 3339 format. Default: The current time minus one year.[optional]
endTimeStringTimestamp for the end of the requested reporting period, in RFC 3339 format. Default: The current time.[optional]
sortOrderStringThe order in which results are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest (default).[optional]
cursorStringA 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]
locationIdStringID of location associated with payment.[optional]
statusStringIf provided, only refunds with the given status are returned. For a list of refund status values, see `PaymentRefund`. Default: If omitted refunds are returned regardless of status.[optional]
sourceTypeStringIf provided, only refunds with the given source type are returned. - `CARD` - List refunds only for payments where card was specified as payment source. Default: If omitted refunds are returned regardless of source type.[optional]

Return type

ListPaymentRefundsResponse

Authorization

oauth2

HTTP request headers

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

refundPayment

RefundPaymentResponse refundPayment(body)

RefundPayment

Refunds a payment. You can refund the entire payment amount or a portion of it. For more information, see Payments and Refunds Overview.

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.RefundsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

RefundsApi apiInstance = new RefundsApi();
RefundPaymentRequest body = new RefundPaymentRequest(); // RefundPaymentRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    RefundPaymentResponse result = apiInstance.refundPayment(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling RefundsApi#refundPayment");
    e.printStackTrace();
}

Parameters

NameTypeDescriptionNotes
bodyRefundPaymentRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

RefundPaymentResponse

Authorization

oauth2

HTTP request headers

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