Developers

Reward Callback Idempotency: Duplicates, Retries, and Reversals

Design a reward callback ledger that credits once, handles repeated delivery and reversals, and acknowledges processing only after durable state is saved.

Dark technical banner reading Credit Once, Handle Retries, with duplicate requests converging into one ledger result

A user should not receive two credits because the same reward callback was processed twice. The backend also needs to distinguish a duplicate completion from a later reversal of that completion. Those are different events with different accounting effects.

Idempotency means repeating an operation does not repeat its economic effect. This guide presents an application design and test plan, not a drop-in endpoint or a promise about any provider's retry schedule.

Identify the callback contract before writing the handler

The RapidoReach callback documentation distinguishes legacy survey callbacks from Offers V2 placement setup. For legacy verification, offerHash uses lowercase MD5 of transactionId + AppKey; txnHash uses transactionId + AppSecret. Compare in constant time. These hashes cover the transaction ID, not the amount or every query field.

Follow that contract's HTTPS, value-validation, and current source-IP guidance. Keep callback credentials on the server. Do not copy the legacy verification formula into an Offers V2 handler; use its placement-specific configuration.

For legacy delivery, HTTP 200 indicates successful processing; a response body of 1 is not the success contract. Return a failure status when processing fails. The documentation does not establish an automatic retry timetable, so arrange reconciliation rather than relying on an assumed schedule.

Model identity separately from the accounting effect

Scope a provider transaction to the correct application or placement. A naked transaction string should not accidentally identify a transaction belonging to a different integration.

A useful app-owned model has a transaction record, accepted state transitions, and immutable ledger entries. Store the provider reference, internal account mapping, validated currency units, verification outcome, processing result, and timestamps needed for support.

For a hypothetical one-completion, one-reversal contract, use an effect key such as (integration, transaction, completion-credit) and a separate reversal-debit effect. This is an internal model, not a RapidoReach parameter name. Richer correction contracts may require a provider event ID or version; do not deduplicate all future changes with a status string alone.

Make the decision and ledger write atomic

A read-then-write check is vulnerable to concurrency. Two requests can both observe that no credit exists and both proceed.

Use a database uniqueness constraint for the intended effect and an atomic transaction or equivalent conditional operation that protects both the processing decision and ledger update. The exact mechanism depends on your database and wallet design.

The conceptual sequence is: validate the request, resolve the account and integration, acquire the protected transaction state, decide whether a permitted new transition exists, write the ledger effect and processing record together, commit, then acknowledge success. A previously committed equivalent event can be acknowledged without adding value again.

If the database commits but the HTTP response is lost, a repeat should find that committed result. If the commit fails, do not claim success while the balance is still missing.

Test a concrete credit and reversal sequence

Suppose a hypothetical completion grants 40 internal points. A duplicate completion leaves the ledger at plus 40. A validated full reversal creates one minus-40 entry linked to the original credit. Repeating that reversal leaves the net effect at zero.

Illustrative accounting effects, not a provider payload specification
Accepted inputNew ledger effectNet transaction effect
First completion+40 points+40
Equivalent completion againNone+40
First permitted full reversal-40 points0
Equivalent reversal againNone0

Store signed, validated units consistently. Avoid floating-point drift in a points ledger and reject malformed or out-of-range values. Reconcile a conflicting amount against trusted transaction information and the applicable contract instead of treating a familiar transaction ID as permission to overwrite the original credit.

Handle out-of-order and conflicting events deliberately

A reversal arriving before your recorded completion needs a policy. One conservative design persists it as a pending exception, applies no spendable credit, and resolves it against trusted provider state. Do not silently discard it and later accept the completion as if no reversal had existed.

Similarly, distinguish an equivalent duplicate from a repeated transaction carrying a different user, amount, currency, or integration. A conflict should enter investigation or contract-specific reconciliation, not inherit the successful duplicate response merely because its reference matches.

Define what happens when a valid reversal exceeds the user's spendable balance. Account restrictions, negative balances, or another documented recovery policy are product decisions that must remain consistent with your terms and accounting design.

Choose an acknowledgment boundary you can defend

A synchronous handler can acknowledge after the accounting transaction commits. An asynchronous design needs durable receipt storage and a recoverable worker before it acknowledges successful acceptance under its provider contract.

An in-memory queue is not durable receipt storage. If a process exits after responding, the work can disappear. Track queued, processed, conflicted, and failed receipts so operations can identify unfinished work without blindly replaying everything.

Keep full callback URLs and credentials out of ordinary logs. Use redacted references, outcome codes, and access-controlled support records. Observability should explain the processing decision without distributing sensitive request values.

Use a failure-focused acceptance matrix

  • Send the same valid event sequentially and concurrently; assert one ledger effect.
  • Use a wrong verification value or unknown account; assert no credit.
  • Fail persistence before commit; assert no success acknowledgment.
  • Lose the response after commit, then repeat; assert no second credit.
  • Repeat a reversal and test reversal-before-completion handling.
  • Change a repeated event's amount or account; assert a conflict path.
  • Read the wallet after a client disconnect; assert durable backend state.

Use isolated development fixtures and the provider's supported test tools. These are acceptance criteria for your implementation; publishing this checklist does not establish that a particular backend has passed them.

Keep the app experience aligned with backend state

Show confirmed and pending rewards clearly. A return event can trigger a wallet refresh, while the ledger remains the source of truth for spendable value.

Plan these responsibilities alongside SDK or API selection and the AI-assisted integration checklist. The useful launch question is whether the complete path is verified: identity, presentation, callback processing, durable accounting, and a wallet that reflects the result.

FROM READING TO BUILDING

Your next revenue stream
starts with a better experience.

Give your users a choice. Add rewarded surveys to your app, game, or website with RapidoReach.