After you configure a device for Payroc Cloud, program your POS to use the Submit Refund Instruction method to send a refund instruction to the payment device.
To return funds to a cardholder, complete the following:
- Submit a refund instruction to the device.
- View the status of the refund instruction.
- View the details of the refund instruction.
You can also cancel a refund instruction if it hasn’t yet completed.
Before you begin
Authenticate your requests before making API calls. If your request fails, see Errors.
Step 1. Submit a refund instruction
To submit a refund instruction to a device, send a POST request to the Devices endpoint.
Request parameters
To create the body of your request, use the following parameters:
Request
processingTerminalIdstringRequired4-50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the refund.
operatorstringOptional0-50 characters
Operator who initiated the request.
customerobjectOptional
Object that contains the customer's contact details and address information.
Contains parameters required for [Level 2, Level 3, and CEDP transactions](https://docs.payroc.com/knowledge/card-payments/enhanced-data).
ipAddressobjectOptional
Object that contains the IP address of the device that sent the request.
customizationOptionsobjectOptional
Object that contains available options to customize certain aspects of an instruction.
Example request
POST/v1/devices/:serialNumber/refund-instructions
Response fields
If your request is successful, we send the refund instruction to the device.
Note: The response returns a value of inProgress for the status field and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the refund, go to Step 2.
Response
statusenumRequired
Indicates the current status of the instruction.
- `canceled` – The instruction was canceled before it was completed.
- `completed` – The instruction has completed. Use the link object to check the resource.
- `failure` – The instruction failed. Check the errorMessage field for more information.
- `inProgress` – The instruction is currently in progress.
refundInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the refund instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail.
**Note:** We return this field only if the status is `failure`.
linkobjectOptionalRead-only
Object that contains HATEOAS links for the resource.
Example response
Step 2. View the status of a refund instruction
To check for updates to the status of the refund instruction, send a GET request to the Refund Instructions endpoint.
Before our gateway sends a response, it waits for up to a minute for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out.
If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to a minute for the status of the instruction to change. Continue to send GET requests until the status changes.
Note: Wait until you receive a response from our gateway before you send another request.
Request parameters
To create your request, use the following parameters:
Path parameters
refundInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the refund instruction.
Example request
GET/v1/refund-instructions/:refundInstructionId
Response fields
If your request is successful, we return the details of the refund instruction, including HATEOAS links to check the details of the refund. Use the HATEOAS links to get the refundId, which you need in Step 3.
If the status of the refund instruction is inProgress, our gateway waits up to a minute for the status to change before it returns a response.
Response
statusenumRequired
Indicates the current status of the instruction.
- `canceled` – The instruction was canceled before it was completed.
- `completed` – The instruction has completed. Use the link object to check the resource.
- `failure` – The instruction failed. Check the errorMessage field for more information.
- `inProgress` – The instruction is currently in progress.
refundInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the refund instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail.
**Note:** We return this field only if the status is `failure`.
linkobjectOptionalRead-only
Object that contains HATEOAS links for the resource.
Example response
Step 3. View the details of the refund
To check whether the processor approved or declined the refund, send a GET request to the Refunds endpoint.
Request parameters
To create your request, use the following parameters:
Path parameters
refundIdstringRequired=10 characters
Unique identifier that our gateway assigned to the refund.
Example request
Response fields
If your request is successful, we return the details of the refund.
Response
refundIdstringRequired=10 characters
Unique identifier that our gateway assigned to the refund.
processingTerminalIdstringRequired4-50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the refund.
cardobjectRequired
Object that contains the details of the payment card.
transactionResultobjectRequired
Object that contains information about the transaction response details.
operatorstringOptional0-50 characters
Operator who requested the refund.
customerobjectOptional
Object that contains the customer's contact details and address information.
paymentobjectOptional
Object that contains information about the payment that the refund is linked to.
**Note:** We don't return this object for unreferenced refunds.
supportedOperationslist of enumsOptional
Array of operations that you can perform on the transaction. Our gateway can return any of the following values:
- `capture` - [Capture the payment](https://docs.payroc.com/api/schema/card-payments/payments/capture).
- `refund` - [Refund the payment](https://docs.payroc.com/api/schema/card-payments/refunds/create-referenced-refund).
- `fullyReverse` - [Fully reverse the transaction](https://docs.payroc.com/api/schema/card-payments/refunds/reverse).
- `partiallyReverse` - [Partially reverse the payment](https://docs.payroc.com/api/schema/card-payments/refunds/reverse).
- `incrementAuthorization` - [Increase the amount of the authorization](https://docs.payroc.com/api/schema/card-payments/payments/adjust).
- `adjustTip` - [Adjust the tip post-payment](https://docs.payroc.com/api/schema/card-payments/payments/adjust).
- `addSignature` - [Add a signature to the payment](https://docs.payroc.com/api/schema/card-payments/payments/adjust).
- `setAsReady` - [Set the transaction’s status to `ready`](https://docs.payroc.com/api/schema/card-payments/payments/adjust).
- `setAsPending` - [Set the transaction’s status to `pending`](https://docs.payroc.com/api/schema/card-payments/payments/adjust).
customFieldslist of objectsOptional
Array of customField objects.
Example response
(Optional) Cancel a refund instruction
To cancel a refund instruction, send a DELETE request to the Refund Instructions endpoint.
Note: You can cancel a refund instruction only if its status is inProgress.
Request parameters
To create your request, use the following parameters:
Path parameters
refundInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the refund instruction.
Example request
Path parameters
refundInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the refund instruction.
Response
If your request is successful, we cancel the refund instruction.