Cancel a Pay In transaction with the API

Learn how to cancel a Pay In transaction using the API
View as MarkdownOpen in Claude
Applies to:Developers

How you cancel a pay-in transaction depends on the transaction status. If a transaction hasn’t been settled yet, you can void it. If a transaction has been settled, or settlement is pending, you can refund the transaction.

This guide explains how to void and refund transactions with the Payabli API.

Choose a method

First, choose a transaction cancellation method based on the transaction’s settlement status.

Transaction cancellation decision flowchart
Click to expand

Diagram: Transaction cancellation decision flow

This flowchart shows how to choose a cancellation method for a Pay In transaction:

  • Has the transaction been settled?
    • No: Use Void — cancels an existing sale or captured authorization and prevents future captures for non-captured authorizations.
    • Yes: Use Refund — sends money back to the accountholder after the transaction has settled.

Void

A void cancels an existing sale or captured authorization. Voiding non-captured authorizations prevents future captures. You can void unsettled transactions. If a transaction has been settled, refund it instead.

Refund

A refund sends money back to the accountholder after a transaction has been settled. If a transaction hasn’t been settled, void it instead.

Check the transaction status

Before you cancel, check the transaction’s SettlementStatus to decide which method to use. Send a GET request to the details endpoint with the transaction’s transId:

GET
/api/MoneyIn/details/:transId
1curl https://api-sandbox.payabli.com/api/MoneyIn/details/45-as456777hhhhhhhhhh77777777-324 \
2 -H "requestToken: <apiKey>"

A SettlementStatus of 0 (Pending) means the transaction is still in an open batch, so you void it. A value of 1 (In Transit) or higher means settlement has begun, so you refund it instead.

Transaction details (excerpt)
1{
2 "PaymentTransId": "10-3ffa27df-b171-44e0-b251-e95fbfc7a723",
3 "TransStatus": 1,
4 "SettlementStatus": 0
5}

For the full mapping of status codes to methods, see the Decision guide: Void vs refund.

Path parameters

When canceling a transaction via the API, you always need the transId, which is the paymentTransId for the transaction. For partial refunds, you also need the amount to refund.

transId
stringRequired

Required for voids and refunds

The paymentTransId identifying the transaction. You can find this in the success response for the original transaction.

amount
double

Required for partial refunds

The amount to refund from the original transaction, minus any service fee charged on the original transaction. This amount can’t be greater than the original total amount of the transaction minus the service fee. For example, if a transaction was $90 plus a $10 service fee, you can refund up to $90. For a full refund, omit the amount and call POST /v2/MoneyIn/refund/{transId}.

Void a transaction

You can void transactions that haven’t settled yet.

This example voids the transaction with a paymentTransId of 10-3ffa27df-b171-44e0-b251-e95fbfc7a723:

POST
/api/v2/MoneyIn/void/:transId
1curl -X POST https://api-sandbox.payabli.com/api/v2/MoneyIn/void/10-3ffa27df-b171-44e0-b251-e95fbfc7a723 \
2 -H "requestToken: <apiKey>"

A successful void returns a 200 status. If you try to void a transaction that has already been voided, the API returns an error response.

