Skip to content

feat: spend a loopkit reward at qkit checkout for a single-use code - #292

Merged
cljiahao merged 14 commits into
stagingfrom
feat/qkit-reward-code
Dec 2, 2026
Merged

cljiahao merged 14 commits into
stagingfrom
feat/qkit-reward-code

Conversation

@cljiahao

@cljiahao cljiahao commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

A customer can pick "Use at qkit checkout" on a reward on /c. loopkit marks the voucher redeemed and gets a single-use LK- code from qkit.issue_reward_code in one transaction (migration 0072, loopkit.customer_use_voucher_at_qkit, service role only, card-token proof). The code is shown with a copy button. A retry returns the same code (idempotent on loopkit:<voucher id>), so a spent reward stays on /c as "qkit code issued" with a "Show code" button.

Vendors set what the code is worth (percent or dollars off) in Profile under "qkit reward code". Free, no Pro gate.

Decisions

  • Kind and value live on vendor_notify_settings (vendor level, free, owner-RLS upsert already exists). qkit_earn_config is Pro-gated in the UI, so it was not reused.
  • customer_join is redefined in 0072: vendor_join_cards carries no active_vouchers, so /c never listed any reward vouchers, stamp-card rewards included. Each card now carries active vouchers plus those spent for a qkit code.
  • pgTAP stubs qkit.issue_reward_code because CI has no qkit schema.

Deploy order

qkit 0129_discount_codes (qkit.issue_reward_code) must be applied before this migration. It already is on prod and staging.

The code expires with the voucher (expires_at is passed through).

Tests

pgTAP (supabase/tests/qkit-reward-code.test.sql), vitest for the action, button, settings form and card-status mapping. pnpm run check and the full vitest run pass locally.

🤖 Generated with Claude Code

cljiahao and others added 14 commits December 1, 2026 23:49
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
customer_join now carries active_vouchers per card (stamp-card rewards were never listed). A voucher already spent for a qkit code stays listed with a Show code button; the RPC is idempotent so it returns the same code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ation

The pgTAP stub now mirrors qkit 0129 argument checks and is only created when the real function is absent. The vendor value is limited to two decimals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Staging's 0072 is qkit_earn_free; this migration does not touch qkit_earn_resolve_program.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
#	src/features/card-check/components/README.md
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…P voucher lookup order-independent

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Stryker finds no tests for them and failed the job with no tests executed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…o 0074

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cljiahao
cljiahao merged commit 395e3e9 into staging Dec 2, 2026
10 checks passed
@cljiahao
cljiahao deleted the feat/qkit-reward-code branch December 2, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant