Skip to content
payrocdevelopers

Run unreferenced refunds

Submit an unreferenced refund instruction to a Payroc Cloud device by sending a POST request to the Devices endpoint, then poll for status and retrieve refund details.

An AI skill is available for this guide, get it on the Skills Marketplace (GitHub).

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:

  1. Submit a refund instruction to the device.
  2. View the status of the refund instruction.
  3. 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.

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/devices/{serialNumber}/refund-instructions
Productionhttps://api.payroc.com/v1/devices/{serialNumber}/refund-instructions

Request parameters

To create the body of your request, use the following parameters:

Schema (request.body)

Request body schema for POST /devices/{serialNumber}/refund-instructions

Example request

Request

POST https://api.payroc.com/v1/devices/{serialNumber}/refund-instructions

Refund instruction

curl
curl -X POST https://api.payroc.com/v1/devices/1850010868/refund-instructions \
     -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "processingTerminalId": "1234001",
  "order": {
    "orderId": "OrderRef6543",
    "description": "Refund for order OrderRef6543",
    "amount": 4999,
    "currency": "USD"
  },
  "operator": "Jane",
  "customizationOptions": {
    "entryMethod": "manualEntry"
  }
}'

Refund instruction

Python
import requests

url = "https://api.payroc.com/v1/devices/1850010868/refund-instructions"

payload = {
    "processingTerminalId": "1234001",
    "order": {
        "orderId": "OrderRef6543",
        "description": "Refund for order OrderRef6543",
        "amount": 4999,
        "currency": "USD"
    },
    "operator": "Jane",
    "customizationOptions": { "entryMethod": "manualEntry" }
}
headers = {
    "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())

Refund instruction

JavaScript
const url = 'https://api.payroc.com/v1/devices/1850010868/refund-instructions';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","description":"Refund for order OrderRef6543","amount":4999,"currency":"USD"},"operator":"Jane","customizationOptions":{"entryMethod":"manualEntry"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Refund instruction

go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.payroc.com/v1/devices/1850010868/refund-instructions"

	payload := strings.NewReader("{\n  \"processingTerminalId\": \"1234001\",\n  \"order\": {\n    \"orderId\": \"OrderRef6543\",\n    \"description\": \"Refund for order OrderRef6543\",\n    \"amount\": 4999,\n    \"currency\": \"USD\"\n  },\n  \"operator\": \"Jane\",\n  \"customizationOptions\": {\n    \"entryMethod\": \"manualEntry\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Refund instruction

ruby
require 'uri'
require 'net/http'

url = URI("https://api.payroc.com/v1/devices/1850010868/refund-instructions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"processingTerminalId\": \"1234001\",\n  \"order\": {\n    \"orderId\": \"OrderRef6543\",\n    \"description\": \"Refund for order OrderRef6543\",\n    \"amount\": 4999,\n    \"currency\": \"USD\"\n  },\n  \"operator\": \"Jane\",\n  \"customizationOptions\": {\n    \"entryMethod\": \"manualEntry\"\n  }\n}"

response = http.request(request)
puts response.read_body

Refund instruction

Java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.payroc.com/v1/devices/1850010868/refund-instructions")
  .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"processingTerminalId\": \"1234001\",\n  \"order\": {\n    \"orderId\": \"OrderRef6543\",\n    \"description\": \"Refund for order OrderRef6543\",\n    \"amount\": 4999,\n    \"currency\": \"USD\"\n  },\n  \"operator\": \"Jane\",\n  \"customizationOptions\": {\n    \"entryMethod\": \"manualEntry\"\n  }\n}")
  .asString();

Refund instruction

PHP
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.payroc.com/v1/devices/1850010868/refund-instructions', [
  'body' => '{
  "processingTerminalId": "1234001",
  "order": {
    "orderId": "OrderRef6543",
    "description": "Refund for order OrderRef6543",
    "amount": 4999,
    "currency": "USD"
  },
  "operator": "Jane",
  "customizationOptions": {
    "entryMethod": "manualEntry"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324',
  ],
]);

echo $response->getBody();

Refund instruction

C#
using RestSharp;

var client = new RestClient("https://api.payroc.com/v1/devices/1850010868/refund-instructions");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"processingTerminalId\": \"1234001\",\n  \"order\": {\n    \"orderId\": \"OrderRef6543\",\n    \"description\": \"Refund for order OrderRef6543\",\n    \"amount\": 4999,\n    \"currency\": \"USD\"\n  },\n  \"operator\": \"Jane\",\n  \"customizationOptions\": {\n    \"entryMethod\": \"manualEntry\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Refund instruction

swift
import Foundation

