payments package

Submodules

payments.admin module

Registers admin interfaces for the payments module.

class payments.admin.BankAccountAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Manage bank accounts.

actions = ['set_last_used']
autocomplete_fields = ('owner',)
export_csv(request: django.http.request.HttpRequest, queryset: django.db.models.query.QuerySet) → django.http.response.HttpResponse[source]
fields = ('created_at', 'last_used', 'owner', 'iban', 'bic', 'initials', 'last_name', 'mandate_no', 'valid_from', 'valid_until', 'signature', 'can_be_revoked')
form

alias of payments.forms.BankAccountAdminForm

list_display = ('iban', 'owner_link', 'last_used', 'valid_from', 'valid_until')
list_filter = (<class 'payments.admin.ValidAccountFilter'>, 'owner__profile__auto_renew')
property media
readonly_fields = ('created_at', 'can_be_revoked')
search_fields = ('owner__username', 'owner__first_name', 'owner__last_name', 'iban')
set_last_used(request: django.http.request.HttpRequest, queryset: django.db.models.query.QuerySet)None[source]

Set the last used date of selected accounts.

class payments.admin.BankAccountInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

can_delete = False
fields = ('iban', 'bic', 'mandate_no', 'valid_from', 'valid_until', 'last_used')
has_add_permission(request, obj=None)[source]

Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.

has_change_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.

property media
model

alias of payments.models.BankAccount

class payments.admin.BatchAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Manage payment batches.

changeform_view(request: django.http.request.HttpRequest, object_id: Optional[str] = None, form_url: str = '', extra_context: Optional[dict] = None) → django.http.response.HttpResponse[source]

Render the change formview.

Only allow when the batch has not been processed yet.

fields = ('id', 'description', 'withdrawal_date', 'processed', 'processing_date', 'total_amount')
get_readonly_fields(request: django.http.request.HttpRequest, obj: Optional[payments.models.Batch] = None)[source]

Hook for specifying custom readonly fields.

get_urls()list[source]
has_delete_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.

inlines = (<class 'payments.admin.PaymentsInline'>,)
list_display = ('id', 'description', 'withdrawal_date', 'start_date', 'end_date', 'total_amount', 'payments_count', 'processing_date', 'processed')
property media
save_formset(request, form, formset, change)[source]

Given an inline formset save it to the database.

search_fields = ('id', 'description', 'withdrawal_date')
class payments.admin.PaymentAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Manage the payments.

actions = ['add_to_new_batch', 'add_to_last_batch', 'export_csv']
add_to_last_batch(request: django.http.request.HttpRequest, queryset: django.db.models.query.QuerySet)None[source]

Add selected TPAY payments to the last batch.

add_to_new_batch(request: django.http.request.HttpRequest, queryset: django.db.models.query.QuerySet)None[source]

Add selected TPAY payments to a new batch.

autocomplete_fields = ('paid_by', 'processed_by')
date_hierarchy = 'created_at'
export_csv(request: django.http.request.HttpRequest, queryset: django.db.models.query.QuerySet) → django.http.response.HttpResponse[source]

Export a CSV of payments.

Parameters
  • request – Request

  • queryset – Items to be exported

fields = ('created_at', 'amount', 'type', 'paid_by', 'processed_by', 'topic', 'notes', 'batch')
get_actions(request: django.http.request.HttpRequest)collections.OrderedDict[source]

Get the actions for the payments.

Hide the processing actions if the right permissions are missing

get_field_queryset(db, db_field, request)[source]

If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don’t specify the queryset, let the field decide (return None in that case).

get_readonly_fields(request: django.http.request.HttpRequest, obj: Optional[payments.models.Payment] = None)[source]

Hook for specifying custom readonly fields.

get_urls()list[source]
has_delete_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.

list_display = ('created_at', 'amount', 'type', 'paid_by_link', 'processed_by_link', 'batch_link', 'topic')
list_filter = ('type', 'batch')
property media
ordering = ('-created_at',)
readonly_fields = ('created_at', 'amount', 'paid_by', 'processed_by', 'type', 'topic', 'notes', 'batch')
search_fields = ('topic', 'notes', 'paid_by__username', 'paid_by__first_name', 'paid_by__last_name', 'processed_by__username', 'processed_by__first_name', 'processed_by__last_name', 'amount')
class payments.admin.PaymentInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

can_delete = False
fields = ('created_at', 'type', 'amount', 'topic', 'notes', 'batch')
has_add_permission(request, obj=None)[source]

Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.

has_change_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.

property media
model

alias of payments.models.Payment

class payments.admin.PaymentUserAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

actions = ['disallow_thalia_pay', 'allow_thalia_pay']
allow_thalia_pay(request, queryset)[source]

Disallow Thalia Pay for selected users.

