Пример #1
0
class OrderForm(forms.ModelForm):
    """
    Order form details
    """
    account_iban = IBANFormField(label='Konta numurs (IBAN)')
    swift = BICFormField(label='Bankas SWIFT kods')

    class Meta(object):
        model = models.Order
        fields = (
            'quantity',
            'name',
            'phone',
            'email',
            'legal_address',
            'shipment_address',
            'bank',
            'swift',
            'account_iban',
        )
        widgets = {
            'quantity': forms.TextInput(attrs={'class': 'col-5'}),
            'phone': forms.TextInput(attrs={'class': 'col-5'}),
            'email': forms.EmailInput(attrs={'class': 'col-5'}),
            'bank': forms.TextInput(attrs={'class': 'col-5'}),
            'swift': forms.TextInput(attrs={'class': 'col-5'}),
            'legal_address': forms.Textarea(attrs={
                'cols': 80,
                'rows': 2
            }),
            'shipment_address': forms.Textarea(attrs={
                'cols': 80,
                'rows': 2
            }),
        }
Пример #2
0
    class NewRefundForm(forms.Form):
        payer = forms.CharField(label=_('Account holder'), )
        iban = IBANFormField(label=_('IBAN'), )
        bic = BICFormField(
            label=_('BIC (optional)'),
            required=False,
        )

        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)
            for n, f in self.fields.items():
                f.required = False
                f.widget.is_required = False

        def clean_payer(self):
            val = self.cleaned_data.get('payer')
            if not val:
                raise ValidationError(_("This field is required."))
            return val

        def clean_iban(self):
            val = self.cleaned_data.get('iban')
            if not val:
                raise ValidationError(_("This field is required."))
            return val
Пример #3
0
 def settings_form_fields(self):
     d = OrderedDict([
         ('ack',
          forms.BooleanField(
              label=
              _('I have understood that I need to regularly create SEPA XML export files and transfer '
                'them to my bank in order to have my bank collect the customer payments.'
                ),
              required=True,
          )),
         ('creditor_name',
          forms.CharField(
              label=_('Creditor name'),
              max_length=70,
          )),
         ('creditor_iban', IBANFormField(label=_('Creditor IBAN'), )),
         ('creditor_bic', BICFormField(label=_('Creditor BIC'), )),
         ('creditor_id',
          forms.CharField(
              label=_('Creditor ID'),
              validators=[
                  RegexValidator(
                      regex=
                      (r"^[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){3,3}"
                       r"([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,28}$"),
                      message=_('This must be a valid SEPA creditor ID.'),
                  )
              ],
              max_length=28)),
         ('reference_prefix',
          forms.CharField(
              label=_('Mandate reference prefix'),
              validators=[
                  RegexValidator(
                      regex=r"^[a-zA-Z0-9',.:+\-/\(\)?]+$",
                      message=
                      _("This may only contain letters, numbers, and the following special "
                        "characters: ' , . : + - / ( ) ?")),
              ],
              required=False,
              help_text=
              _('We will use this string and append the event slug and the order code to build a '
                'unique SEPA mandate reference.'),
              max_length=35 - settings.ENTROPY['order_code'] - 2 -
              len(self.event.slug))),
         ('prenotification_days',
          forms.IntegerField(
              label=_('Pre-notification time'),
              help_text=
              _('Number of days between the placement of the order and the due date of the direct '
                'debit. Depending on your legislation and your bank rules, you might be required to '
                'hand in a debit at least 5 days before the due date at your bank and you might even '
                'be required to inform the customer at least 14 days beforehand. We recommend '
                'configuring at least 7 days.'),
              min_value=1)),
     ] + list(super().settings_form_fields.items()))
     d.move_to_end('_enabled', last=False)
     return d
Пример #4
0
class SEPATransferForm(PinRequestForm):
    form_name = _("SEPA transfer")
    field_order = ['recipient', 'iban', 'bic', 'amount', 'purpose']

    recipient = forms.CharField(label=_('Recipient'), required=True)
    iban = IBANFormField(label=_("IBAN"), required=True)
    bic = BICFormField(label=_("BIC"), required=True)
    amount = forms.DecimalField(label=_('Amount'), required=True)
    purpose = forms.CharField(label=_('Purpose'), required=True)
