mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add quick-start assistant for new users (#833)
* First draft for quick-setup * Add payment * Fix stripe w/o connect * cols * Add tests
This commit is contained in:
@@ -14,9 +14,9 @@ class BankTransfer(BasePaymentProvider):
|
||||
identifier = 'banktransfer'
|
||||
verbose_name = _('Bank transfer')
|
||||
|
||||
@property
|
||||
def settings_form_fields(self):
|
||||
form_field = I18nFormField(
|
||||
@staticmethod
|
||||
def form_field(**kwargs):
|
||||
return I18nFormField(
|
||||
label=_('Bank account details'),
|
||||
widget=I18nTextarea,
|
||||
help_text=_('Include everything that your customers need to send you a bank transfer payment. Within SEPA '
|
||||
@@ -30,10 +30,14 @@ class BankTransfer(BasePaymentProvider):
|
||||
'Account owner: John Doe\n'
|
||||
'Name of Bank: Professional Banking Institute Ltd., London'
|
||||
)
|
||||
}}
|
||||
}},
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@property
|
||||
def settings_form_fields(self):
|
||||
d = OrderedDict(
|
||||
list(super().settings_form_fields.items()) + [('bank_details', form_field)]
|
||||
list(super().settings_form_fields.items()) + [('bank_details', self.form_field())]
|
||||
)
|
||||
d.move_to_end('bank_details', last=False)
|
||||
d.move_to_end('_enabled', last=False)
|
||||
|
||||
@@ -51,25 +51,31 @@ class StripeSettingsHolder(BasePaymentProvider):
|
||||
super().__init__(event)
|
||||
self.settings = SettingsSandbox('payment', 'stripe', event)
|
||||
|
||||
def get_connect_url(self, request):
|
||||
request.session['payment_stripe_oauth_event'] = request.event.pk
|
||||
if 'payment_stripe_oauth_token' not in request.session:
|
||||
request.session['payment_stripe_oauth_token'] = get_random_string(32)
|
||||
return (
|
||||
"https://connect.stripe.com/oauth/authorize?response_type=code&client_id={}&state={}"
|
||||
"&scope=read_write&redirect_uri={}"
|
||||
).format(
|
||||
self.settings.connect_client_id,
|
||||
request.session['payment_stripe_oauth_token'],
|
||||
urlquote(build_global_uri('plugins:stripe:oauth.return')),
|
||||
)
|
||||
|
||||
def settings_content_render(self, request):
|
||||
if self.settings.connect_client_id and not self.settings.secret_key:
|
||||
# Use Stripe connect
|
||||
if not self.settings.connect_user_id:
|
||||
request.session['payment_stripe_oauth_event'] = request.event.pk
|
||||
if 'payment_stripe_oauth_token' not in request.session:
|
||||
request.session['payment_stripe_oauth_token'] = get_random_string(32)
|
||||
|
||||
return (
|
||||
"<p>{}</p>"
|
||||
"<a href='https://connect.stripe.com/oauth/authorize?response_type=code&client_id={}&state={}"
|
||||
"&scope=read_write&redirect_uri={}' class='btn btn-primary btn-lg'>{}</a>"
|
||||
"<a href='{}' class='btn btn-primary btn-lg'>{}</a>"
|
||||
).format(
|
||||
_('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 '
|
||||
'one.'),
|
||||
self.settings.connect_client_id,
|
||||
request.session['payment_stripe_oauth_token'],
|
||||
urlquote(build_global_uri('plugins:stripe:oauth.return')),
|
||||
self.get_connect_url(request),
|
||||
_('Connect with Stripe')
|
||||
)
|
||||
else:
|
||||
|
||||
@@ -93,6 +93,10 @@ def oauth_return(request, *args, **kwargs):
|
||||
event.settings.payment_stripe_connect_user_id = data['stripe_user_id']
|
||||
event.settings.payment_stripe_connect_user_name = account['business_name']
|
||||
|
||||
if request.session.get('payment_stripe_oauth_enable', False):
|
||||
event.settings.payment_stripe__enabled = True
|
||||
del request.session['payment_stripe_oauth_enable']
|
||||
|
||||
return redirect(reverse('control:event.settings.payment.provider', kwargs={
|
||||
'organizer': event.organizer.slug,
|
||||
'event': event.slug,
|
||||
|
||||
Reference in New Issue
Block a user