let headers = [
  "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "processingTerminalId": "1234001",
  "order": [
    "orderId": "OrderRef6543",
    "description": "Refund for order OrderRef6543",
    "amount": 4999,
    "currency": "USD"
  ],
  "operator": "Jane",
  "customizationOptions": ["entryMethod": "manualEntry"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/devices/1850010868/refund-instructions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

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.

Schema (response.body)

Response body schema for POST /devices/{serialNumber}/refund-instructions

Example response

Response (202)

JSON
{
  "status": "inProgress",
  "refundInstructionId": "a37439165d134678a9100ebba3b29597",
  "link": {
    "rel": "self",
    "method": "GET",
    "href": "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597"
  }
}

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.

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/refund-instructions/{refundInstructionId}
Productionhttps://api.payroc.com/v1/refund-instructions/{refundInstructionId}

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:

Schema (request.path)

Path parameters for GET /refund-instructions/{refundInstructionId}

Example request

Request

GET https://api.payroc.com/v1/refund-instructions/{refundInstructionId}

Refund instruction

curl
curl https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597 \
     -H "Authorization: Bearer <token>"

Refund instruction

Python
import requests

url = "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())

Refund instruction

JavaScript
const url = 'https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Refund instruction

go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Refund instruction

ruby
require 'uri'
require 'net/http'

url = URI("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Refund instruction

Java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597")
  .header("Authorization", "Bearer <token>")
  .asString();

Refund instruction

PHP
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();

Refund instruction

C#
using RestSharp;

var client = new RestClient("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);

Refund instruction

swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

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.

Schema (response.body)

Response body schema for GET /refund-instructions/{refundInstructionId}

Example response

Response (200)

JSON
{
  "status": "completed",
  "refundInstructionId": "a37439165d134678a9100ebba3b29597",
  "link": {
    "rel": "refund",
    "method": "GET",
    "href": "https://api.payroc.com/v1/refunds/CD3HN88U9F"
  }
}

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.

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/refunds/{refundId}
Productionhttps://api.payroc.com/v1/refunds/{refundId}

Request parameters

To create your request, use the following parameters:

Schema (request.path)

Path parameters for GET /refunds/{refundId}

Example request

Request

GET https://api.payroc.com/v1/refunds/{refundId}

Refund

curl
curl https://api.payroc.com/v1/refunds/CD3HN88U9F \
     -H "Authorization: Bearer <token>"

Refund

Python
import requests

url = "https://api.payroc.com/v1/refunds/CD3HN88U9F"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())

Refund

JavaScript
const url = 'https://api.payroc.com/v1/refunds/CD3HN88U9F';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Refund

go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.payroc.com/v1/refunds/CD3HN88U9F"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Refund

ruby
require 'uri'
require 'net/http'

url = URI("https://api.payroc.com/v1/refunds/CD3HN88U9F")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Refund

Java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.payroc.com/v1/refunds/CD3HN88U9F")
  .header("Authorization", "Bearer <token>")
  .asString();

Refund

PHP
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.payroc.com/v1/refunds/CD3HN88U9F', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();

Refund

C#
using RestSharp;

var client = new RestClient("https://api.payroc.com/v1/refunds/CD3HN88U9F");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);

Refund

swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/refunds/CD3HN88U9F")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

Response fields

If your request is successful, we return the details of the refund.

Schema (response.body)

Response body schema for GET /refunds/{refundId}

Example response

Response (200)

JSON
{
  "refundId": "CD3HN88U9F",
  "processingTerminalId": "1234001",
  "order": {
    "orderId": "OrderRef6543",
    "description": "Refund for order OrderRef6543",
    "amount": 4999,
    "currency": "USD",
    "dateTime": "2024-07-02T15:30:00Z"
  },
  "card": {
    "type": "Visa Credit",
    "cardNumber": "453985******7062",
    "expiryDate": "1230",
    "entryMethod": "keyed"
  },
  "transactionResult": {
    "status": "ready",
    "responseCode": "A",
    "type": "refund",
    "approvalCode": "000000",
    "authorizedAmount": -4999,
    "currency": "USD",
    "responseMessage": "OK5"
  },
  "customFields": [
    {
      "name": "yourCustomField",
      "value": "abc123"
    }
  ]
}

(Optional) Cancel a refund instruction

To cancel a refund instruction, send a DELETE request to the Refund Instructions endpoint.

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/refund-instructions/{refundInstructionId}
Productionhttps://api.payroc.com/v1/refund-instructions/{refundInstructionId}

Note: You can cancel a refund instruction only if its status is inProgress.

Request parameters

To create your request, use the following parameters:

Schema (request.path)

Path parameters for DELETE /refund-instructions/{refundInstructionId}

Example request

Schema

Operation schema for DELETE /refund-instructions/{refundInstructionId}

Response

If your request is successful, we cancel the refund instruction.

Browse guides

Search documentation

API reference169
Guides118
Knowledge38
legal1
Solutions32
Workflows74
↑↓highlight↵openView all search results

Menu

Theme

Sign out

Your saved plans remain in your organization. This browser’s private draft and account view will be cleared.

Talk to an engineer