Accepted
Reward issuance can involve network calls to Stellar, campaign eligibility checks, trustline validation, retries, and merchant-facing status reporting. The API must avoid duplicate rewards when merchants retry requests after timeouts or client failures.
Use an idempotent asynchronous issuance engine:
POST /api/rewards/issue requires an idempotencyKey.reward_issuances.idempotency_key is unique in PostgreSQL.pending record before enqueueing work.jobId.rewardIssuanceWorker increments attempts, validates the campaign, submits
Stellar distribution, and marks the record confirmed or failed.reward-issuance-dlq.Positive:
202 queued while settlement continues.Negative:
novaRewards/backend/routes/rewards.jsnovaRewards/backend/services/rewardIssuanceService.jsnovaRewards/backend/jobs/rewardIssuanceWorker.jsnovaRewards/database/019_create_reward_issuances.sql