This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
  1. Install django-mooch using pip and add mooch to your INSTALLED_APPS.

  2. Add a moochers app:

    from collections import OrderedDict
    
    from django.conf import settings
    from django.conf.urls import include, url
    
    from mooch.banktransfer import BankTransferMoocher
    from mooch.postfinance import PostFinanceMoocher
    from mooch.stripe import StripeMoocher
    
    from myapp.models import Thing  # Inherit mooch.models.Payment
    
    
    app_name = 'mooch'  # This is the app namespace.
    
    moochers = OrderedDict((
        ('postfinance', PostFinanceMoocher(
            model=Thing,
            pspid='thing',
            live=False,
            sha1_in=settings.POSTFINANCE_SHA1_IN,
            sha1_out=settings.POSTFINANCE_SHA1_OUT,
            app_name=app_name,
        )),
        ('stripe', StripeMoocher(
            model=Thing,
            publishable_key=settings.STRIPE_PUBLISHABLE_KEY,
            secret_key=settings.STRIPE_SECRET_KEY,
            app_name=app_name,
        )),
        ('banktransfer', BankTransferMoocher(
            model=Thing,
            autocharge=True,  # Mark all payments as successful.
            app_name=app_name,
        )),
    ]
    
    urlpatterns = [
        url(r'', moocher.urls) for moocher in moochers.values()
    ]
    
  3. Include the moochers app / URLconf somewhere in your other URLconfs.

  4. Add a payment page:

    def pay(request, id):
        instance = get_object_or_404(Thing.objects.all(), id=id)
    
        return render(request, 'pay.html', {
            'thing': instance,
            'moochers': [
                moocher.payment_form(request, instance)
                for moocher in moochers.values()
            ],
        })
    
  5. Maybe send a confirmation mail when charges happen (an example template for this is actually included with the project). Please note that contrary to most other projects, django-mooch uses the moocher instance as sender, not the class:

    from mooch.mail import render_to_mail
    from mooch.signals import post_charge
    
    # The signal handler receives the moocher instance, the payment and
    # the request.
    def send_mail(sender, payment, request, **kwargs):
        render_to_mail('mooch/thanks_mail', {
            'payment': payment,
        }, to=[payment.email]).send(fail_silently=True)
    
    # Connect the signal to our moocher instances (moochers may be used
    more than once on the same website):
    for moocher in moochers.values():
        post_charge.connect(send_mail, sender=moocher)
    

    If you want to differentiate between moochers (for example to send a different mail for bank transfers, because the payment has not actually happened yet) set the sender argument when connecting as follows:

    # Some stuff you'll have to imagine... sorry.
    post_charge.connect(thank_you_mail, moochers['postfinance'])
    post_charge.connect(thank_you_mail, moochers['stripe'])
    post_charge.connect(please_pay_mail, moochers['banktransfer'])
    
Release History

Release History

0.4.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_mooch-0.4.1-py2.py3-none-any.whl (18.2 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Dec 2, 2016
django-mooch-0.4.1.tar.gz (12.7 kB) Copy SHA256 Checksum SHA256 Source Dec 2, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting