Skip to content
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

Stripe global settings #521

Merged
merged 6 commits into from
Jan 25, 2025

Conversation

HungNgien
Copy link
Contributor

@HungNgien HungNgien commented Jan 24, 2025

Description: add fields in the global settings to input Stripe keys, allowing the billing information of organizers to be saved when the fields are filled.

This PR resolves #485

Summary by Sourcery

New Features:

  • Allow organizers to save their billing information using Stripe Connect.

Copy link

sourcery-ai bot commented Jan 24, 2025

Reviewer's Guide by Sourcery

This pull request introduces new fields in the global settings to input Stripe keys, which allows the billing information of organizers to be saved when the fields are filled. It also adds a validator to ensure that the Stripe keys are in the correct format.

Class diagram for Stripe key validation and settings form

classDiagram
    class GlobalSettingsForm {
        +__init__(*args, **kwargs)
    }
    class StripeKeyValidator {
        -_prefixes: List[str]
        +__init__(prefix: Union[str, List[str]])
        +__call__(value: str)
    }
    class SecretKeySettingsField {
    }
    GlobalSettingsForm -- SecretKeySettingsField : uses
    GlobalSettingsForm -- StripeKeyValidator : uses
    note for GlobalSettingsForm "Added new Stripe Connect fields:
    - payment_stripe_connect_secret_key
    - payment_stripe_connect_publishable_key
    - payment_stripe_connect_test_secret_key
    - payment_stripe_connect_test_publishable_key"
    note for StripeKeyValidator "Validates Stripe keys
with specific prefixes:
- sk_live_, rk_live_
- pk_live_
- sk_test_, rk_test_
- pk_test_"
Loading

Flow diagram for Stripe key validation process

flowchart TD
    A[Start Validation] --> B{Is key empty?}
    B -->|Yes| C[Raise ValidationError:
Key cannot be empty]
    B -->|No| D{Check key prefix}
    D -->|Valid prefix| E[Validation Success]
    D -->|Invalid prefix| F[Raise ValidationError:
Invalid key format]
    F --> G[Show error message with
expected prefix format]
Loading

File-Level Changes

Change Details Files
Added fields for Stripe Connect secret and publishable keys, both for live and test modes.
  • Added 'payment_stripe_connect_secret_key' field.
  • Added 'payment_stripe_connect_publishable_key' field.
  • Added 'payment_stripe_connect_test_secret_key' field.
  • Added 'payment_stripe_connect_test_publishable_key' field.
src/pretix/control/forms/global_settings.py
Added a validator to ensure that Stripe keys start with the correct prefix.
  • Created a 'StripeKeyValidator' class.
  • The validator checks if the key starts with the expected prefix(es).
  • The validator supports both single and multiple prefix validation.
src/pretix/control/forms/global_settings.py
Updated the 'stripe_webhook_secret_key' field label.
  • Changed the label of 'stripe_webhook_secret_key' to 'Stripe Webhook: Secret key'.
src/pretix/control/forms/global_settings.py

Assessment against linked issues

Issue Objective Addressed Explanation
#485 Ensure the system works without dependency on the Stripe module
#485 Add 2 new fields in global settings for admin to input Stripe keys
#485 Enable organizer billing to use Stripe keys from global settings

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@HungNgien HungNgien marked this pull request as ready for review January 24, 2025 10:06
@mariobehling mariobehling merged commit 81866cd into fossasia:development Jan 25, 2025
3 of 5 checks passed
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.

Global settings - new form to input stripe key
3 participants