Пример #5
0
 def payment_form_fields(self):
     return OrderedDict([
         ('account', forms.CharField(label=_('Account holder'))),
         ('iban', IBANFormField(label=_('IBAN'))),
         ('bic', BICFormField(label=_('BIC'))),
         ('mandate',
          forms.BooleanField(label=_(
              'I hereby grant the SEPA direct debit mandate for this order (see below)'
          ))),
     ])
Пример #6
0
class SepaXMLExportForm(forms.Form):
    account_holder = forms.CharField(label=_("Account holder"))
    iban = IBANFormField(label="IBAN")
    bic = BICFormField(label="BIC")

    def set_initial_from_event(self, event: Event):
        banktransfer = event.get_payment_providers(cached=True)[BankTransfer.identifier]
        self.initial["account_holder"] = banktransfer.settings.get("bank_details_sepa_name")
        self.initial["iban"] = banktransfer.settings.get("bank_details_sepa_iban")
        self.initial["bic"] = banktransfer.settings.get("bank_details_sepa_bic")
Пример #7
0
class PrepareDDForm(forms.Form):
    debit_date = forms.DateField(
        label=_("Debit date"),
        required=True,
        help_text=
        _("Date on which the debit should become effective. "
          "Warning: There are likely to be contractual limitations concerning this "
          "date between you and your bank. Generally should be 14 days in the "
          "future, on a bank day, not more than 30 days in the future."))
    debit_text = forms.CharField(required=True,
                                 label=_('Memo'),
                                 help_text=_(
                                     'Memo/subject that the member will see '
                                     'on their bank statement.'))

    own_name = forms.CharField(required=True, label=_('Creditor name'))
    own_iban = IBANFormField(required=True, label=_('Creditor IBAN'))
    own_bic = BICFormField(required=True, label=_('Creditor BIC'))
    sepa_format = forms.CharField(required=True,
                                  label=_('SEPA PAIN format'),
                                  initial='pain.001.001.03')
    own_account = forms.CharField(required=False, widget=forms.HiddenInput())

    cor1 = forms.BooleanField(label=_('Issue express debit (COR1)'),
                              required=False,
                              help_text=_(
                                  "An express debit has a reduced lead "
                                  "time of generally 1 business day, "
                                  "but must be explicitly agreed upon "
                                  "when giving the SEPA mandate."))

    exp_bank_types = forms.ChoiceField(required=True,
                                       label=_("Bank types"),
                                       choices=[('ALL', _('All banks')),
                                                ('DE', _('German banks only')),
                                                ('NDE',
                                                 _('Non-German banks only'))])
    exp_member_numbers = forms.CharField(
        required=False,
        label=_("Member numbers"),
        help_text=_(
            "Allows to issue a direct debit for a subset of members only. "
            "Example: 1-9,20-29,42"))

    subject = forms.CharField(required=True)
    text = forms.CharField(widget=forms.Textarea)

    debit_date.widget.attrs.update({'class': 'datepicker'})
