Skip to main content

Multi-broker payment processor for Django.

Project description

Latest PyPI version https://img.shields.io/travis/sunscrapers/django-getpaid.svg https://img.shields.io/coveralls/github/cypreess/django-getpaid.svg https://img.shields.io/pypi/wheel/django-getpaid.svg https://img.shields.io/pypi/l/django-getpaid.svg

django-getpaid is a multi-broker payment processor for Django

Documentation

The full documentation is at https://django-getpaid.readthedocs.io.

Features

  • support for multiple payment brokers at the same time

  • clean but flexible architecture

  • support for asynchronous status updates - both push and pull

  • support for modern REST-based broker APIs

  • support for multiple currencies (but one per payment)

  • easy customization with provided base abstract models and swappable mechanic (same as with Django’s User model)

Quickstart

Install django-getpaid and at least one payment backend:

pip install django-getpaid
pip install django-getpaid-paynow

Add them to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'getpaid',
    'getpaid_paynow',  # one of plugins
    ...
]

Add getpaid to URL patterns:

urlpatterns = [
    ...
    path('payments/', include('getpaid.urls')),
    ...
]

Use getpaid.models.AbstractOrder as parent class of your Order model and define minimal set of methods:

from getpaid.models import AbstractOrder

class MyCustomOrder(AbstractOrder):
    amount = models.DecimalField(decimal_places=2, max_digits=8)
    description = models.CharField(max_length=128)
    buyer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

    def get_absolute_url(self):
        return reverse('order-detail', kwargs={"pk": self.pk})

    def get_total_amount(self):
        return self.amount

    def get_user_info(self):
        return {"email": self.buyer.email}

    def get_description(self):
        return self.description

Inform getpaid of your Order model in settings.py and provide settings for payment backends:

GETPAID_ORDER_MODEL = 'yourapp.MyCustomOrder'

GETPAID_BACKEND_SETTINGS = {
    'getpaid_paynow': {   # dotted import path of the plugin
        # refer to backend docs for its real settings
        "api_key": "9bcdead5-b194-4eb5-a1d5-c1654572e624",
        "signature_key": "54d22fdb-2a8b-4711-a2e9-0e69a2a91189",
    },
}

And… provide some business logic ;)

Your pre-payment view should use getpaid.forms.PaymentMethodForm bound with payment data. During binding the form will generate a list of plugins (payment methods) supporting your currency and hide rest of the fields. Then this form should be POSTed to {% url 'getpaid:create-payment' %} to create new payment. You should be automatically redirected to paywall. After payment you should by default return to order-detail page but this behavior can be changed by plugin’s config.

Running Tests

Does the code actually work?

poetry install
poetry run tox

Credits

Created by Krzysztof Dorosz. Redesigned and rewritten by Dominik Kozaczko.

Proudly sponsored by SUNSCRAPERS

Tools used in rendering this package:

Disclaimer

This project has nothing in common with getpaid plone project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-getpaid-2.0.0rc6.tar.gz (18.2 kB view hashes)

Uploaded Source

Built Distribution

django_getpaid-2.0.0rc6-py3-none-any.whl (21.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page