prepareRefundTransaction creates and configures a new transaction object for the refund.
(originalTxn *model.Transaction, skipQueue bool)
| 2312 | |
| 2313 | // prepareRefundTransaction creates and configures a new transaction object for the refund. |
| 2314 | func prepareRefundTransaction(originalTxn *model.Transaction, skipQueue bool) *model.Transaction { |
| 2315 | newTransaction := *originalTxn // Create a copy |
| 2316 | newTransaction.TransactionID = model.GenerateUUIDWithSuffix("txn") |
| 2317 | newTransaction.Reference = model.GenerateUUIDWithSuffix("ref") |
| 2318 | newTransaction.ParentTransaction = originalTxn.TransactionID |
| 2319 | newTransaction.Source = originalTxn.Destination // Swap source and destination |
| 2320 | newTransaction.Destination = originalTxn.Source |
| 2321 | newTransaction.AllowOverdraft = true |
| 2322 | newTransaction.SkipQueue = skipQueue |
| 2323 | |
| 2324 | // Adjust status based on original status for proper processing |
| 2325 | if originalTxn.Status == StatusVoid { |
| 2326 | // If original was voided, the refund should process like an inflight reversal |
| 2327 | newTransaction.Inflight = true |
| 2328 | newTransaction.Status = "" // Reset status to let QueueTransaction handle it |
| 2329 | } else { |
| 2330 | newTransaction.Status = "" // Reset status for standard queuing |
| 2331 | newTransaction.Inflight = false |
| 2332 | } |
| 2333 | |
| 2334 | return &newTransaction |
| 2335 | } |
| 2336 | |
| 2337 | // RefundTransaction processes a refund for a given transaction by its ID. |
| 2338 | // It starts a tracing span, retrieves the original transaction, validates its status, creates a new refund transaction, and queues it. |
no test coverage detected