Skip to content

CONV-269: Implement credit pack purchase idempotency#238

Merged
menvil merged 1 commit into
developfrom
feature/CONV-269-implement-credit-pack-purchase-idempotency
Jun 2, 2026
Merged

CONV-269: Implement credit pack purchase idempotency#238
menvil merged 1 commit into
developfrom
feature/CONV-269-implement-credit-pack-purchase-idempotency

Conversation

@menvil

@menvil menvil commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wraps grant logic in DB::transaction() with a checkout session ID check
  • alreadyGrantedForCheckoutSession() queries credit_transactions by metadata_json->stripe_checkout_session_id
  • Same checkout session ID (even with different event IDs) does not grant credits twice
  • No separate table created — metadata query is sufficient

Test plan

  • Duplicate same event → credits granted once
  • Same checkout session, different event IDs → credits granted once
  • composer test passes (481 tests)
  • composer lint passes

🤖 Generated with Claude Code


Summary by cubic

Implements credit pack checkout with Stripe and makes credit granting idempotent using the Checkout Session ID so duplicate or replayed events don’t grant credits twice. Satisfies CONV-269.

  • New Features

    • Config-driven credit packs (config/billing.php) with simple checkout: POST /billing/credits/{pack} redirects to Stripe; success/cancel views added.
    • Idempotent webhook handling: requires Checkout Session ID, wraps grant in DB::transaction(), and skips if credit_transactions.metadata_json->stripe_checkout_session_id already exists.
    • Stripe integration via CashierCreditPackCheckoutGateway; metadata includes user_id, pack_key, pack_credits; tests cover flow and idempotency.
  • Migration

    • Set STRIPE_CREDIT_PACK_SMALL_PRICE_ID, STRIPE_CREDIT_PACK_MEDIUM_PRICE_ID, STRIPE_CREDIT_PACK_LARGE_PRICE_ID.
    • Point Stripe checkout.session.completed webhooks to POST /stripe/webhook.
    • No database changes required.

Written for commit 9031d7f. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • release

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd0804f2-ca2b-4ed1-9226-6368f5d358b2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/CONV-269-implement-credit-pack-purchase-idempotency

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@menvil menvil force-pushed the feature/CONV-269-implement-credit-pack-purchase-idempotency branch from 181d999 to 9031d7f Compare June 2, 2026 18:32
@menvil menvil merged commit df9086f into develop Jun 2, 2026
@menvil menvil deleted the feature/CONV-269-implement-credit-pack-purchase-idempotency branch June 2, 2026 18:32
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