Response
1{
2 "code": "A0003",
3 "reason": "Canceled",
4 "explanation": "Transaction canceled",
5 "action": "No action required",
6 "data": {
7 "parentOrgName": "Mrinal's Pet Supplies",
8 "paypointDbaname": "Mrinal's Pet Shop North",
9 "paypointLegalname": "Mrinal's Pet Shop North",
10 "paypointEntryname": "495147f647",
11 "paymentTransId": "3040-96dfa9a7c4ed4f82a3dd4a4a12ad28ae",
12 "connectorName": "gp",
13 "externalProcessorInformation": "",
14 "gatewayTransId": "TRN_Ih68D6UZdip7OEQ2QFXat1yQSLF2nB",
15 "orderId": null,
16 "method": "card",
17 "batchNumber": "3040_combined_20251201_3a50747d-6b5c-40ef-9f69-93a9cc7fcb49",
18 "batchAmount": 420,
19 "payorId": 4440,
20 "paymentData": {
21 "maskedAccount": "4XXXXXXXXXXX5439",
22 "accountType": "visa",
23 "accountExp": "12/25",
24 "holderName": "John Cassian",
25 "storedId": null,
26 "initiator": null,
27 "storedMethodUsageType": null,
28 "sequence": null,
29 "orderDescription": "",
30 "accountId": null,
31 "signatureData": null,
32 "binData": {
33 "binMatchedLength": "6",
34 "binCardBrand": "VISA",
35 "binCardType": "CREDIT",
36 "binCardCategory": "CLASSIC",
37 "binCardIssuer": "",
38 "binCardIssuerCountry": "RUSSIAN FEDERATION",
39 "binCardIssuerCountryCodeA2": "RU",
40 "binCardIssuerCountryNumber": "643",
41 "binCardIsRegulated": "",
42 "binCardUseCategory": "",
43 "binCardIssuerCountryCodeA3": ""
44 },
45 "paymentDetails": {
46 "totalAmount": 105,
47 "serviceFee": 5,
48 "checkNumber": null,
49 "checkUniqueId": "",
50 "currency": "USD",
51 "orderDescription": null,
52 "orderId": null,
53 "orderIdAlternative": null,
54 "paymentDescription": null,
55 "groupNumber": null,
56 "source": null,
57 "payabliTransId": null,
58 "categories": [],
59 "splitFunding": [],
60 "checkImage": null,
61 "unbundled": null
62 }
63 },
64 "transStatus": 5,
65 "paypointId": 3040,
66 "totalAmount": 105,
67 "netAmount": 100,
68 "feeAmount": 5,
69 "settlementStatus": 0,
70 "operation": "Sale",
71 "responseData": {
72 "resultCode": "A0000",
73 "resultCodeText": "Approved",
74 "response": null,
75 "responsetext": "CAPTURED",
76 "authcode": "AXS425",
77 "transactionid": "TRN_Xo4dpKfmx3OxSc9svd2ccI6OOnyB2I",
78 "avsresponse": "N",
79 "avsresponse_text": "No Match, No address or ZIP match",
80 "cvvresponse": "M",
81 "cvvresponse_text": "CVV2/CVC2 match",
82 "orderid": null,
83 "response_code": "100",
84 "response_code_text": "Operation successful",
85 "customer_vault_id": null,
86 "emv_auth_response_data": null,
87 "type": null
88 },
89 "source": "api",
90 "scheduleReference": 0,
91 "orgId": 123,
92 "refundId": 0,
93 "returnedId": 0,
94 "chargebackId": 0,
95 "retrievalId": 0,
96 "invoiceData": {
97 "invoiceNumber": null,
98 "invoiceDate": null,
99 "invoiceDueDate": null,
100 "invoiceEndDate": null,
101 "invoiceStatus": null,
102 "invoiceType": null,
103 "frequency": null,
104 "paymentTerms": null,
105 "termsConditions": null,
106 "notes": null,
107 "tax": null,
108 "discount": null,
109 "invoiceAmount": null,
110 "freightAmount": null,
111 "dutyAmount": null,
112 "purchaseOrder": null,
113 "firstName": null,
114 "lastName": null,
115 "company": null,
116 "shippingAddress1": null,
117 "shippingAddress2": null,
118 "shippingCity": null,
119 "shippingState": null,
120 "shippingZip": null,
121 "shippingCountry": null,
122 "shippingEmail": null,
123 "shippingPhone": null,
124 "shippingFromZip": null,
125 "summaryCommodityCode": null,
126 "items": null,
127 "attachments": null,
128 "additionalData": null
129 },
130 "entrypageId": 0,
131 "externalPaypointID": "",
132 "isValidatedACH": false,
133 "transactionTime": "2025-12-01T09:50:03.559",
134 "customer": {
135 "identifiers": null,
136 "firstName": "David",
137 "lastName": "Beckham",
138 "companyName": "Driving School LLC",
139 "billingAddress1": "Home Address",
140 "billingAddress2": "",
141 "billingCity": "",
142 "billingState": "",
143 "billingZip": "45157",
144 "billingCountry": "US",
145 "billingPhone": "+15555555555",
146 "billingEmail": "example@payabli.com",
147 "customerNumber": "C-90010",
148 "shippingAddress1": "Home Address",
149 "shippingAddress2": "",
150 "shippingCity": "",
151 "shippingState": "",
152 "shippingZip": "45157",
153 "shippingCountry": "US",
154 "customerId": 4440,
155 "customerStatus": 0,
156 "additionalData": null
157 },
158 "splitFundingInstructions": null,
159 "cfeeTransactions": [
160 {
161 "cFeeTransid": "3040-96dfa9a7c4ed4f82a3dd4a4a12ad28ae",
162 "feeAmount": 5,
163 "operation": "Sale",
164 "refundId": 0,
165 "responseData": {},
166 "settlementStatus": 0,
167 "transactionTime": "2025-12-01T09:50:03.559",
168 "transStatus": 1
169 }
170 ],
171 "transactionEvents": [
172 {
173 "transEvent": "Created",
174 "eventData": "0HNHD68HATSUC:00000001",
175 "eventTime": "2025-12-01T09:50:02.558651"
176 },
177 {
178 "transEvent": "Approved",
179 "eventData": "0HNHD68HATSUC:00000001",
180 "eventTime": "2025-12-01T09:50:03.609111"
181 }
182 ],
183 "riskStatus": "PASSED",
184 "riskReason": "",
185 "riskAction": "",
186 "deviceId": "",
187 "achSecCode": "",
188 "achHolderType": "personal",
189 "ipAddress": "255.255.255.255",
190 "isSameDayACH": false,
191 "walletType": null,
192 "pendingFeeAmount": 0,
193 "riskFlagged": false,
194 "riskFlaggedOn": "2025-12-01T09:50:02.5474568",
195 "riskActionCode": 0,
196 "transAdditionalData": null
197 },
198 "token": null
199}

