Transactions

Refund transaction

Refund a transaction with the Python SDK.

POST/refund-transaction/{transaction_id}

Use blnk.transactions.refund to refund a transaction.

Call the method

Omit the optional body to queue the refund using Core defaults. See Refunds.

response = blnk.transactions.refund(
  "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
)

Process the refund synchronously instead of queuing.

response = blnk.transactions.refund(
  "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
  {"skip_queue": True},
)

Set a narration and merge metadata onto the copy inherited from the original. See Refunds.

response = blnk.transactions.refund(
  "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
  {
    "description": "Refund for ticket #4821",
    "meta_data": {
      "type": "refund",
      "reason": "goodwill",
    },
  },
)

Preview the refund without writing anything. See Dry-run transactions.

preview = blnk.transactions.refund(
  "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
  {"dry_run": True},
)
FieldTypeDescription
transactionIdstrTransaction ID of the applied transaction to refund.
skip_queueboolWhen True, process the refund synchronously instead of queuing.
descriptionstrNarration for the refund. When omitted or empty, the refund copies the original.
meta_datadictMerged onto metadata inherited from the original.
dry_runboolReturn a preview without creating a refund.

Save the refund transaction ID

On a posted refund, use response.data["transaction_id"] to track it. Check parent_transaction to confirm it links to the original.

A dry run has no transaction_id. Check would_apply instead.

Response

{
  "amount": 1250.34,
  "precision": 100,
  "precise_amount": 125034,
  "transaction_id": "txn_af70986c-fbdc-450a-bf81-c1af034ce840",
  "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": "QUEUED",
  "hash": "0b9c25fb5b00d6c71cb4ca87026bf6dc316e63353d3330deb588bd0b3d74dcc0",
  "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_idstrID of the new refund transaction.
parent_transactionstrOriginal transaction being refunded.
sourcestrOriginal destination, now the source of the refund.
destinationstrOriginal source, now the destination of the refund.
statusstrStatus of the refund transaction.