-
Notifications
You must be signed in to change notification settings - Fork 5
chore: align plugin against enext branch #16
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
chore: align plugin against enext branch #16
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR aligns module imports, log action identifiers, and database references from pretix to eventyay across the Stripe plugin implementation. Entity relationship diagram for updated Stripe object referenceserDiagram
ReferencedStripeObject {
string reference
base.Order order
base.OrderPayment payment
}
RegisteredApplePayDomain {
string domain
}
ReferencedStripeObject ||--|{ "base.Order" : order
ReferencedStripeObject ||--|{ "base.OrderPayment" : payment
Class diagram for updated plugin app configurationclassDiagram
class StripePluginApp {
name: string
verbose_name: string
}
class EventyayPluginMeta {
name: string
author: string
version: string
}
StripePluginApp <|-- EventyayPluginMeta
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `eventyay_stripe/payment.py:93-95` </location>
<code_context>
_(
"To accept payments via Stripe, you will need an account at Stripe. By clicking on the "
- "following button, you can either create a new Stripe account connect pretix to an existing "
+ "following button, you can either create a new Stripe account connect eventyay to an existing "
"one."
),
</code_context>
<issue_to_address>
**suggestion:** The sentence structure is unclear and may confuse users.
Rephrase to clarify the options: creating a new Stripe account or connecting to an existing one.
```suggestion
"To accept payments via Stripe, you will need an account at Stripe. By clicking the following button, you can either create a new Stripe account or connect eventyay to an existing Stripe account."
```
</issue_to_address>
### Comment 2
<location> `eventyay_stripe/apps.py:8-9` </location>
<code_context>
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
from . import __version__
try:
from eventyay.base.plugins import PluginConfig
except ImportError:
raise RuntimeError("Python package 'stripe' is not installed.")
</code_context>
<issue_to_address>
**suggestion (code-quality):** Explicitly raise from a previous error ([`raise-from-previous-error`](https://docs.sourcery.ai/Reference/Default-Rules/suggestions/raise-from-previous-error/))
```suggestion
except ImportError as e:
raise RuntimeError("Python package 'stripe' is not installed.") from e
```
</issue_to_address>
### Comment 3
<location> `eventyay_stripe/payment.py:125` </location>
<code_context>
@property
def settings_form_fields(self):
if 'eventyay_resellers' in [p.module for p in get_all_plugins()]:
moto_settings = [
(
"reseller_moto",
forms.BooleanField(
label=_("Enable MOTO payments for resellers"),
help_text=(
_(
"Gated feature (needs to be enabled for your account by Stripe support first)"
)
+ '<div class="alert alert-danger">%s</div>'
% _(
"We can flag the credit card transaction you make through the reseller interface as "
"MOTO (Mail Order / Telephone Order), which will exempt them from Strong Customer "
"Authentication (SCA) requirements. However: By enabling this feature, you will need to "
"fill out yearly PCI-DSS self-assessment forms like the 40 page SAQ D. Please "
"consult the %s for further information on this subject."
% '<a href="https://stripe.com/docs/security">{}</a>'.format(
_("Stripe Integration security guide")
)
)
),
required=False,
),
)
]
else:
moto_settings = []
if self.settings.connect_client_id and not self.settings.secret_key:
# Stripe connect
if self.settings.connect_user_id:
fields = [
(
"connect_user_name",
forms.CharField(label=_("Stripe account"), disabled=True),
),
(
"connect_user_id",
forms.CharField(label=_("Stripe user id"), disabled=True),
),
(
"endpoint",
forms.ChoiceField(
label=_("Endpoint"),
initial="live",
choices=(
("live", pgettext("stripe", "Live")),
("test", pgettext("stripe", "Testing")),
),
help_text=_(
"If your event is in test mode, we will always use Stripe's test API, "
"regardless of this setting."
),
),
),
]
else:
return {}
else:
allcountries = list(countries)
allcountries.insert(0, ("", _("Select country")))
fields = [
(
"publishable_key",
forms.CharField(
label=_("Publishable key"),
help_text=_(
'<a target="_blank" rel="noopener" href="{docs_url}">{text}</a>'
).format(
text=_(
"Click here for a tutorial on how to obtain the required keys"
),
docs_url="https://docs.stripe.com/keys",
),
validators=(StripeKeyValidator("pk_"),),
),
),
(
"secret_key",
SecretKeySettingsField(
label=_("Secret key"),
validators=(StripeKeyValidator(["sk_", "rk_"]),),
),
),
(
"merchant_country",
forms.ChoiceField(
choices=allcountries,
label=_("Merchant country"),
help_text=_(
"The country in which your Stripe-account is registered in. Usually, this is your "
"country of residence."
),
),
),
]
d = OrderedDict(
fields
+ [
(
"method_card",
forms.BooleanField(
label=_("Credit card payments"),
required=False,
),
),
(
"method_ideal",
forms.BooleanField(
label=_("iDEAL"),
disabled=self.event.currency != "EUR",
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_alipay",
forms.BooleanField(
label=_("Alipay"),
disabled=self.event.currency
not in (
'EUR', 'AUD', 'CAD', 'GBP', 'HKD', 'JPY', 'NZD', 'SGD', 'USD'
),
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_bancontact",
forms.BooleanField(
label=_("Bancontact"),
disabled=self.event.currency != "EUR",
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_sofort",
forms.BooleanField(
label=_("SOFORT"),
disabled=self.event.currency != "EUR",
help_text=(
_("Needs to be enabled in your Stripe account first.")
+ '<div class="alert alert-warning">%s</div>'
% _(
"Despite the name, Sofort payments via Stripe are <strong>not</strong> processed "
"instantly but might take up to <strong>14 days</strong> to be confirmed in some cases. "
"Please only activate this payment method if your payment term allows for this lag."
)
),
required=False,
),
),
(
"method_eps",
forms.BooleanField(
label=_("EPS"),
disabled=self.event.currency != "EUR",
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_multibanco",
forms.BooleanField(
label=_("Multibanco"),
disabled=self.event.currency != "EUR",
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_przelewy24",
forms.BooleanField(
label=_("Przelewy24"),
disabled=self.event.currency not in ["EUR", "PLN"],
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
"method_wechatpay",
forms.BooleanField(
label=_("WeChat Pay"),
disabled=self.event.currency
not in ['AUD', 'CAD', 'EUR', 'GBP', 'HKD', 'JPY', 'SGD', 'USD'],
help_text=_(
"Needs to be enabled in your Stripe account first."
),
required=False,
),
),
(
'method_mobilepay',
forms.BooleanField(
label=_('MobilePay'),
disabled=self.event.currency not in ['DKK', 'EUR', 'NOK', 'SEK'],
help_text=_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before they work properly.'),
required=False,
)
),
(
'method_revolut_pay',
forms.BooleanField(
label='Revolut Pay',
disabled=self.event.currency not in ['EUR', 'GBP'],
help_text=_('Revolut Pay method might need to be enabled in the settings of your Stripe account '
'before they work properly. Revolut Pay payments must be in currencies supported in your country.'),
required=False,
)
),
(
'method_swish',
forms.BooleanField(
label=_('Swish'),
disabled=self.event.currency != 'SEK',
help_text=_('Swish method might need to be enabled in the settings of your Stripe account '
'before they work properly.'),
required=False,
)
),
(
'method_twint',
forms.BooleanField(
label='TWINT',
disabled=self.event.currency != 'CHF',
help_text=_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before they work properly.'),
required=False,
)
),
(
'method_affirm',
forms.BooleanField(
label=_('Affirm'),
disabled=self.event.currency not in ['USD', 'CAD'],
help_text=' '.join([
str(_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before they work properly.')),
str(_('Only available for payments between $50 and $30,000.'))
]),
required=False,
)
),
(
'method_klarna',
forms.BooleanField(
label=_('Klarna'),
disabled=self.event.currency not in [
'AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'NOK', 'NZD', 'PLN', 'SEK', 'USD'
],
help_text=' '.join([
str(_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before they work properly.')),
str(_('Klarna and Stripe will decide which of the payment methods offered by Klarna are '
'available to the user.')),
str(_('Klarna\'s terms of services do not allow it to be used by charities or political '
'organizations.')),
]),
required=False,
)
),
(
'method_sepa_debit',
forms.BooleanField(
label=_('SEPA Direct Debit'),
disabled=self.event.currency != 'EUR',
help_text=(
_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before work properly.') +
'<div class="alert alert-warning">%s</div>' % _(
'SEPA Direct Debit payments via Stripe are <strong>not</strong> processed '
'instantly but might take up to <strong>14 days</strong> to be confirmed in some cases. '
'Please only activate this payment method if your payment term allows for this lag.'
)),
required=False,
)
),
(
'sepa_creditor_name',
forms.CharField(
label=_('SEPA Creditor Mandate Name'),
disabled=self.event.currency != 'EUR',
help_text=_('Please provide your SEPA Creditor Mandate Name, that will be displayed to the user.'),
required=False,
widget=forms.TextInput(
attrs={
'data-display-dependency': '#id_payment_stripe_method_sepa_debit',
'data-required-if': '#id_payment_stripe_method_sepa_debit'
}
),
)
),
]
+ list(super().settings_form_fields.items())
+ moto_settings
)
d.move_to_end("_enabled", last=False)
return d
</code_context>
<issue_to_address>
**issue (code-quality):** We've found these issues:
- Replace if statement with if expression ([`assign-if-exp`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/assign-if-exp/))
- Replace call to format with f-string ([`use-fstring-for-formatting`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/use-fstring-for-formatting/))
- Replace interpolated string formatting with f-string ([`replace-interpolation-with-fstring`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/replace-interpolation-with-fstring/))
</issue_to_address>
### Comment 4
<location> `eventyay_stripe/views.py:320-321` </location>
<code_context>
def charge_webhook(event, event_json, charge_id, rso):
prov = StripeCreditCard(event)
prov._init_api()
try:
charge = stripe.Charge.retrieve(
charge_id,
expand=['dispute', 'refunds', 'payment_intent', 'payment_intent.latest_charge'],
**prov.api_config
)
except stripe.error.StripeError:
logger.exception('Stripe error on webhook. Event data: %s', str(event_json))
return HttpResponse('Charge not found', status=HTTPStatus.INTERNAL_SERVER_ERROR)
metadata = charge['metadata']
if 'event' not in metadata:
return HttpResponse('Event not given in charge metadata', status=HTTPStatus.OK)
if int(metadata['event']) != event.pk:
return HttpResponse('Not interested in this event', status=HTTPStatus.OK)
if rso and rso.payment:
order = rso.payment.order
payment = rso.payment
elif rso:
order = rso.order
payment = None
else:
try:
order = event.orders.get(id=metadata['order'])
except Order.DoesNotExist:
return HttpResponse('Order not found', status=HTTPStatus.OK)
payment = None
with transaction.atomic():
if payment:
payment = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=payment.pk)
else:
payment = order.payments.filter(
info__icontains=charge['id'],
provider__startswith='stripe',
amount=prov._amount_to_decimal(charge['amount']),
).select_for_update(of=OF_SELF).last()
if not payment:
payment = order.payments.create(
state=OrderPayment.PAYMENT_STATE_CREATED,
provider=(SOURCE_TYPES.get(
charge['source'].get('type', charge['source'].get('object', 'card')), 'stripe'
)),
amount=prov._amount_to_decimal(charge['amount']),
info=str(charge),
)
if payment.provider != prov.identifier:
prov = payment.payment_provider
prov._init_api()
order.log_action('eventyay.plugins.stripe.event', data=event_json)
is_refund = charge['amount_refunded'] or charge['refunds']['total_count'] or charge['dispute']
if is_refund:
known_refunds = [r.info_data.get('id') for r in payment.refunds.all()]
migrated_refund_amounts = [r.amount for r in payment.refunds.all() if not r.info_data.get('id')]
for r in charge['refunds']['data']:
a = prov._amount_to_decimal(r['amount'])
if r['status'] in ('failed', 'canceled'):
continue
if a in migrated_refund_amounts:
migrated_refund_amounts.remove(a)
continue
if r['id'] not in known_refunds:
payment.create_external_refund(
amount=a,
info=str(r)
)
if charge['dispute']:
if charge['dispute']['status'] != 'won' and charge['dispute']['id'] not in known_refunds:
a = prov._amount_to_decimal(charge['dispute']['amount'])
if a in migrated_refund_amounts:
migrated_refund_amounts.remove(a)
else:
payment.create_external_refund(
amount=a,
info=str(charge['dispute'])
)
elif charge['status'] == 'succeeded' and payment.state in (
OrderPayment.PAYMENT_STATE_PENDING,
OrderPayment.PAYMENT_STATE_CREATED,
OrderPayment.PAYMENT_STATE_CANCELED,
OrderPayment.PAYMENT_STATE_FAILED
):
try:
if getattr(charge, "payment_intent", None):
payment.info = str(charge.payment_intent)
payment.confirm()
except LockTimeoutException:
return HttpResponse("Lock timeout, please try again.", status=HTTPStatus.SERVICE_UNAVAILABLE)
except Quota.QuotaExceededException:
pass
elif charge['status'] == 'failed' and payment.state in (
OrderPayment.PAYMENT_STATE_PENDING,
OrderPayment.PAYMENT_STATE_CREATED
):
payment.fail(info=str(charge))
return HttpResponse(status=HTTPStatus.OK)
</code_context>
<issue_to_address>
**suggestion (code-quality):** We've found these issues:
- Use named expression to simplify assignment and conditional ([`use-named-expression`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/use-named-expression/))
- Low code quality found in charge\_webhook - 13% ([`low-code-quality`](https://docs.sourcery.ai/Reference/Default-Rules/comments/low-code-quality/))
```suggestion
if (
is_refund := charge['amount_refunded']
or charge['refunds']['total_count']
or charge['dispute']
):
```
<br/><details><summary>Explanation</summary>
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines.
- Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
mariobehling
left a comment
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.
Please make this PR against the enext branch.
The PR is made against enext branch only. |
|
The commit is against master branch not enext branch. So, please fix it. |
9627a3b to
1d2cb51
Compare
1d2cb51 to
d3744b0
Compare
|
@hongquan could you please review this PR. |
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.
Pull Request Overview
This pull request renames all references from "pretix" to "eventyay" throughout the Stripe plugin codebase, reflecting a rebranding or fork of the payment integration system. The changes are systematic and affect imports, database model references, log action identifiers, and configuration settings.
Key Changes:
- Updated all Python imports from
pretix.*toeventyay.*across the codebase - Changed database foreign key references from
pretixbasetobase - Updated log action type identifiers and plugin module names to use
eventyaynamespace - Modified class names and user-facing strings to reflect the new branding
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| eventyay_stripe/views.py | Updated imports from pretix to eventyay and changed log action identifiers |
| eventyay_stripe/urls.py | Updated import path for event_url from pretix to eventyay |
| eventyay_stripe/tasks.py | Changed imports for task handling and URL generation to eventyay |
| eventyay_stripe/signals.py | Updated signal imports and log entry action type references |
| eventyay_stripe/payment.py | Changed all payment provider imports, updated user-facing text, and modified plugin references |
| eventyay_stripe/models.py | Updated Django model foreign key references from pretixbase to base |
| eventyay_stripe/migrations/0001_initial.py | Changed migration dependency and foreign key targets, updated field types |
| eventyay_stripe/management/commands/stripe_connect_fill_countries.py | Updated imports and plugin name filter |
| eventyay_stripe/forms.py | Changed import path for SettingsForm |
| eventyay_stripe/apps.py | Updated PluginConfig import and renamed PretixPluginMeta to EventyayPluginMeta |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else: | ||
| message = _( | ||
| 'Please configure a %(link)s to ' | ||
| 'Please configure a %%(link)s to ' |
Copilot
AI
Oct 31, 2025
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.
The string formatting is incorrect. The line uses %%(link)s (escaped percentage signs) but then attempts to use % formatting with a dictionary on line 117. This will output the literal string %(link)s instead of substituting the link. Change %%(link)s to %(link)s.
| 'Please configure a %%(link)s to ' | |
| 'Please configure a %(link)s to ' |
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.
No having just %(link)s was the problem that's why I had to add extra %
eventyay_stripe/apps.py
Outdated
|
|
||
| try: | ||
| from pretix.base.plugins import PluginConfig | ||
| from eventyay.base.plugins import PluginConfig |
Copilot
AI
Oct 31, 2025
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.
Import of 'PluginConfig' is not used.
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.
Thank you
d3744b0 to
a76e42f
Compare
This PR is a part of fossasia/eventyay#1030
Summary by Sourcery
Align module imports and namespace references from pretix to eventyay throughout the Stripe plugin
Enhancements: