Send an unreferenced refund to a customer’s bank account

View as MarkdownOpen in Claude

Note: Only certain merchant accounts can send unreferenced refunds.

A merchant can refund a payment to a customer’s bank account without a paymentId by running an unreferenced refund.

Integration steps

Step 1. 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 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. Refund the payment

To refund a bank transfer payment, send a POST request to the Bank Transfer Refunds 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 order.
refundMethodobjectRequired
Polymorphic object that contains payment details for the refund. The value of the type parameter determines which variant you should use: - `ach` - Automated Clearing House (ACH) details - `secureToken` - Secure token details
customerobjectOptional
Object that contains information about the customer.
customFieldslist of objectsOptional
Array of customField objects.

Example request

POST
/v1/bank-transfer-refunds
1using Payroc;
2using System.Threading.Tasks;
3using Payroc.BankTransferPayments.Refunds;
4using System.Collections.Generic;
5
6namespace Usage;
7
8public class Example
9{
10 public async Task Do() {
11 var client = new BasePayrocClient(
12 clientOptions: new ClientOptions {
13 Environment = PayrocEnvironment.Production
14 }
15 );
16
17 await client.BankTransferPayments.Refunds.CreateAsync(
18 new BankTransferUnreferencedRefund {
19 IdempotencyKey = "8e03978e-40d5-43e8-bc93-6894a57f9324",
20 ProcessingTerminalId = "1234001",
21 Order = new BankTransferRefundOrder {
22 OrderId = "OrderRef6543",
23 Description = "Refund for order OrderRef6543",
24 Amount = 4999L,
25 Currency = Currency.Usd
26 },
27 RefundMethod = new BankTransferUnreferencedRefundRefundMethod(
28 new AchPayload {
29 AccountNumber = "1234567890",
30 NameOnAccount = "Sarah Hazel Hopper",
31 RoutingNumber = "123456789",
32 AccountType = AchPayloadAccountType.Checking,
33 SecCode = AchPayloadSecCode.Web
34 }
35 ),
36 Customer = new BankTransferCustomer {
37 NotificationLanguage = BankTransferCustomerNotificationLanguage.En,
38 ContactMethods = new List<ContactMethod>(){
39 new ContactMethod(
40 new ContactMethodEmail {
41 Value = "[email protected]"
42 }
43 ),
44 }
45
46 },
47 CustomFields = new List<CustomField>(){
48 new CustomField {
49 Name = "yourCustomField",
50 Value = "abc123"
51 },
52 }
53
54 }
55 );
56 }
57
58}

Response fields

If your request is successful, we send the refund to the customer’s bank account and return a response. The response contains the following fields:

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 order.
bankAccountobjectRequired
Polymorphic object that contains bank account information. The value of the type field determines which variant you should use: - `ach` - Automated Clearing House (ACH) details - `pad` - Pre-authorized debit (PAD) details
transactionResultobjectRequiredRead-only
Object that contains information about the transaction.
customerobjectOptional
Object that contains information about the customer.
paymentobjectOptional
Object that contains information about a payment.
customFieldslist of objectsOptional
Array of customField objects.

Example response

Response
1{
2 "refundId": "CD3HN88U9F",
3 "processingTerminalId": "1234001",
4 "order": {
5 "orderId": "OrderRef6543",
6 "description": "Refund for order OrderRef6543",
7 "amount": 4999,
8 "currency": "USD",
9 "dateTime": "2024-07-02T15:30:00Z"
10 },
11 "bankAccount": {
12 "type": "ach",
13 "accountNumber": "****7890",
14 "nameOnAccount": "Sarah Hazel Hopper",
15 "routingNumber": "*****6789",
16 "secCode": "web",
17 "accountType": "checking"
18 },
19 "transactionResult": {
20 "type": "unreferencedRefund",
21 "status": "ready",
22 "currency": "USD",
23 "responseCode": "A",
24 "authorizedAmount": -4999,
25 "responseMessage": "NoError",
26 "processorResponseCode": "0"
27 },
28 "customer": {
29 "notificationLanguage": "en",
30 "contactMethods": [
31 {
32 "type": "email",
33 "value": "[email protected]"
34 }
35 ]
36 },
37 "customFields": [
38 {
39 "name": "yourCustomField",
40 "value": "abc123"
41 }
42 ]
43}