-
Notifications
You must be signed in to change notification settings - Fork 10
Add custom create_checkout_session options (like success_url) to credit pack purchases
#5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom create_checkout_session options (like success_url) to credit pack purchases
#5
Conversation
|
@rameerez any chance you can merge this? It allows specifying a |
Building on the initial **options implementation: - Merge custom metadata with base_metadata (preserves credit fulfillment data) - Merge payment_intent_data metadata similarly - Protect mode and line_items from being overridden - Add comprehensive YARD documentation with examples This ensures users can customize checkout sessions (success_url, cancel_url, allow_promotion_codes, locale, etc.) without accidentally breaking the credit fulfillment flow by overriding critical metadata. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests cover: - Pass-through options (success_url, cancel_url, allow_promotion_codes, locale, etc.) - Metadata merging (custom metadata + base_metadata preserved) - payment_intent_data metadata merging - Protected parameters (mode, line_items cannot be overridden) - Backward compatibility (no options = works as before) - Edge cases (empty options, nil metadata, nil payment_intent_data) 17 new tests ensuring credit fulfillment data is always preserved while allowing flexible checkout customization. Co-Authored-By: Claude Opus 4.5 <[email protected]>
e938c47 to
8ec892b
Compare
|
Thanks for the PR @yshmarov! I asked Claude to make sure this wouldn't break anything and it came up with this: What was added1. Safe metadata merging and parameter protectionThe original
2. Comprehensive test coverageAdded 17 new tests covering:
Usage example# All these options work safely:
session = credit_pack.create_checkout_session(current_user,
success_url: credits_url,
cancel_url: pricing_url,
allow_promotion_codes: true,
locale: I18n.locale,
metadata: { organization_id: org.id } # Merged with base_metadata
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
The method was mutating the caller's hash by calling .delete(:metadata) directly on the passed payment_intent_data. This caused unexpected side effects when callers reused their hash for multiple checkout sessions. Fix: Use .dup to create a copy before mutating. Added regression tests: - Verify caller's hash is not mutated after call - Verify hash can be reused for multiple checkout sessions Co-Authored-By: Claude Opus 4.5 <[email protected]>
create_checkout_session options (like success_url) to credit pack purchases
with
**optionsnow you can pass additional params to the checkout session.fixes #3
Note
Adds flexible checkout customization while preserving fulfillment safety and backward compatibility.
create_checkout_session(user, **options)to pass through common Stripe options (success_url,cancel_url,allow_promotion_codes,locale,customer_email, etc.)metadataandpayment_intent_data[:metadata]withbase_metadata; base fields take precedencemode,line_items) to prevent overriding; always usesmode: "payment"and pack-defined line itemspayment_intent_dataWritten by Cursor Bugbot for commit ca3ab89. This will update automatically on new commits. Configure here.