Send a referenced refund to a bank account

A merchant can use the payment details of a card payment to run a referenced refund. To run a referenced refund, the merchant should first retrieve the payment information in one of the following ways:

  • Use the paymentId.
  • Search for the payment using payment information such as the bank account number.

Integration steps

Step 1. Retrieve information about the original payment.
(Optional) Step 1a. Retrieve information about the payment using the paymentId.
(Optional) Step 1b. Retrieve information about the payment without the paymentId.
Step 2. Refund the 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:

  1. Include your API key in the x-api-key parameter in the header of a POST request.
  2. 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

$curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: <api key>'

Example response

If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.

1{
2 "access_token": "eyJhbGc....adQssw5c",
3 "expires_in": 3600,
4 "scope": "service_a service_b",
5 "token_type": "Bearer"
6}

Headers

To create the header of each GET 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.
$curl
>-H "Content-Type: application/json"
>-H "Authorization: <Bearer token>"

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.
$curl
>-H "Content-Type: application/json"
>-H "Authorization: <Bearer token>"
>-H "Idempotency-Key: <UUID v4>"

Errors

If your request is unsuccessful, we return an error. For more information about errors, see Errors.

Step 1 - Retrieve the details of the payment

1a (Optional) – Retrieve the details of the payment with a paymentId

Send a GET request with the paymentID to our Bank Transfer Payments endpoint.

Request parameters

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

Example request

GET
/v1/bank-transfer-payments/:paymentId
1curl https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y \
2 -H "Authorization: Bearer <token>"

Response fields

If your request is successful, our gateway returns the details of the payment. The response contains the following fields:

Example response

Response
1{
2 "paymentId": "M2MJOG6O2Y",
3 "processingTerminalId": "1234001",
4 "order": {
5 "orderId": "OrderRef6543",
6 "amount": 4999,
7 "currency": "USD",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Large Pepperoni Pizza",
10 "breakdown": {
11 "subtotal": 4347,
12 "tip": {
13 "type": "percentage",
14 "amount": 435,
15 "percentage": 10
16 },
17 "taxes": [
18 {
19 "name": "Sales Tax",
20 "rate": 5,
21 "amount": 217
22 }
23 ]
24 }
25 },
26 "bankAccount": {
27 "type": "ach",
28 "secCode": "web",
29 "nameOnAccount": "Sarah Hazel Hopper",
30 "accountNumber": "****3159",
31 "routingNumber": "063100277",
32 "secureToken": {
33 "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
34 "customerName": "Sarah Hazel Hopper",
35 "token": "296753123456",
36 "status": "notValidated",
37 "link": {
38 "rel": "self",
39 "method": "GET",
40 "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"
41 }
42 },
43 "accountType": "checking"
44 },
45 "transactionResult": {
46 "type": "payment",
47 "status": "ready",
48 "responseMessage": "NoError",
49 "authorizedAmount": 4999,
50 "currency": "USD",
51 "responseCode": "A",
52 "processorResponseCode": "0"
53 },
54 "customer": {
55 "notificationLanguage": "en",
56 "contactMethods": [
57 {
58 "type": "email",
59 "value": "[email protected]"
60 }
61 ]
62 },
63 "customFields": [
64 {
65 "name": "yourCustomField",
66 "value": "abc123"
67 }
68 ]
69}

1b (Optional) – Retrieve the details of the payment without a paymentId

Send a GET request to our Bank Transfer Payments endpoint. To filter your results, use query parameters.

Request parameters

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

Example request

GET
/v1/bank-transfer-payments
1curl -G https://api.payroc.com/v1/bank-transfer-payments \
2 -H "Authorization: Bearer <token>" \
3 -d processingTerminalId=1234001 \
4 -d orderId=OrderRef6543 \
5 --data-urlencode nameOnAccount=Sarah%20Hazel%20Hopper \
6 -d last4=7890 \
7 -d type=payment \
8 -d status=ready \
9 --data-urlencode dateFrom=2024-07-01T00:00:00Z \
10 --data-urlencode dateTo=2024-07-31T23:59:59Z \
11 -d settlementState=settled \
12 -d settlementDate=2024-07-15 \
13 -d before=2571 \
14 -d after=8516 \
15 -d limit=25

Response fields

If your request is successful, our gateway returns a list of payments that match the query parameters. The response contains the following fields:

Example response

