Reverse a card sale or a pre-authorization
If a customer requests a refund and the payment is still in an open batch, the merchant can use their POS to look up the card payment and cancel the transaction.
To find the paymentId
of the card payment that the merchant wants to reverse, they can retrieve a list of all the card payments that meet the search criteria that the merchant provides. They can then find the transaction that they want in the list of returned results.
Note: If the merchant runs a referenced refund on a bank transfer payment that is in an open batch, our gateway automatically reverses the payment.
Integration steps
Step 1. (Optional) List card payments.
Step 2. Reverse a card payment.
Before you begin
Bearer tokens
Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps:
- Include your API key in the x-api-key parameter in the header of a POST request.
- Send your request to https://identity.payroc.com/authorize.
Note: You need to generate a new Bearer token before the previous Bearer token expires.
Example request
Example response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
Headers
To create the header of each POST request, you must include the following parameters:
- Content-Type: Include application/json as the value for this parameter.
- Authorization: Include your Bearer token in this parameter.
- Idempotency-Key: Include a UUID v4 to make the request idempotent.
Errors
If your request is unsuccessful, we return an error. For more information about errors, see Errors.
Step 1 (Optional) List payments
To retrieve a list of card payments, send a GET request to our Payments endpoint.
Use our filters to narrow down the search results.
Request parameters
To create the body of your request, use the following parameters:
Query parameters
Example request
Response fields
If your request is successful, we retrieve the card payment information and return a response. The response contains the following fields:
Response
Example response
Step 2. Reverse a payment
To reverse a card payment, send a POST request to our Reverse endpoint.
If the merchant wants to reverse only part of the transaction, send the amount that they want to reverse in the amount parameter.
Request parameters
To create the body of your request, use the following parameters:
Request
Example request
Response fields
If your request is successful, we reverse the card payment and return a response. The response contains the following fields:
Response
Example response
Test cases
Before you run test cases, read the Payments page in Test Your Integration.
Reverse a card payment
Send a POST request to the following endpoint:
POST https://api.uat.payroc.com/v1/payments/{paymentId}/reverse
Note: The previous payment must be in the open batch and not settled.
Example response