debits.debits_test package

Submodules

debits.debits_test.business module

debits.debits_test.business.create_organization(name, pricing_plan_id, trial_months)[source]

Creates a new example organization.

It also associates a MyPurchase with it.

debits.debits_test.callbacks module

class debits.debits_test.callbacks.MyPayPalIPN(**kwargs)[source]

Bases: debits.paypal.views.PayPalIPN

Mixin to handle purchase events.

Two subscription IPNs may call both on_subscription_created() and on_payment(). It is not a problem (if not to count a tiny performance lag).

TODO: Generalize it for non PayPal processors.

do_purchase(purchase)[source]

Set the MyPurchase for an Organization.

on_payment(payment)[source]

Called on any payment (subscription or regular).

on_subscription_created(POST, purchase)[source]

Called when a subscription is created.

debits.debits_test.forms module

class debits.debits_test.forms.CreateOrganizationForm(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

Django form to create a new example organization.

base_fields = {'name': <django.forms.fields.CharField object>, 'pricing_plan': <django.forms.models.ModelChoiceField object>, 'use_trial': <django.forms.fields.BooleanField object>}
declared_fields = {'name': <django.forms.fields.CharField object>, 'pricing_plan': <django.forms.models.ModelChoiceField object>, 'use_trial': <django.forms.fields.BooleanField object>}
media
class debits.debits_test.forms.SwitchPricingPlanForm(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

Django form to switch pricing plan.

base_fields = {'pricing_plan': <django.forms.models.ModelChoiceField object>}
declared_fields = {'pricing_plan': <django.forms.models.ModelChoiceField object>}
media

debits.debits_test.models module

class debits.debits_test.models.MyPurchase(*args, **kwargs)[source]

Bases: debits.debits_base.models.SubscriptionPurchase

An example purchase.

exception DoesNotExist

Bases: debits.debits_base.models.DoesNotExist

exception MultipleObjectsReturned

Bases: debits.debits_base.models.MultipleObjectsReturned

for_organization

The organization for which the purchase was initiated.

Don’t mess for_organization with organization!

for_organization_id
organization

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.

plan

The pricing plan for the purchase.

plan_id
subscriptionpurchase_ptr

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

In the example:

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

Restaurant.place is a ForwardOneToOneDescriptor instance.

subscriptionpurchase_ptr_id
class debits.debits_test.models.Organization(*args, **kwargs)[source]

Bases: django.db.models.base.Model

An example organization.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

for_purchase

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.

id

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

name

Organization name.

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

The current active MyPurchase for the organization.

purchase_id
class debits.debits_test.models.PricingPlan(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Pricing plan (like “Item 1”, $10/month).

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

currency

The currency of payments.

id

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

mypurchase_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.

name

Pricing plan name.

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

Recurring payments period.

period_count

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

period_unit

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

price

The price of each recurring payment.

product

Sold product.

product_id

debits.debits_test.processors module

class debits.debits_test.processors.MyPayPalForm(request)[source]

Bases: debits.paypal.form.PayPalForm

A mixin result.

classmethod ipn_name()[source]

Django view name for PayPal IPN.

product_name(purchase)[source]

What “product” PayPal shows for the purchase.

debits.debits_test.products module

debits.debits_test.test_settings module

debits.debits_test.urls module

debits.debits_test.views module

debits.debits_test.views.create_organization_view(request)[source]

The view to create an example organization.

debits.debits_test.views.do_organization_payment_view(request, purchase, organization)[source]

The common pars of views for transaction_payment_view() and organization_payment_view().

debits.debits_test.views.do_prolong(hash, form, processor, purchase)[source]

Start prolonging our subscription purchase.

debits.debits_test.views.do_subscribe(hash, form, processor, purchase)[source]

Start subscription to our subscription purchase.

debits.debits_test.views.do_unsubscribe(purchase)[source]
debits.debits_test.views.do_upgrade(hash, form, processor, purchase, organization)[source]

Start upgrading a subscription purchase,

debits.debits_test.views.get_processor(request, hash)[source]

Determine the payment processor, from a form.

debits.debits_test.views.list_organizations_view(request)[source]

Django view to list all the organizations.

debits.debits_test.views.organization_payment_view(request, organization_id)[source]

A view initiated for an organization.

debits.debits_test.views.purchase_view(request)[source]

The main test view to make purchases, subscriptions, upgrades.

debits.debits_test.views.transaction_payment_view(request, transaction_id)[source]

A view initiated from a transaction.

debits.debits_test.views.unsubscribe_organization_view(request, organization_pk)[source]

Django view for the “Unsubscribe” button.

debits.debits_test.views.upgrade_calculate_new_period(k, purchase)[source]

New period (in days) after an upgrade.

debits.debits_test.views.upgrade_create_new_item(old_purchase, plan, new_period, organization)[source]

Create new purchase used to upgrade another purchase (old_purchase).

debits.debits_test.wsgi module

WSGI config for django-debits project.

It exposes the WSGI callable as a module-level variable named application.

For more information on this file, see https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/

Module contents