mooch - Simple payment
Steps
Install django-mooch using pip and add mooch to your INSTALLED_APPS.
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() ]Include the moochers app / URLconf somewhere in your other URLconfs.
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() ], })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'])
Metadata
Release files for django-mooch 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_mooch-0.6.0.tar.gz | 10.2 kB | Without provenance | Details for django_mooch-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_mooch-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for django_mooch-0.6.0-py3-none-any.whl |
Total release size: 24.1 kB
Release files / django_mooch-0.6.0.tar.gz
| Download URL | django_mooch-0.6.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c2416ce1be3bb2fe902d388965d56ac670d59aaaa01d6ac51ab0ee6dbc0c650
|
|
BLAKE2b-256 checksum How to use checksums |
d22ba9c0e9c5e39d55679dca0fba2acc3f2e42bd8d1e9cd70fc88013fa58f770
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / django_mooch-0.6.0-py3-none-any.whl
| Download URL | django_mooch-0.6.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6dc7052b3e394110f3e93a7161630f6ad9ceee03307e54cd10f99ae892f99485
|
|
BLAKE2b-256 checksum How to use checksums |
216cb96f4c1caa351c3829b87575e0c95fc4f4a62afbe861e028d48b51440eaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for django-mooch 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.