No project description provided
Project description
django_tbank_kassa
django_tbank_kassa is a Django library for integrating with Tinkoff Bank's payment system. It simplifies the process of managing payments by providing tools to handle payments and webhooks with minimal setup.
Features
- Easy integration with Tinkoff Bank's API.
- Handles payment creation and status updates.
- Provides built-in views and serializers for payments.
- Configurable via environment variables.
Installation
-
Install the package using pip:
pip install django_tbank_kassa
-
Add
django_tbank_kassato yourINSTALLED_APPSin the Django settings file:INSTALLED_APPS = [ # ... other apps ... 'django_tbank_kassa', ]
-
Add the following settings to your Django project:
TBANK_KASSA_TERMINAL_KEY = 'your_terminal_key' TBANK_KASSA_PASSWORD = 'your_password' TBANK_KASSA_TEST = True # Set to False for production
Usage
Configuration
Ensure the following settings are configured in your Django project:
TBANK_KASSA_TERMINAL_KEY: Your Tinkoff Bank terminal key.TBANK_KASSA_PASSWORD: Your Tinkoff Bank password.TBANK_KASSA_TEST: Set toTruefor testing mode orFalsefor production.
Payment Model
django_tbank_kassa provides a Payment model. Migrations will create the necessary database tables for storing payment details.
Run the migrations:
python manage.py migrate
Views
The library includes views for handling payment creation and retrieving payment details. Add the following to your urls.py:
from django.urls import path
from django_tbank_kassa.generics import ListCreatePaymentView, RetrievePaymentView, TBankWebhookView
urlpatterns = [
path('payments/', ListCreatePaymentView.as_view(), name='list_create_payment'),
path('payments/<str:id>/', RetrievePaymentView.as_view(), name='retrieve_payment'),
path('webhook/', TBankWebhookView.as_view(), name='webhook'),
]
Creating Payments
To create a new payment, send a POST request to the /payments/ endpoint with the following data:
id(string): A unique identifier for the payment.amount(decimal): The amount of the payment.
Example:
{
"id": "order123",
"amount": "1000.00"
}
The response will include the payment status, a payment ID, and a URL to complete the payment.
Handling Webhooks
Tinkoff Bank sends webhook events to notify about payment status changes. Configure the webhook URL (e.g., /webhook/) in your Tinkoff Bank account settings.
When a webhook is received, the library validates it and updates the corresponding payment status. You can customize the webhook handling by extending the TBankWebhookView and overriding its methods if necessary.
Example Project
Here is an example of integrating django_tbank_kassa into a Django project:
- Add the app and configure the settings as described above.
- Add the provided URLs to your
urls.py. - Use the
/payments/endpoint to create and manage payments. - Register the webhook URL with Tinkoff Bank.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tbank_kassa-0.1.1.tar.gz.
File metadata
- Download URL: django_tbank_kassa-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d7c3c185d00f16a600d84099b6742b7030ac249ab83239bfd5eafbf3e166b61
|
|
| MD5 |
1025d610e3419942351bb28b0beaf051
|
|
| BLAKE2b-256 |
c81f51c868696657ca4ebf8173b5a3e4faad0625cab8d8a6912e418649d9d492
|
File details
Details for the file django_tbank_kassa-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_tbank_kassa-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49222bff82a256977c2c8348ab0dd8d1901576c059c90ca8243a7e4891a73d59
|
|
| MD5 |
aeeda4735449df02c6635717f76ffec2
|
|
| BLAKE2b-256 |
7358c7771f896948578ae1a7b0822bb60a679af27c22e88a8fa853ed01ce7b09
|