Multi-broker payment processor for Django.
Project description
Welcome to django-getpaid
django-getpaid is payment processing framework for Django
Documentation
The full documentation is at https://django-getpaid.readthedocs.io.
Features
support for multiple payment brokers at the same time
very 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)
support for global and per-plugin validators
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-payu
Add them to your INSTALLED_APPS:
INSTALLED_APPS = [
...
'getpaid',
'getpaid_payu', # one of plugins
...
]
Add getpaid to URL patterns:
urlpatterns = [
...
path('payments/', include('getpaid.urls')),
...
]
Define an Order model by subclassing getpaid.models.AbstractOrder and define some required 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_buyer_info(self):
return {"email": self.buyer.email}
def get_currency(self):
return "EUR"
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_payu": {
# take these from your merchant panel:
"pos_id": 12345,
"second_key": "91ae651578c5b5aa93f2d38a9be8ce11",
"oauth_id": 12345,
"oauth_secret": "12f071174cb7eb79d4aac5bc2f07563f",
},
}
Write a view that will create the Payment.
An example view and its hookup to urls.py can look like this:
# orders/views.py
from getpaid.forms import PaymentMethodForm
class OrderView(DetailView):
model = Order
def get_context_data(self, **kwargs):
context = super(OrderView, self).get_context_data(**kwargs)
context["payment_form"] = PaymentMethodForm(
initial={"order": self.object, "currency": self.object.currency}
)
return context
# main urls.py
urlpatterns = [
# ...
path("order/<int:pk>/", OrderView.as_view(), name="order_detail"),
]
You’ll also need a template (order_detail.html in this case) for this view. Here’s the important part:
<h2>Choose payment broker:</h2>
<form action="{% url 'getpaid:create-payment' %}" method="post">
{% csrf_token %}
{{ payment_form.as_p }}
<input type="submit" value="Checkout">
</form>
Running Tests
poetry install
poetry run tox
Alternatives
Credits
Created by Krzysztof Dorosz. Redesigned and rewritten by Dominik Kozaczko.
Development of version 2.0 sponsored by SUNSCRAPERS
Disclaimer
This project has nothing in common with getpaid plone project.
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
Built Distribution
File details
Details for the file django-getpaid-2.3.0.tar.gz
.
File metadata
- Download URL: django-getpaid-2.3.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.11.22-2-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b960560b9e21aa1953a6de011e9c1dbe6e72dc7b80c5c49053deca6c4b339a8 |
|
MD5 | e99f2afdc3e349cfb16815b45b4d50b7 |
|
BLAKE2b-256 | 9356e24a19aaa22e9be8515aae9df4504d043592e92892b41b0f4d73e30117b4 |
File details
Details for the file django_getpaid-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: django_getpaid-2.3.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.11.22-2-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3ae2fe744590317c1b6818fdf3b3519b028a85b72db0b776d35a5fca580f7c1 |
|
MD5 | 60956362d5928ae9b6ef1fb4fa528d42 |
|
BLAKE2b-256 | e63982a2dc4315f1c7637ee2019be6c7cc6d973db8b8b51b4ef2d25e7d2210c6 |