Simple payment for Django
Project description
Install django-mooch using pip and add mooch to your INSTALLED_APPS.
Add the following settings:
STRIPE_PUBLISHABLE_KEY = env('STRIPE_PUBLISHABLE_KEY') STRIPE_SECRET_KEY = env('STRIPE_SECRET_KEY') POSTFINANCE_PSPID = env('POSTFINANCE_PSPID') POSTFINANCE_LIVE = env('POSTFINANCE_LIVE') POSTFINANCE_SHA1_IN = env('POSTFINANCE_SHA1_IN') POSTFINANCE_SHA1_OUT = env('POSTFINANCE_SHA1_OUT')
Add a moochers app:
from django.conf.urls import include, url from mooch.postfinance import PostFinanceMoocher from mooch.stripe import StripeMoocher from myapp.models import Thing # Inherit mooch.models.Payment postfinance_moocher = PostFinanceMoocher(model=Thing) stripe_moocher = StripeMoocher(model=Thing) moochers = [postfinance_moocher, stripe_moocher] app_name = 'mooch' # This is important urlpatterns = [ url(r'^postfinance/', include(postfinance_moocher.urls)), url(r'^stripe/', include(stripe_moocher.urls)), ]
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 ], })
Maybe send a confirmation mail when charges happen (an example template for this is actually included with the project):
from mooch.mail import render_to_mail from mooch.signals import post_charge # The signal handler receives the moocher class, the payment and # the request. def send_mail(sender, payment, **kwargs): render_to_mail('mooch/thanks_mail', { 'payment': payment, }, to=[payment.email]).send(fail_silently=True) post_charge.connect(send_mail)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-mooch-0.1.0.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for django_mooch-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d18ac49ab3439ffa5c0f96ed24cd143a9a208a0c20b8bce951c82660b966141 |
|
MD5 | 84766ee61c45b4c2b5a7692f37fd428f |
|
BLAKE2b-256 | dbce17b55a42fe65fb5ea8159147499c0a5cc99d990488ca0d1049da982ac563 |