$refundsApi = $client->getRefundsApi();
RefundsApi
Retrieves a list of refunds for the account making the request.
Max results per page: 100
function listPaymentRefunds(
?string $beginTime = null,
?string $endTime = null,
?string $sortOrder = null,
?string $cursor = null,
?string $locationId = null,
?string $status = null,
?string $sourceType = null
): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
beginTime |
?string |
Query, Optional | Timestamp for the beginning of the requested reporting period, in RFC 3339 format. Default: The current time minus one year. |
endTime |
?string |
Query, Optional | Timestamp for the end of the requested reporting period, in RFC 3339 format. Default: The current time. |
sortOrder |
?string |
Query, Optional | The order in which results are listed. - ASC - oldest to newest- DESC - newest to oldest (default). |
cursor |
?string |
Query, Optional | 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. |
locationId |
?string |
Query, Optional | Limit results to the location supplied. By default, results are returned for all locations associated with the merchant. |
status |
?string |
Query, Optional | 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. |
sourceType |
?string |
Query, Optional | If provided, only refunds with the given source type are returned. - CARD - List refunds only for payments where card was specified as paymentsource. Default: If omitted refunds are returned regardless of source type. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type ListPaymentRefundsResponse
.
$beginTime = 'begin_time2';
$endTime = 'end_time2';
$sortOrder = 'sort_order0';
$cursor = 'cursor6';
$locationId = 'location_id4';
$status = 'status8';
$sourceType = 'source_type0';
$apiResponse = $refundsApi->listPaymentRefunds($beginTime, $endTime, $sortOrder, $cursor, $locationId, $status, $sourceType);
if ($apiResponse->isSuccess()) {
$listPaymentRefundsResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();
Refunds a payment. You can refund the entire payment amount or a portion of it. For more information, see Payments and Refunds Overview.
function refundPayment(RefundPaymentRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
RefundPaymentRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type RefundPaymentResponse
.
$body_idempotencyKey = 'a7e36d40-d24b-11e8-b568-0800200c9a66';
$body_amountMoney = new Models\Money;
$body_amountMoney->setAmount(100);
$body_amountMoney->setCurrency(Models\Currency::USD);
$body_paymentId = 'UNOE3kv2BZwqHlJ830RCt5YCuaB';
$body = new Models\RefundPaymentRequest(
$body_idempotencyKey,
$body_amountMoney,
$body_paymentId
);
$body->setAppFeeMoney(new Models\Money);
$body->getAppFeeMoney()->setAmount(114);
$body->getAppFeeMoney()->setCurrency(Models\Currency::GEL);
$body->setReason('reason8');
$apiResponse = $refundsApi->refundPayment($body);
if ($apiResponse->isSuccess()) {
$refundPaymentResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();
Retrieves a specific Refund
using the refund_id
.
function getPaymentRefund(string $refundId): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
refundId |
string |
Template, Required | Unique ID for the desired PaymentRefund . |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type GetPaymentRefundResponse
.
$refundId = 'refund_id4';
$apiResponse = $refundsApi->getPaymentRefund($refundId);
if ($apiResponse->isSuccess()) {
$getPaymentRefundResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();