Giter Club home page Giter Club logo

django-getpaid's Introduction

Latest PyPI version https://api.codacy.com/project/badge/Coverage/d25ba81e2e4740d6aac356f4ac90b16d https://api.codacy.com/project/badge/Grade/d25ba81e2e4740d6aac356f4ac90b16d

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

Note

If you already have an Order model and don't want to subclass AbstractOrder just make sure you implement all methods.

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.

Currently sponsored by ClearCode

Development of version 2.0 sponsored by SUNSCRAPERS

Disclaimer

This project has nothing in common with getpaid plone project.

django-getpaid's People

Contributors

cypreess avatar dekoza avatar pawciobiel avatar bernardopires avatar kglod avatar kamilglod avatar scotteadams avatar glowka avatar fizista avatar lukaszbanasiak avatar slafs avatar glothriel avatar asermax avatar ekohl avatar yomguy avatar lukasklein avatar anih avatar icha0s avatar sunu avatar piotrekio avatar pawelad avatar lauris avatar krzysiekj avatar pikulak avatar suprasummus avatar mfa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.