예제 #1
0
def register_global_settings(sender, **kwargs):
    return OrderedDict([
        ('payment_stripe_connect_client_id',
         forms.CharField(
             label=_('Stripe Connect: Client ID'),
             required=False,
             validators=(StripeKeyValidator('ca_'), ),
         )),
        ('payment_stripe_connect_secret_key',
         forms.CharField(
             label=_('Stripe Connect: Secret key'),
             required=False,
             validators=(StripeKeyValidator(['sk_live_', 'rk_live_']), ),
         )),
        ('payment_stripe_connect_publishable_key',
         forms.CharField(
             label=_('Stripe Connect: Publishable key'),
             required=False,
             validators=(StripeKeyValidator('pk_live_'), ),
         )),
        ('payment_stripe_connect_test_secret_key',
         forms.CharField(
             label=_('Stripe Connect: Secret key (test)'),
             required=False,
             validators=(StripeKeyValidator(['sk_test_', 'rk_test_']), ),
         )),
        ('payment_stripe_connect_test_publishable_key',
         forms.CharField(
             label=_('Stripe Connect: Publishable key (test)'),
             required=False,
             validators=(StripeKeyValidator('pk_test_'), ),
         )),
    ])
예제 #2
0
파일: payment.py 프로젝트: pajowu/pretix
    def settings_form_fields(self):
        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)),
                    ('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.pretix.eu/en/latest/user/payments/stripe.html'
                            ),
                     validators=(StripeKeyValidator('pk_'), ),
                 )),
                ('secret_key',
                 forms.CharField(
                     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 registred in. Usually, this is your '
                         'country of residence.'),
                 )),
            ]
        d = OrderedDict(fields + [
            ('method_cc',
             forms.BooleanField(
                 label=_('Credit card payments'),
                 required=False,
             )),
            ('method_giropay',
             forms.BooleanField(
                 label=_('giropay'),
                 disabled=self.event.currency != 'EUR',
                 help_text=_(
                     'Needs to be enabled in your Stripe account first.'),
                 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,
             )),
        ] + list(super().settings_form_fields.items()))
        d.move_to_end('_enabled', last=False)
        return d
예제 #3
0
파일: payment.py 프로젝트: zippyy/pretix
 def settings_form_fields(self):
     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)),
                 ('endpoint',
                  forms.ChoiceField(
                      label=_('Endpoint'),
                      initial='live',
                      choices=(
                          ('live', pgettext('stripe', 'Live')),
                          ('test', pgettext('stripe', 'Testing')),
                      ),
                  )),
             ]
         else:
             return {}
     else:
         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.pretix.eu/en/latest/user/payments/stripe.html'
                         ),
                  validators=(StripeKeyValidator('pk_'), ),
              )),
             ('secret_key',
              forms.CharField(
                  label=_('Secret key'),
                  validators=(StripeKeyValidator(['sk_', 'rk_']), ),
              )),
         ]
     d = OrderedDict(fields + [
         ('ui',
          forms.ChoiceField(
              label=_('User interface'),
              choices=(
                  ('pretix', _('Simple (pretix design)')),
                  ('checkout', _('Stripe Checkout')),
              ),
              help_text=_('Only relevant for credit card payments.'))),
         ('method_cc',
          forms.BooleanField(
              label=_('Credit card payments'),
              required=False,
          )),
         ('method_giropay',
          forms.BooleanField(
              label=_('giropay'),
              disabled=self.event.currency != 'EUR',
              help_text=_(
                  'Needs to be enabled in your Stripe account first.'),
              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. Note that, despite the name, '
                'payments are not immediately confirmed but might take some time.'
                ),
              required=False,
          )),
         ('cc_3ds_mode',
          forms.ChoiceField(
              label=_('3D Secure mode'),
              help_text=
              _('This determines when we will use the 3D Secure methods for credit card payments. '
                'Using 3D Secure (also known as Verified by VISA or MasterCard SecureCode) reduces '
                'the risk of fraud but makes the payment process a bit longer.'
                ),
              choices=(
                  ('required',
                   pgettext('stripe 3dsecure',
                            'Only when required by the card')),
                  ('recommended',
                   pgettext('stripe 3dsecure',
                            'Always when recommended by Stripe')),
                  ('optional',
                   pgettext('stripe 3dsecure',
                            'Always when supported by the card')),
              ),
          )),
     ] + list(super().settings_form_fields.items()))
     d.move_to_end('_enabled', last=False)
     return d