예제 #1
0
 def _process(self):
     if self._registrant.getPayed():
         flash(_('You have already paid for your registration.'), 'info')
         return redirect(
             url_for('event.confRegistrationFormDisplay', self._conf,
                     **get_registrant_params()))
     checkout_attempt_delta = None
     if not self._registrant.isCheckoutSessionAlive():
         self._registrant._checkout_attempt_dt = datetime.now()
     else:
         checkout_attempt_dt = self._registrant.getCheckoutAttemptDt()
         checkout_attempt_delta = int(
             math.ceil(
                 (datetime.now() - checkout_attempt_dt).total_seconds() /
                 60))
     event = self._conf
     amount = self._registrant.getTotal()
     currency = event_settings.get(event, 'currency')
     plugins = get_active_payment_plugins(event)
     force_plugin = plugins.items()[0] if len(
         plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template(
         'event_checkout.html',
         event,
         event=event,
         registrant=self._registrant,
         plugins=plugins.items(),
         force_plugin=force_plugin,
         amount=amount,
         currency=currency,
         checkout_attempt_delta=checkout_attempt_delta,
         registrant_params=get_registrant_params())
예제 #2
0
 def _checkParams(self, params):
     RHRegistrationFormRegistrantBase._checkParams(self, params)
     try:
         self.plugin = get_active_payment_plugins(
             self._conf)[request.args['method']]
     except KeyError:
         raise NotFound
예제 #3
0
    def _check_currencies(self, form):
        """Checks if the currencies are valid.

        :return: `(auto_currency, invalid_currency)` - tuple containing the currency that should
                 be automatically set on the event and a flag if the currency issues cannot be resolved
                 automatically and require user interaction (i.e. saving the plugin settings is disallowed)
        """
        messages = []
        event = self._conf
        valid_currencies = self.plugin.valid_currencies
        currency = event_settings.get(event, 'currency')
        if valid_currencies is None or currency in valid_currencies:
            return None, False, messages

        if len(valid_currencies) == 1:
            auto_currency = list(valid_currencies)[0]
            for plugin in get_active_payment_plugins(event).itervalues():
                if plugin.valid_currencies is not None and auto_currency not in plugin.valid_currencies:
                    messages.append(('error', _("This payment method only supports {}, but the payment method "
                                                "'{}' doesn't.").format(auto_currency, plugin.title)))
                    return None, True, messages
            if not form.is_submitted():
                messages.append(('warning', _("This payment method only supports {0}. Enabling it will automatically "
                                              "change the currency of the event to {0}!").format(auto_currency)))
            return auto_currency, False, messages

        if not form.is_submitted():
            messages.append(('error', _("To enable this payment method, please use one of the following "
                                        "currencies: {}").format(', '.join(valid_currencies))))
        return None, True, messages
예제 #4
0
파일: forms.py 프로젝트: NIIF/indico
 def validate_currency(self, field):
     for plugin in get_active_payment_plugins(self._event).itervalues():
         if plugin.valid_currencies is None:
             continue
         if field.data not in plugin.valid_currencies:
             raise ValidationError(_("The currency is not supported by the payment method '{}'. "
                                     "Please disable it first.").format(plugin.title))
예제 #5
0
파일: forms.py 프로젝트: marcosmolla/indico
 def validate_currency(self, field):
     for plugin in get_active_payment_plugins(self._event).itervalues():
         if plugin.valid_currencies is None:
             continue
         if field.data not in plugin.valid_currencies:
             raise ValidationError(
                 _("The currency is not supported by the payment method '{}'. "
                   "Please disable it first.").format(plugin.title))
예제 #6
0
 def _process(self):
     if self.registration.state != RegistrationState.unpaid:
         flash(_("The registration doesn't need to be paid"), 'error')
         return redirect(url_for('event_registration.display_regform', self.registration.locator.registrant))
     currency = event_settings.get(self.event, 'currency')
     plugins = get_active_payment_plugins(self.event)
     force_plugin = plugins.items()[0] if len(plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template('event_checkout.html', self.event, event=self.event,
                                           registration=self.registration,
                                           regform=self.registration.registration_form,
                                           plugins=plugins.items(), force_plugin=force_plugin,
                                           amount=self.registration.price, currency=currency)
예제 #7
0
 def _process(self):
     if self._registrant.getPayed():
         flash(_('You have already paid for your registration.'), 'info')
         return redirect(url_for('event.confRegistrationFormDisplay', self._conf, **get_registrant_params()))
     checkout_attempt_delta = None
     if not self._registrant.isCheckoutSessionAlive():
         self._registrant._checkout_attempt_dt = datetime.now()
     else:
         checkout_attempt_dt = self._registrant.getCheckoutAttemptDt()
         checkout_attempt_delta = int(math.ceil((datetime.now() - checkout_attempt_dt).total_seconds() / 60))
     event = self._conf
     amount = self._registrant.getTotal()
     currency = event_settings.get(event, 'currency')
     plugins = get_active_payment_plugins(event)
     force_plugin = plugins.items()[0] if len(plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template('event_checkout.html', event, event=event, registrant=self._registrant,
                                           plugins=plugins.items(), force_plugin=force_plugin, amount=amount,
                                           currency=currency, checkout_attempt_delta=checkout_attempt_delta,
                                           registrant_params=get_registrant_params())
예제 #8
0
    def _check_currencies(self, form):
        """Checks if the currencies are valid.

        :return: `(auto_currency, invalid_currency)` - tuple containing the currency that should
                 be automatically set on the event and a flag if the currency issues cannot be resolved
                 automatically and require user interaction (i.e. saving the plugin settings is disallowed)
        """
        messages = []
        event = self._conf
        valid_currencies = self.plugin.valid_currencies
        currency = event_settings.get(event, 'currency')
        if valid_currencies is None or currency in valid_currencies:
            return None, False, messages

        if len(valid_currencies) == 1:
            auto_currency = list(valid_currencies)[0]
            for plugin in get_active_payment_plugins(event).itervalues():
                if plugin.valid_currencies is not None and auto_currency not in plugin.valid_currencies:
                    messages.append((
                        'error',
                        _("This payment method only supports {}, but the payment method "
                          "'{}' doesn't.").format(auto_currency,
                                                  plugin.title)))
                    return None, True, messages
            if not form.is_submitted():
                messages.append((
                    'warning',
                    _("This payment method only supports {0}. Enabling it will automatically "
                      "change the currency of the event to {0}!").format(
                          auto_currency)))
            return auto_currency, False, messages

        if not form.is_submitted():
            messages.append((
                'error',
                _("To enable this payment method, please use one of the following "
                  "currencies: {}").format(', '.join(valid_currencies))))
        return None, True, messages
예제 #9
0
 def _checkParams(self, params):
     RHRegistrationFormRegistrantBase._checkParams(self, params)
     try:
         self.plugin = get_active_payment_plugins(self._conf)[request.args['method']]
     except KeyError:
         raise NotFound