Skip to content

thorgate/django-thorbanks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

64ab645 · Jan 3, 2024
Feb 4, 2020
Apr 12, 2023
Oct 19, 2023
Oct 19, 2023
Feb 4, 2020
Dec 23, 2015
Dec 23, 2015
Feb 4, 2020
Apr 12, 2023
Feb 4, 2020
Feb 18, 2021
Sep 26, 2023
Sep 27, 2023
Jan 3, 2024
Feb 18, 2021
Feb 5, 2020
Apr 12, 2023

Repository files navigation

django-thorbanks

Build Status Coverage Status PyPI release

Django app for integrating Estonian banklinks into your project.

Features

Bank Protocol Authentication Payment
Swedbank iPizza ✔️ ✔️
SEB iPizza ✔️ ✔️
Danske iPizza ✔️ ✔️
LHV iPizza ✔️ ✔️
Krediidipank iPizza ✔️ ✔️
Nordea iPizza ✔️ ✔️

Usage

1. Install it:

Pip:

pip install django-thorbanks

Pipenv:

pipenv install django-thorbanks

Poetry:

poetry add django-thorbanks

2. Add to installed apps

INSTALLED_APPS = (
    # Add the following apps:
    "thorbanks",
    "thorbanks_models",
)

3. Configure and create migrations:

With MANUAL_MODELS:

With default models:

Make django aware that thorbanks migrations are in your local apps folder via settings.MIGRATION_MODULES:

Note: Replace shop with the name of an existing app in your project.

# Tell django that thorbanks_models migrations are in shop app (in thorbanks_migrations module)
MIGRATION_MODULES = {"thorbanks_models": "shop.thorbanks_migrations"}

Now run makemigrations thorbanks_models and migrate management commands to create and apply the migrations.

4. Add settings.BANKLINKS

For a working example see the definitions in example/settings.py.

Note: You will need a public and private key for each bank integration. In case you don't have the public key, you can generate one out of a certificate by:

openssl x509 -pubkey -noout -in cert.pem  > pubkey.pem

5. Link Transaction to your Order model

Note: When using MANUAL_MODELS replace thorbanks_models with your local app name

class Order(models.Model):
    # ... other fields
    transaction = models.OneToOneField(
        "thorbanks_models.Transaction", null=True, on_delete=models.SET_NULL
    )

6. Include thorbanks urls

urlpatterns = [
    # This is where the user will be redirected after returning from the banklink page
    url(r"^banks/", include("thorbanks.urls")),
]

7. Add listeners to banklinks success & failure callbacks:

See example.shop.models.banklink_success_callback and example.shop.models.banklink_failed_callback.

8. Create views and forms for payments:

see example.shop.views and example.shop.forms.

iPizza protocol