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
Queued refund
Omit the optional body to queue the refund using Core defaults. See Refunds.
response = blnk.transactions.refund(
"txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
)Skip queue
Process the refund synchronously instead of queuing.
response = blnk.transactions.refund(
"txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
{"skip_queue": True},
)Description and metadata
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",
},
},
)Dry run
Preview the refund without writing anything. See Dry-run transactions.
preview = blnk.transactions.refund(
"txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
{"dry_run": True},
)| Field | Type | Description |
|---|---|---|
transactionId | str | Transaction ID of the applied transaction to refund. |
skip_queue | bool | When True, process the refund synchronously instead of queuing. |
description | str | Narration for the refund. When omitted or empty, the refund copies the original. |
meta_data | dict | Merged onto metadata inherited from the original. |
dry_run | bool | Return 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
Queued refund
{
"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
{
"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 | str | ID of the new refund transaction. |
parent_transaction | str | Original transaction being refunded. |
source | str | Original destination, now the source of the refund. |
destination | str | Original source, now the destination of the refund. |
status | str | Status of the refund transaction. |