disallow_thalia_pay(request, queryset)[source]
fields = ('user_link', 'get_tpay_allowed', 'get_tpay_enabled', 'get_tpay_balance')
get_tpay_allowed(obj)[source]
get_tpay_balance(obj)[source]
get_tpay_enabled(obj)[source]
has_add_permission(request, obj=None)[source]

Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.

has_change_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.

has_delete_permission(request, obj=None)[source]

Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.

Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.

inlines = [<class 'payments.admin.BankAccountInline'>, <class 'payments.admin.PaymentInline'>]
list_display = ('__str__', 'email', 'get_tpay_allowed', 'get_tpay_enabled', 'get_tpay_balance')
list_filter = [<class 'payments.admin.ThaliaPayAllowedFilter'>, <class 'payments.admin.ThaliaPayEnabledFilter'>, <class 'payments.admin.ThaliaPayBalanceFilter'>]
property media
readonly_fields = ('user_link', 'get_tpay_allowed', 'get_tpay_enabled', 'get_tpay_balance')
search_fields = ('first_name', 'last_name', 'username', 'email')
class payments.admin.PaymentsInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

The inline for payments in the Batch admin.

can_delete = False
extra = 0
form

alias of payments.forms.BatchPaymentInlineAdminForm

get_fields(request, obj=None)[source]

Hook for specifying fields.

max_num = 0
property media
model

alias of payments.models.Payment

readonly_fields = ('topic', 'paid_by', 'amount', 'created_at', 'notes')
class payments.admin.ThaliaPayAllowedFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]

Must be overridden to return a list of tuples (value, verbose value)

parameter_name = 'tpay_allowed'
queryset(request, queryset)[source]

Return the filtered queryset.

title = 'Thalia Pay allowed'
class payments.admin.ThaliaPayBalanceFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]

Must be overridden to return a list of tuples (value, verbose value)

parameter_name = 'tpay_balance'
queryset(request, queryset)[source]

Return the filtered queryset.

title = 'Thalia Pay balance'
class payments.admin.ThaliaPayEnabledFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]

Must be overridden to return a list of tuples (value, verbose value)

parameter_name = 'tpay_enabled'
queryset(request, queryset)[source]

Return the filtered queryset.

title = 'Thalia Pay enabled'
class payments.admin.ValidAccountFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

Filter the memberships by whether they are active or not.

lookups(request, model_name)tuple[source]

Must be overridden to return a list of tuples (value, verbose value)

parameter_name = 'active'
queryset(request, queryset)django.db.models.query.QuerySet[source]

Return the filtered queryset.

title = 'mandates'

payments.admin_views module

Admin views provided by the payments package.

class payments.admin_views.BatchExportAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

View that exports a batch.

dispatch(request, *args, **kwargs)
post(request, *args, **kwargs)[source]
class payments.admin_views.BatchNewFilledAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

View that adds a new batch filled with all payments that where not already in a batch.

dispatch(request, *args, **kwargs)
get(request, *args, **kwargs)[source]
class payments.admin_views.BatchProcessAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

View that processes a batch.

dispatch(request, *args, **kwargs)
post(request, *args, **kwargs)[source]
class payments.admin_views.BatchTopicDescriptionAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

Shows the topic export as plain text.

dispatch(request, *args, **kwargs)
post(request, *args, **kwargs)[source]
template_name = 'admin/payments/batch_topic.html'
class payments.admin_views.BatchTopicExportAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

View that exports a batch per topic.

dispatch(request, *args, **kwargs)
post(request, *args, **kwargs)[source]
class payments.admin_views.PaymentAdminView(**kwargs)[source]

Bases: django.views.generic.base.View

View that creates a payment.

dispatch(request, *args, **kwargs)
post(request, *args, app_label, model_name, payable, **kwargs)[source]

payments.apps module

Configuration for the payments package.

class payments.apps.PaymentsConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

AppConfig for the payments package.

name = 'payments'
ready()[source]

Import the signals when the app is ready.

verbose_name = 'Payments'

payments.exceptions module

exception payments.exceptions.PaymentError[source]

Bases: Exception

Custom error for problems during payment.

payments.forms module

class payments.forms.BankAccountAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

Custom admin form for BankAccount model to add the widget for the signature.

class Meta[source]

Bases: object

fields = '__all__'
model

alias of payments.models.BankAccount

