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

String transactionId = "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c";

ApiResponse<JsonNode> response = blnk.transactions().refund(
    transactionId,
    RefundTransactionRequest.create().skipQueue(true));

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")));

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));
FieldTypeDescription
transactionIdStringTransaction ID of the applied transaction to refund.
skip_queuebooleanWhen true, process the refund synchronously instead of queuing.
descriptionStringNarration for the refund. When omitted or empty, the refund copies the original.
meta_dataMap<String, Object>Merged onto metadata inherited from the original.
dry_runbooleanReturn 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

{
  "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": true,
  "would_apply": true,
  "status": "APPLIED",
  "reference": "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c_refund",
  "currency": "USD",
  "amount": 1250.34,
  "precise_amount": "125034",
  "precision": 100
}
FieldTypeDescription
transaction_idStringID of the new refund transaction.
parent_transactionStringOriginal transaction being refunded.
sourceStringOriginal destination, now the source of the refund.
destinationStringOriginal source, now the destination of the refund.
statusStringStatus of the refund transaction.