Пример #8
0
 def form_fields():
     return OrderedDict([
         ('ack',
          forms.BooleanField(
              label=
              _('I have understood that people will pay the ticket price directly to my bank account and '
                'pretix cannot automatically know what payments arrived. Therefore, I will either mark '
                'payments as complete manually, or regularly import a digital bank statement in order to '
                'give pretix the required information.'),
              required=True,
          )),
         ('bank_details_type',
          forms.ChoiceField(label=_('Bank account type'),
                            widget=forms.RadioSelect,
                            choices=(
                                ('sepa', _('SEPA bank account')),
                                ('other', _('Other bank account')),
                            ),
                            initial='sepa')),
         ('bank_details_sepa_name',
          forms.CharField(
              label=_('Name of account holder'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details_sepa_iban',
          IBANFormField(
              label=_('IBAN'),
              required=False,
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
          )),
         ('bank_details_sepa_bic',
          BICFormField(
              label=_('BIC'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details_sepa_bank',
          forms.CharField(
              label=_('Name of bank'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details',
          I18nFormField(
              label=_('Bank account details'),
              widget=I18nTextarea,
              help_text=
              _('Include everything else that your customers might need to send you a bank transfer payment. '
                'If you have lots of international customers, they might need your full address and your '
                'bank\'s full address.'),
              widget_kwargs={
                  'attrs': {
                      'rows':
                      '4',
                      'placeholder':
                      _('For SEPA accounts, you can leave this empty. Otherwise, please add everything that '
                        'your customers need to transfer the money, e.g. account numbers, routing numbers, '
                        'addresses, etc.'),
                  }
              },
              required=False)),
         ('invoice_immediately',
          forms.BooleanField(
              label=
              _('Create an invoice for orders using bank transfer immediately if the event is otherwise '
                'configured to create invoices after payment is completed.'
                ),
              required=False,
          )),
         ('public_name',
          I18nFormField(label=_('Payment method name'),
                        widget=I18nTextInput,
                        required=False)),
         ('omit_hyphen',
          forms.BooleanField(
              label=_('Do not include hyphens in the payment reference.'),
              help_text=_('This is required in some countries.'),
              required=False)),
         ('include_invoice_number',
          forms.BooleanField(
              label=_('Include invoice number in the payment reference.'),
              required=False)),
         ('prefix',
          forms.CharField(
              label=_('Prefix for the payment reference'),
              required=False,
          )),
         ('pending_description',
          I18nFormField(
              label=_('Additional text to show on pending orders'),
              help_text=_(
                  'This text will be shown on the order confirmation page for pending orders in addition to '
                  'the standard text.'),
              widget=I18nTextarea,
              required=False,
          )),
         ('refund_iban_blocklist',
          forms.CharField(
              label=_('IBAN blocklist for refunds'),
              required=False,
              widget=forms.Textarea,
              help_text=
              _('Put one IBAN or IBAN prefix per line. The system will not attempt to send refunds to any '
                'of these IBANs. Useful e.g. if you receive a lot of "forwarded payments" by a third-party payment '
                'provider. You can also list country codes such as "GB" if you never want to send refunds to '
                'IBANs from a specific country.'))),
     ])
Пример #9
0
 def form_fields():
     return OrderedDict([
         ('ack',
          forms.BooleanField(
              label=
              _('I have understood that people will pay the ticket price directly to my bank account and '
                'pretix cannot automatically know what payments arrived. Therefore, I will either mark '
                'payments as complete manually, or regularly import a digital bank statement in order to '
                'give pretix the required information.'),
              required=True,
          )),
         ('bank_details_type',
          forms.ChoiceField(
              label=_('Bank account type'),
              widget=forms.RadioSelect,
              choices=(
                  ('sepa', _('SEPA bank account')
                   ),
                  (
                      'other', _('Other bank account')),
              ),
              initial='sepa')),
         ('bank_details_sepa_name',
          forms.CharField(
              label=_('Name of account holder'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details_sepa_iban',
          IBANFormField(
              label=_('IBAN'),
              required=False,
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
          )),
         ('bank_details_sepa_bic',
          BICFormField(
              label=_('BIC'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details_sepa_bank',
          forms.CharField(
              label=_('Name of bank'),
              widget=forms.TextInput(
                  attrs={
                      'data-display-dependency':
                      '#id_payment_banktransfer_bank_details_type_0',
                      'data-required-if':
                      '#id_payment_banktransfer_bank_details_type_0'
                  }),
              required=False)),
         ('bank_details',
          I18nFormField(
              label=_('Bank account details'),
              widget=I18nTextarea,
              help_text=
              _('Include everything else that your customers might need to send you a bank transfer payment. '
                'If you have lots of international customers, they might need your full address and your '
                'bank\'s full address.'),
              widget_kwargs={
                  'attrs': {
                      'rows':
                      '4',
                      'placeholder':
                      _('For SEPA accounts, you can leave this empty. Otherwise, please add everything that '
                        'your customers need to transfer the money, e.g. account numbers, routing numbers, '
                        'addresses, etc.'),
                  }
              },
              required=False)),
         ('public_name',
          I18nFormField(label=_('Payment method name'),
                        widget=I18nTextInput,
                        required=False))
     ])
Пример #10
0
 def test_default_form(self):
     bic_model_field = BICField()
     self.assertEqual(type(bic_model_field.formfield()),
                      type(BICFormField()))
Пример #11
0
 def test_form_field_formatting(self):
     bic_form_field = BICFormField()
     self.assertEqual(bic_form_field.prepare_value('deutdeff'), 'DEUTDEFF')
     self.assertIsNone(bic_form_field.prepare_value(None))
     self.assertEqual(bic_form_field.to_python(None), '')
Пример #12
0
 def test_form_field_formatting(self):
     bic_form_field = BICFormField()
     self.assertEqual(bic_form_field.prepare_value("deutdeff"), "DEUTDEFF")
     self.assertIsNone(bic_form_field.prepare_value(None))
     self.assertEqual(bic_form_field.to_python(None), "")
Пример #13
0
 def form_fields():
     return OrderedDict([
         ('bank_details_type', forms.ChoiceField(
             label=_('Bank account type'),
             widget=forms.RadioSelect,
             choices=(
                 ('sepa', _('SEPA bank account')),
                 ('other', _('Other bank account')),
             ),
             initial='sepa'
         )),
         ('bank_details_sepa_name', forms.CharField(
             label=_('Name of account holder'),
             widget=forms.TextInput(
                 attrs={
                     'data-display-dependency': '#id_payment_banktransfer_bank_details_type_0',
                     'data-required-if': '#id_payment_banktransfer_bank_details_type_0'
                 }
             ),
             required=False
         )),
         ('bank_details_sepa_iban', IBANFormField(
             label=_('IBAN'),
             required=False,
             widget=forms.TextInput(
                 attrs={
                     'data-display-dependency': '#id_payment_banktransfer_bank_details_type_0',
                     'data-required-if': '#id_payment_banktransfer_bank_details_type_0'
                 }
             ),
         )),
         ('bank_details_sepa_bic', BICFormField(
             label=_('BIC'),
             widget=forms.TextInput(
                 attrs={
                     'data-display-dependency': '#id_payment_banktransfer_bank_details_type_0',
                     'data-required-if': '#id_payment_banktransfer_bank_details_type_0'
                 }
             ),
             required=False
         )),
         ('bank_details_sepa_bank', forms.CharField(
             label=_('Name of bank'),
             widget=forms.TextInput(
                 attrs={
                     'data-display-dependency': '#id_payment_banktransfer_bank_details_type_0',
                     'data-required-if': '#id_payment_banktransfer_bank_details_type_0'
                 }
             ),
             required=False
         )),
         ('bank_details', I18nFormField(
             label=_('Bank account details'),
             widget=I18nTextarea,
             help_text=_(
                 'Include everything else that your customers might need to send you a bank transfer payment. '
                 'If you have lots of international customers, they might need your full address and your '
                 'bank\'s full address.'),
             widget_kwargs={'attrs': {
                 'rows': '4',
                 'placeholder': _(
                     'For SEPA accounts, you can leave this empty. Otherwise, please add everything that '
                     'your customers need to transfer the money, e.g. account numbers, routing numbers, '
                     'addresses, etc.'
                 ),
             }},
             required=False
         )),
         ('public_name', I18nFormField(
             label=_('Payment method name'),
             widget=I18nTextInput,
             required=False
         ))
     ])
Пример #14
0
    def settings_form_fields(self):

        d = OrderedDict([
            ('ack',
             forms.BooleanField(
                 label=
                 _('I have understood that I need to regularly create SEPA XML export files and transfer '
                   'them to my bank in order to have my bank collect the customer payments.'
                   ),
                 required=True,
             )),
            ('creditor_name',
             forms.CharField(
                 label=_('Creditor name'),
                 max_length=70,
             )), ('creditor_iban', IBANFormField(label=_('Creditor IBAN'), )),
            ('creditor_bic', BICFormField(label=_('Creditor BIC'), )),
            ('creditor_id',
             forms.CharField(
                 label=_('Creditor ID'),
                 validators=[
                     RegexValidator(
                         regex=
                         (r"^[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){3,3}"
                          r"([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,28}$"),
                         message=_('This must be a valid SEPA creditor ID.'),
                     )
                 ],
                 max_length=28)),
            ('reference_prefix',
             forms.CharField(
                 label=_('Mandate reference prefix'),
                 validators=[
                     RegexValidator(
                         regex=r"^[a-zA-Z0-9',.:+\-/\(\)?]+$",
                         message=
                         _("This may only contain letters, numbers, and the following special "
                           "characters: ' , . : + - / ( ) ?")),
                 ],
                 required=False,
                 help_text=
                 _('We will use this string and append the event slug and the order code to build a '
                   'unique SEPA mandate reference.'),
                 max_length=35 - settings.ENTROPY['order_code'] - 2 -
                 len(self.event.slug))),
            ('prenotification_days',
             forms.IntegerField(
                 label=_('Pre-notification time'),
                 help_text=
                 _('Number of days between the placement of the order and the due date of the direct '
                   'debit. Depending on your legislation and your bank rules, you might be required to '
                   'hand in a debit at least 5 days before the due date at your bank and you might even '
                   'be required to inform the customer at least 14 days beforehand. We recommend '
                   'configuring at least 7 days.'),
                 min_value=1)),
            ('iban_blocklist',
             forms.CharField(
                 label=_('IBAN blocklist'),
                 required=False,
                 widget=forms.Textarea,
                 help_text=
                 _('Put one IBAN or IBAN prefix per line. The system will not allow any of these IBANs. Useful e.g. '
                   'if you had lots of failed payments already from a specific person. You can also list country codes'
                   'such as "GB" if you never want to accept IBANs from a specific country.'
                   ))),
            ('earliest_due_date',
             forms.DateField(
                 label=_('Earliest debit due date'),
                 help_text=
                 _('Earliest date the direct debit can be due. '
                   'This date is used as the direct debit due date if the order date plus pre-notification time would result in a due date earlier than this. '
                   'Customers with orders using the earliest due date will receive an email reminding them about the upcoming charge based on the configured pre-notification days.'
                   ),
                 required=False,
                 widget=forms.widgets.DateInput(
                     attrs={'class': 'datepickerfield'}))),
            ('pre_notification_mail_subject',
             I18nFormField(
                 label=_("Pre-notification mail subject"),
                 help_text=
                 _('The subject of the notification email. '
                   'This email is only sent if the earliest debit due date option is used.'
                   ),
                 required=False,
                 widget=I18nTextInput,
                 widget_kwargs={
                     'attrs': {
                         'data-display-dependency':
                         '#id_payment_sepadebit_earliest_due_date'
                     }
                 },
             )),
            ('pre_notification_mail_body',
             I18nFormField(
                 label=_("Pre-notification mail body"),
                 help_text=
                 _('The body of the notification email. '
                   'This email is only sent if the earliest debit due date option is used.'
                   ),
                 required=False,
                 widget=I18nTextarea,
                 widget_kwargs={
                     'attrs': {
                         'data-display-dependency':
                         '#id_payment_sepadebit_earliest_due_date'
                     }
                 },
             ))
        ] + list(super().settings_form_fields.items()))
        d.move_to_end('_enabled', last=False)

        self._set_field_placeholders(d, "pre_notification_mail_subject",
                                     ["event", "order", "sepadebit_payment"],
                                     [])
        self._set_field_placeholders(d, "pre_notification_mail_body",
                                     ["event", "order", "sepadebit_payment"],
                                     [])
        return d