widgets = {'signature': <payments.widgets.SignatureWidget object>}
base_fields = {'bic': <localflavor.generic.forms.BICFormField object>, 'created_at': <django.forms.fields.DateTimeField object>, 'iban': <localflavor.generic.forms.IBANFormField object>, 'initials': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'last_used': <django.forms.fields.DateField object>, 'mandate_no': <django.forms.fields.CharField object>, 'owner': <django.forms.models.ModelChoiceField object>, 'signature': <django.forms.fields.CharField object>, 'valid_from': <django.forms.fields.DateField object>, 'valid_until': <django.forms.fields.DateField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class payments.forms.BankAccountForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

Custom admin form for BankAccount model to add the widget for the signature.

class Meta[source]

Bases: object

fields = ('initials', 'last_name', 'iban', 'bic', 'signature', 'valid_from', 'mandate_no', 'owner')
model

alias of payments.models.BankAccount

base_fields = {'bic': <localflavor.generic.forms.BICFormField object>, 'direct_debit': <django.forms.fields.BooleanField object>, 'iban': <localflavor.generic.forms.IBANFormField object>, 'initials': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'mandate_no': <django.forms.fields.CharField object>, 'owner': <django.forms.models.ModelChoiceField object>, 'signature': <django.forms.fields.CharField object>, 'valid_from': <django.forms.fields.DateField object>}
declared_fields = {'direct_debit': <django.forms.fields.BooleanField object>}
property media

Return all media required to render the widgets on this form.

class payments.forms.BankAccountUserRevokeForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

Custom form for members to revoke their bank account.

class Meta[source]

Bases: object

fields = ('valid_until',)
model

alias of payments.models.BankAccount

base_fields = {'valid_until': <django.forms.fields.DateField object>}
declared_fields = {}
is_valid()[source]

Return True if the form has no errors, or False otherwise.

property media

Return all media required to render the widgets on this form.

class payments.forms.BatchPaymentInlineAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

Custom admin form for Payments model for the Batch inlines to add remove from batch option.

class Meta[source]

Bases: object

fields = ('topic', 'paid_by', 'amount', 'created_at', 'notes')
model

alias of payments.models.Payment

base_fields = {'amount': <django.forms.fields.DecimalField object>, 'created_at': <django.forms.fields.DateTimeField object>, 'notes': <django.forms.fields.CharField object>, 'paid_by': <django.forms.models.ModelChoiceField object>, 'remove_batch': <django.forms.fields.BooleanField object>, 'topic': <django.forms.fields.CharField object>}
declared_fields = {'remove_batch': <django.forms.fields.BooleanField object>}
property media

Return all media required to render the widgets on this form.

class payments.forms.PaymentCreateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

Custom form to create a payment by a user.

class Meta[source]

Bases: object

fields = '__all__'
base_fields = {'app_label': <django.forms.fields.CharField object>, 'model_name': <django.forms.fields.CharField object>, 'next': <django.forms.fields.CharField object>, 'payable': <django.forms.fields.CharField object>}
declared_fields = {'app_label': <django.forms.fields.CharField object>, 'model_name': <django.forms.fields.CharField object>, 'next': <django.forms.fields.CharField object>, 'payable': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

payments.models module

The models defined by the payments package.

class payments.models.BankAccount(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes a bank account.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

bic

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property can_be_revoked
clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
iban

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

initials

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_used

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

mandate_no

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property name
objects = <django.db.models.manager.Manager object>
owner

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

owner_id
signature

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property valid
valid_from

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

valid_until

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class payments.models.Batch(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes a batch of payments for export.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

end_date()datetime.datetime[source]
get_absolute_url()[source]
get_next_by_withdrawal_date(*, field=<django.db.models.fields.DateField: withdrawal_date>, is_next=True, **kwargs)
get_previous_by_withdrawal_date(*, field=<django.db.models.fields.DateField: withdrawal_date>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
payments_count()decimal.Decimal[source]
payments_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

processed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

processing_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

save(force_insert=False, force_update=False, using=None, update_fields=None)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

start_date()datetime.datetime[source]
total_amount()decimal.Decimal[source]
withdrawal_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class payments.models.Payable[source]

Bases: object

payment = None
property payment_amount
property payment_notes
property payment_payer
property payment_topic
pk = None
save()[source]
class payments.models.Payment(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes a payment.

CARD = 'card_payment'
CASH = 'cash_payment'
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

PAYMENT_TYPE = (('cash_payment', 'Cash payment'), ('card_payment', 'Card payment'), ('tpay_payment', 'Thalia Pay payment'), ('wire_payment', 'Wire payment'))
TPAY = 'tpay_payment'
WIRE = 'wire_payment'
amount

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

batch

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

batch_id
clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

events_registration

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

get_admin_url()[source]
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_type_display(*, field=<django.db.models.fields.CharField: type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

notes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
paid_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

paid_by_id
pizzas_order

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

processed_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

processed_by_id
registrations_entry

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

save(**kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

topic

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class payments.models.PaymentUser(id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined)[source]

Bases: members.models.member.Member

exception DoesNotExist

Bases: members.models.member.Member.DoesNotExist

exception MultipleObjectsReturned

Bases: members.models.member.Member.MultipleObjectsReturned

allow_tpay()[source]

Give this user Thalia Pay permission.

disallow_tpay()[source]

Revoke this user’s Thalia Pay permission.

property tpay_allowed

Check if this user has permissions to use Thalia Pay (but not necessarily enabled).

property tpay_balance

Check the Thalia Pay balance for a user.

property tpay_enabled

Check if this user has a bank account with Direct Debit enabled.

payments.services module

The services defined by the payments package.

payments.services.create_payment(payable: payments.models.Payable, processed_by: members.models.member.Member, pay_type: Union[cash_payment, card_payment, wire_payment, tpay_payment])payments.models.Payment[source]

Create a new payment from a payable object.

Parameters
  • payable – Payable object

  • processed_by – PaymentUser that processed this payment

  • pay_type – Payment type

Returns

Payment object

payments.services.delete_payment(payable: payments.models.Payable)[source]

Remove a payment from a payable object.

Parameters

payable – Payable object

Returns

payments.services.process_batch(batch)[source]

Process a Thalia Pay batch.

Parameters

batch – the batch to be processed

Returns

payments.services.revoke_old_mandates()int[source]

Revoke all mandates that have not been used for 36 months or more.

Returns

number of affected rows

payments.services.send_tpay_batch_processing_emails(batch)[source]

Send withdrawal notice emails to all members in a batch.

payments.services.update_last_used(queryset: django.db.models.query.QuerySet, date: Optional[datetime.date] = None)int[source]

Update the last used field of a BankAccount queryset.

Parameters
  • queryset – Queryset of BankAccounts

  • date – date to set last_used to

Returns

number of affected rows

payments.signals module

payments.signals.give_new_users_tpay_permissions(instance, created, **kwargs)[source]

If a new user is created, give this user Thalia Pay permissions.

payments.urls module

payments.views module

class payments.views.BankAccountCreateView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.CreateView

dispatch(request, *args, **kwargs)
form_class

alias of payments.forms.BankAccountForm

form_valid(form: payments.forms.BankAccountForm) → django.http.response.HttpResponse[source]

If the form is valid, save the associated model.

get_context_data(**kwargs)dict[source]

Insert the form into the context dict.

model

alias of payments.models.BankAccount

post(request, *args, **kwargs) → django.http.response.HttpResponse[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

success_message = 'Bank account saved successfully.'
success_url = '/user/finance/accounts/'
class payments.views.BankAccountListView(**kwargs)[source]

Bases: django.views.generic.list.ListView

dispatch(request, *args, **kwargs)
get_context_data(*args, **kwargs)[source]

Get the context for this view.

get_queryset()django.db.models.query.QuerySet[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

model

alias of payments.models.BankAccount

class payments.views.BankAccountRevokeView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.UpdateView

dispatch(request, *args, **kwargs)
form_class

alias of payments.forms.BankAccountUserRevokeForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

get(*args, **kwargs) → django.http.response.HttpResponse[source]

Handle GET requests: instantiate a blank version of the form.

get_queryset()django.db.models.query.QuerySet[source]

Return the QuerySet that will be used to look up the object.

This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.

model

alias of payments.models.BankAccount

post(request, *args, **kwargs) → django.http.response.HttpResponse[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

success_message = 'Direct debit authorisation successfully revoked.'
success_url = '/user/finance/accounts/'
class payments.views.PaymentListView(**kwargs)[source]

Bases: django.views.generic.list.ListView

dispatch(request, *args, **kwargs)
get_context_data(*args, **kwargs)[source]

Get the context for this view.

get_queryset()django.db.models.query.QuerySet[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

model

alias of payments.models.Payment

class payments.views.PaymentProcessView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.FormView

Defines a view that allows the user to add a Thalia Pay payment to a Payable object using a POST request.

The user should be authenticated.

dispatch(request, *args, **kwargs)[source]
form_class

alias of payments.forms.PaymentCreateForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

payable = None
post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

success_message = 'Your payment has been processed successfully.'
template_name = 'payments/payment_form.html'

payments.widgets module

Widgets provided by the payments package.

class payments.widgets.PaymentWidget(attrs=None, obj=None)[source]

Bases: django.forms.widgets.Widget

Custom widget for the Payment object, used in registrations.

class Media[source]

Bases: object

js = ('admin/payments/js/payments.js',)
get_context(name, value, attrs)dict[source]
property media
template_name = 'payments/widgets/payment.html'
class payments.widgets.SignatureWidget(attrs=None)[source]

Bases: django.forms.widgets.Widget

Widget for signature image.

class Media[source]

Bases: object

css = {'all': ('admin/payments/css/signature.css',)}
js = ('payments/js/signature_pad.min.js', 'payments/js/main.js')
property media
template_name = 'payments/widgets/signature.html'