Response
1{
2 "limit": 2,
3 "count": 2,
4 "hasMore": true,
5 "data": [
6 {
7 "paymentId": "M2MJOG6O2Y",
8 "processingTerminalId": "1234001",
9 "order": {
10 "orderId": "OrderRef6543",
11 "amount": 4999,
12 "currency": "USD",
13 "dateTime": "2024-07-02T15:30:00Z",
14 "description": "Large Pepperoni Pizza",
15 "breakdown": {
16 "subtotal": 4347,
17 "tip": {
18 "type": "percentage",
19 "amount": 435,
20 "percentage": 10
21 },
22 "taxes": [
23 {
24 "name": "Sales Tax",
25 "rate": 5,
26 "amount": 217
27 }
28 ]
29 }
30 },
31 "bankAccount": {
32 "type": "pad",
33 "nameOnAccount": "Sarah Hazel Hopper",
34 "accountNumber": "*******3159",
35 "transitNumber": "76543",
36 "institutionNumber": "543"
37 },
38 "transactionResult": {
39 "type": "payment",
40 "status": "ready",
41 "responseMessage": "Payment Approved",
42 "authorizedAmount": 4999,
43 "currency": "USD",
44 "responseCode": "A"
45 },
46 "customer": {
47 "notificationLanguage": "en",
48 "contactMethods": [
49 {
50 "type": "email",
51 "value": "[email protected]"
52 }
53 ]
54 }
55 },
56 {
57 "paymentId": "E29U8OU8Q4",
58 "processingTerminalId": "1234001",
59 "order": {
60 "orderId": "OrderRef7654",
61 "amount": 3999,
62 "currency": "USD",
63 "dateTime": "2024-07-02T15:30:00Z",
64 "description": "test",
65 "breakdown": {
66 "subtotal": 3477,
67 "tip": {
68 "type": "percentage",
69 "amount": 348,
70 "percentage": 10
71 },
72 "taxes": [
73 {
74 "name": "Sales Tax",
75 "rate": 5,
76 "amount": 174
77 }
78 ]
79 }
80 },
81 "bankAccount": {
82 "type": "pad",
83 "nameOnAccount": "Sarah Hazel Hopper",
84 "accountNumber": "*******7890",
85 "transitNumber": "76543",
86 "institutionNumber": "543"
87 },
88 "transactionResult": {
89 "type": "payment",
90 "status": "ready",
91 "responseMessage": "Payment Approved",
92 "authorizedAmount": 3999,
93 "currency": "USD",
94 "responseCode": "A"
95 },
96 "customer": {
97 "notificationLanguage": "en",
98 "contactMethods": [
99 {
100 "type": "email",
101 "value": "[email protected]"
102 }
103 ]
104 },
105 "customFields": [
106 {
107 "name": "yourCustomField",
108 "value": "abc123"
109 }
110 ]
111 }
112 ],
113 "links": [
114 {
115 "rel": "next",
116 "method": "get",
117 "href": "https://api.payroc.com/v1/bank-transfer-payments?limit=2&processingTerminalId=1234001&after=E29U8OU8Q4"
118 },
119 {
120 "rel": "previous",
121 "method": "get",
122 "href": "https://api.payroc.com/v1//bank-transfer-payments?limit=2&processingTerminalId=1234001&before=M2MJOG6O2Y"
123 }
124 ]
125}

Step 2 - Refund the payment

To refund the payment, send a POST request to our Bank Transfer Payments Refund endpoint.

Request parameters

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

Example request

POST
/v1/bank-transfer-payments/:paymentId/refund
1curl -X POST https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "amount": 4999,
7 "description": "amount to refund"
8}'

Response fields

If your request is successful, our gateway refunds the payment. The response contains the following fields:

Example response

Response
1{
2 "paymentId": "M2MJOG6O2Y",
3 "processingTerminalId": "1234001",
4 "order": {
5 "orderId": "OrderRef6543",
6 "amount": 4999,
7 "currency": "USD",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Refund for order OrderRef6543",
10 "breakdown": {
11 "subtotal": 4347,
12 "tip": {
13 "type": "percentage",
14 "amount": 435,
15 "percentage": 10
16 },
17 "taxes": [
18 {
19 "name": "Sales Tax",
20 "rate": 5,
21 "amount": 217
22 }
23 ]
24 }
25 },
26 "bankAccount": {
27 "type": "pad",
28 "nameOnAccount": "Sarah Hazel Hopper",
29 "accountNumber": "****7890",
30 "transitNumber": "76543",
31 "institutionNumber": "543",
32 "secureToken": {
33 "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
34 "customerName": "Sarah Hopper",
35 "token": "296753123456",
36 "status": "notValidated",
37 "link": {
38 "rel": "self",
39 "method": "GET",
40 "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"
41 }
42 }
43 },
44 "transactionResult": {
45 "type": "payment",
46 "status": "reversal",
47 "responseMessage": "Payment Approved",
48 "authorizedAmount": 4999,
49 "currency": "USD",
50 "responseCode": "A"
51 },
52 "customer": {
53 "notificationLanguage": "en",
54 "contactMethods": [
55 {
56 "type": "email",
57 "value": "[email protected]"
58 }
59 ]
60 },
61 "customFields": [
62 {
63 "name": "yourCustomField",
64 "value": "abc123"
65 }
66 ]
67}