A simple django app to manage Satispay payments following the Web-button flow.
Project description
django-satispaython
A simple django app to manage Satispay payments following the Web-button flow.
Requirements
- python >= 3.6
- django >= 3
satispaython
>= 0.2
Installation
You can install this package with pip: pip install django-satispaython
.
Usage
Key generation and key-id
In order to use django-satispaython you need to generate a RSA private key and then get a key-id. Django-satispaython is based on satispaython so you can import it, create a key and obtain a key-id.
Configuration
Once you created a RSA key and got a key-id add django-satispaython to your INSTALLED_APPS:
INSTALLED_APPS = (
#...
'django_satispaython.apps.DjangoSatispaythonConfig',
#...
)
Then add the followings to you django settings:
SATISPAYTHON_PRIVATE_KEY_PATH = '/path/to/my/key.pem'
SATISPAYTHON_KEY_ID_PATH = '/path/to/my/key-id.txt'
SATISPAYTHON_STAGING = True
SATISPAYTHON_PRIVATE_KEY_PATH
: the path of your PEM file containing the RSA private key used to get your key-id.SATISPAYTHON_KEY_ID_PATH
: the path of the file containing the key-id coupled with the private-key.SATISPAYTHON_STAGING
: ifTrue
django-satispaython will use the Sandbox endpoints.
Satispay API
In order to use the Satispay API import django-satispaython.api:
from django_satispaython import api as satispay
Then you can:
Create a payment
satispay.create_payment(amount_unit, currency, callback_url, expiration_date=None, external_code=None, metadata=None, idempotency_key=None)
You may use satispaython utility function format_datetime
to get a correctly formatted expiration_date
to supply to the request.
Get payment details
satisapy.get_payment_details(payment_id)
Templatetags
In order to render the Satispay button just load the tag and use it in the template:
{% load django_satispaython %}
...
{% satispay_button payment_id=<your_payment_id> %}
Note that the button will automatically point at the endpoint (production or sandbox) specified in the project settings
.
Database and Admin
Django-satispaython comes with a SatispayPayment model which contains every info associated to a payment and is automatically showed in the admin page.
:information_source: All the Satispay API functions return an instance of the SatispayPayment model without actually storing it by default.
If you want to store a newly created payment in the database or update an already existing one with the informations provided by the response, set the update
parameter to True
.
satispay.create_payment(amount_unit, currency, callback_url, expiration_date=None, external_code=None, metadata=None, idempotency_key=None, update=True)
satisapy.get_payment_details(payment_id, update=True)
In this case an output similar to django's update_or_create
will be returned.
TODOS
- Signals
- ImproperlyConfiguredException
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
Built Distribution
Hashes for django-satispaython-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 670e47ba0f16a225f4d2874233e6cc34545ea0f9cee350262500af6d68b007f7 |
|
MD5 | 89363f9af0f8d8ac1029a4f6bce27265 |
|
BLAKE2b-256 | 541658f13a94709a18ebf6bea4f85150985488728e40f98f22d6ec40ebe5a27d |
Hashes for django_satispaython-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b1a32f79c57eb435e56940d864d7c1f7a2c17d07f67d662513f7921195f3cd1 |
|
MD5 | 58fced69378b7227f6f77b7d700947fe |
|
BLAKE2b-256 | c55455f87e0dc3991056152212f5dc1883010810779d9d7ab24eefc806d2d3fc |