Refund a transaction

You can refund settled transactions. If you use the Enhanced Refund Flow, see the guide for information about how refunds are handled in different scenarios.

These examples show full and partial refunds.

This example refunds the transaction with a paymentTransId of 10-3ffa27df-b171-44e0-b251-e95fbfc7a723 for the total amount of the transaction.

POST
/api/v2/MoneyIn/refund/:transId
1curl -X POST https://api-sandbox.payabli.com/api/v2/MoneyIn/refund/10-3ffa27df-b171-44e0-b251-e95fbfc7a723 \
2 -H "requestToken: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{}'

A successful refund returns a 201 status with a JSON body.

This example shows a successful refund response for a full refund.

Response
1{
2 "code": "A0004",
3 "reason": "Refunded",
4 "explanation": "Transaction refunded",
5 "action": "No action required",
6 "data": {
7 "parentOrgName": "Mrinal's Pet Supplies",
8 "paypointDbaname": "Mrinal's Pet Shop North",
9 "paypointLegalname": "Mrinal's Pet Shop North",
10 "paypointEntryname": "495147f647",
11 "paymentTransId": "3040-96dfa9a7c4ed4f82a3dd4a4a12ad28ae",
12 "connectorName": "gp",
13 "externalProcessorInformation": "",
14 "gatewayTransId": "TRN_Ih68D6UZdip7OEQ2QFXat1yQSLF2nB",
15 "orderId": null,
16 "method": "card",
17 "batchNumber": "3040_combined_20251201_3a50747d-6b5c-40ef-9f69-93a9cc7fcb49",
18 "batchAmount": 420,
19 "payorId": 4440,
20 "paymentData": {
21 "maskedAccount": "4XXXXXXXXXXX5439",
22 "accountType": "visa",
23 "accountExp": "12/25",
24 "holderName": "John Cassian",
25 "storedId": null,
26 "initiator": null,
27 "storedMethodUsageType": null,
28 "sequence": null,
29 "orderDescription": "",
30 "accountId": null,
31 "signatureData": null,
32 "binData": {
33 "binMatchedLength": "6",
34 "binCardBrand": "VISA",
35 "binCardType": "CREDIT",
36 "binCardCategory": "CLASSIC",
37 "binCardIssuer": "",
38 "binCardIssuerCountry": "RUSSIAN FEDERATION",
39 "binCardIssuerCountryCodeA2": "RU",
40 "binCardIssuerCountryNumber": "643",
41 "binCardIsRegulated": "",
42 "binCardUseCategory": "",
43 "binCardIssuerCountryCodeA3": ""
44 },
45 "paymentDetails": {
46 "totalAmount": 105,
47 "serviceFee": 5,
48 "checkNumber": null,
49 "checkUniqueId": "",
50 "currency": "USD",
51 "orderDescription": null,
52 "orderId": null,
53 "orderIdAlternative": null,
54 "paymentDescription": null,
55 "groupNumber": null,
56 "source": null,
57 "payabliTransId": null,
58 "categories": [],
59 "splitFunding": [],
60 "checkImage": null,
61 "unbundled": null
62 }
63 },
64 "transStatus": 1,
65 "paypointId": 3040,
66 "totalAmount": 105,
67 "netAmount": 100,
68 "feeAmount": 5,
69 "settlementStatus": 0,
70 "operation": "Sale",
71 "responseData": {
72 "resultCode": "A0000",
73 "resultCodeText": "Approved",
74 "response": null,
75 "responsetext": "CAPTURED",
76 "authcode": "AXS425",
77 "transactionid": "TRN_Xo4dpKfmx3OxSc9svd2ccI6OOnyB2I",
78 "avsresponse": "N",
79 "avsresponse_text": "No Match, No address or ZIP match",
80 "cvvresponse": "M",
81 "cvvresponse_text": "CVV2/CVC2 match",
82 "orderid": null,
83 "response_code": "100",
84 "response_code_text": "Operation successful",
85 "customer_vault_id": null,
86 "emv_auth_response_data": null,
87 "type": null
88 },
89 "source": "api",
90 "scheduleReference": 0,
91 "orgId": 123,
92 "refundId": 0,
93 "returnedId": 0,
94 "chargebackId": 0,
95 "retrievalId": 0,
96 "invoiceData": {
97 "invoiceNumber": null,
98 "invoiceDate": null,
99 "invoiceDueDate": null,
100 "invoiceEndDate": null,
101 "invoiceStatus": null,
102 "invoiceType": null,
103 "frequency": null,
104 "paymentTerms": null,
105 "termsConditions": null,
106 "notes": null,
107 "tax": null,
108 "discount": null,
109 "invoiceAmount": null,
110 "freightAmount": null,
111 "dutyAmount": null,
112 "purchaseOrder": null,
113 "firstName": null,
114 "lastName": null,
115 "company": null,
116 "shippingAddress1": null,
117 "shippingAddress2": null,
118 "shippingCity": null,
119 "shippingState": null,
120 "shippingZip": null,
121 "shippingCountry": null,
122 "shippingEmail": null,
123 "shippingPhone": null,
124 "shippingFromZip": null,
125 "summaryCommodityCode": null,
126 "items": null,
127 "attachments": null,
128 "additionalData": null
129 },
130 "entrypageId": 0,
131 "externalPaypointID": "",
132 "isValidatedACH": false,
133 "transactionTime": "2025-12-01T09:50:03.559",
134 "customer": {
135 "identifiers": null,
136 "firstName": "David",
137 "lastName": "Beckham",
138 "companyName": "Driving School LLC",
139 "billingAddress1": "Home Address",
140 "billingAddress2": "",
141 "billingCity": "",
142 "billingState": "",
143 "billingZip": "45157",
144 "billingCountry": "US",
145 "billingPhone": "+15555555555",
146 "billingEmail": "example@payabli.com",
147 "customerNumber": "C-90010",
148 "shippingAddress1": "Home Address",
149 "shippingAddress2": "",
150 "shippingCity": "",
151 "shippingState": "",
152 "shippingZip": "45157",
153 "shippingCountry": "US",
154 "customerId": 4440,
155 "customerStatus": 0,
156 "additionalData": null
157 },
158 "splitFundingInstructions": null,
159 "cfeeTransactions": [
160 {
161 "cFeeTransid": "3040-96dfa9a7c4ed4f82a3dd4a4a12ad28ae",
162 "feeAmount": 5,
163 "operation": "Sale",
164 "refundId": 0,
165 "responseData": {},
166 "settlementStatus": 0,
167 "transactionTime": "2025-12-01T09:50:03.559",
168 "transStatus": 1
169 }
170 ],
171 "transactionEvents": [
172 {
173 "transEvent": "Created",
174 "eventData": "0HNHD68HATSUC:00000001",
175 "eventTime": "2025-12-01T09:50:02.558651"
176 },
177 {
178 "transEvent": "Approved",
179 "eventData": "0HNHD68HATSUC:00000001",
180 "eventTime": "2025-12-01T09:50:03.609111"
181 }
182 ],
183 "riskStatus": "PASSED",
184 "riskReason": "",
185 "riskAction": "",
186 "deviceId": "",
187 "achSecCode": "",
188 "achHolderType": "personal",
189 "ipAddress": "255.255.255.255",
190 "isSameDayACH": false,
191 "walletType": null,
192 "pendingFeeAmount": 0,
193 "riskFlagged": false,
194 "riskFlaggedOn": "2025-12-01T09:50:02.5474568",
195 "riskActionCode": 0,
196 "transAdditionalData": null
197 },
198 "token": null
199}

Just like sale transactions, you can void a refund transaction before the batch closes. Use the paymentTransId from the refund transaction response as the transId in the void request.

See these related resources to help you get the most out of Payabli.