Transactions
Refund transaction
Refund a transaction with the Java SDK.
POST
/refund-transaction/{transaction_id}Use blnk.transactions().refund for this operation.
Call the method
Skip queue
String transactionId = "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c";
ApiResponse<JsonNode> response = blnk.transactions().refund(
transactionId,
RefundTransactionRequest.create().skipQueue(true));Description and metadata
Set a narration and merge metadata onto the copy inherited from the original. See Refunds.
ApiResponse<JsonNode> response = blnk.transactions().refund(
"txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
RefundTransactionRequest.create()
.description("Refund for ticket #4821")
.metaData(Map.of(
"type", "refund",
"reason", "goodwill")));Dry run
Preview the refund without writing anything. See Dry-run transactions.
ApiResponse<JsonNode> preview = blnk.transactions().refund(
"txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
RefundTransactionRequest.create().dryRun(true));| Field | Type | Description |
|---|---|---|
transactionId | String | Transaction ID of the applied transaction to refund. |
skip_queue | boolean | When true, process the refund synchronously instead of queuing. |
description | String | Narration for the refund. When omitted or empty, the refund copies the original. |
meta_data | Map<String, Object> | Merged onto metadata inherited from the original. |
dry_run | boolean | Return a preview without creating a refund. |
Save the refund transaction ID
On a posted refund, use response.data().get("transaction_id").asText() to track it.
A dry run has no transaction_id. Check would_apply instead.
Response
Skip queue
{
"amount": 1250.34,
"precision": 100,
"precise_amount": 125034,
"transaction_id": "txn_4c8be5c7-7c40-493f-b4a1-c09fcf8e7e7b",
"parent_transaction": "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
"source": "bln_f344b673-e855-4bda-b769-3e94a02c1941",
"destination": "@WorldUSD",
"reference": "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c_refund",
"currency": "USD",
"description": "Card payment on Stripe",
"status": "APPLIED",
"hash": "587dec3f5819f2a1e6f5b016fd97153334a3b6c9568475349911ce6356ec31fa",
"created_at": "2024-11-26T09:33:35.265582042Z"
}Dry run
{
"dry_run": true,
"would_apply": true,
"status": "APPLIED",
"reference": "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c_refund",
"currency": "USD",
"amount": 1250.34,
"precise_amount": "125034",
"precision": 100
}| Field | Type | Description |
|---|---|---|
transaction_id | String | ID of the new refund transaction. |
parent_transaction | String | Original transaction being refunded. |
source | String | Original destination, now the source of the refund. |
destination | String | Original source, now the destination of the refund. |
status | String | Status of the refund transaction. |