epay-gateway-django
Chargily ePay Gateway (Django Package)
Documentation
you can find more about Here
This Plugin is to integrate ePayment gateway with Chargily easily.
- Currently support payment by CIB / EDAHABIA cards and soon by Visa / Mastercard
- This repo is recently created for Django plugin, If you are a developer and want to collaborate to the development of this plugin, you are welcomed!
Installation
pip install chargily-epay-Django
Create Payment model
to create a payment model you need to extend one of the following classes AbstractPayment, AnonymPayment, AnonymPayment.
from chargily_epay_django.models import AnonymPayment
class Payment(AnonymPayment):
webhook_url = 'payment-confirmation' # reverse url
back_url = 'payment-status' # reverse url
CreatePaymentView
you can create a new Payment using CreatePaymentView, this class extends from CreateView
# views.py
from django.forms import ModelForm
from chargily_epay_django.views import CreatePaymentView
from my_app.models import Payment
class PaymentForm(ModelForm):
class Meta:
model = Payment
fields = ['client', 'client_email', 'amount', 'mode', 'comment']
class CreatePayment(CreatePaymentView):
template_name: str = "payment/payment-template.html"
form_class = PaymentForm
Example
PaymentConfirmationView
if you want to confirme payment you can use PaymentConfirmationView view, this view responsable for reciving payment confirmation from third party.
# views.py
# .....
from chargily_epay_django.views import CreatePaymentView, PaymentConfirmationView
# .....
class PaymentConfirmation(PaymentConfirmationView):
model = Payment
PaymentObjectStatusView, Or PaymentObjectDoneView
to check payment status you can use PaymentObjectStatusView, Or PaymentObjectDoneView check the doc to see dirence
# views.py
# .....
from chargily_epay_django.views import CreatePaymentView, PaymentConfirmationView, PaymentObjectDoneView
# .....
class PaymentStatus(PaymentObjectDoneView):
template_name: str = "payment/payment-status.html"
model = Payment
Example
FakePayment
if you are working in Devlopment mode you can use FakePaymentView all you need to do is to create a view and extend this class and add FakePaymentMixin , to Payment model
# models.py
from chargily_epay_django.models import AnonymPayment, FakePaymentMixin
class Payment(FakePaymentMixin,AnonymPayment):
webhook_url = 'payment-confirmation' # reverse url
back_url = 'payment-status' # reverse url
fake_payment_url = "fake-payment" # reverse url
# view
from chargily_epay_django.views import (
CreatePaymentView,
PaymentConfirmationView,
PaymentObjectDoneView,
FakePaymentView
)
class FakePayment(FakePaymentView):
model = Payment
Example
Result
we now can CREATE, UPDATE and READ payment using this few lines of code.
Note: you still have to configure settings, and urls.py
# models.py
from chargily_epay_django.models import AnonymPayment, FakePaymentMixin
class Payment(FakePaymentMixin,AnonymPayment):
webhook_url = 'payment-confirmation' # reverse url
back_url = 'payment-status' # reverse url
fake_payment_url = "fake-payment" # reverse url
# views.py
from django.forms import ModelForm
from chargily_epay_django.views import (
CreatePaymentView,
PaymentConfirmationView,
PaymentObjectDoneView,
FakePaymentView
)
from my_app.models import Payment
# FORM
class PaymentForm(ModelForm):
class Meta:
model = Payment
fields = ['client', 'client_email', 'amount', 'mode', 'comment']
# VIEWS
class CreatePayment(CreatePaymentView):
template_name: str = "payment/payment-template.html"
form_class = PaymentForm
class PaymentConfirmation(PaymentConfirmationView):
model = Payment
class PaymentStatus(PaymentObjectDoneView):
template_name: str = "payment/payment-status.html"
model = Payment
class FakePayment(FakePaymentView):
model = Payment
Example
check this example sponsor site
Contribution tips
- Make a fork of this repo.
- Take a tour to our API documentation here
- Get your API Key/Secret from ePay by Chargily dashboard for free.
- Start developing.
- Finished? Push and merge.
Metadata
Release files for chargily-epay-Django 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chargily-epay-Django-0.0.2.tar.gz | 48.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chargily_epay_Django-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.0 kB
Release files / chargily-epay-Django-0.0.2.tar.gz
| Download URL | chargily-epay-Django-0.0.2.tar.gz |
|---|---|
| Size | 48.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7cfe23899682c670ad8fcd523ac7ae845f3f42932bf3d38b441b7a06d24672ae
|
|
BLAKE2b-256 checksum How to use checksums |
fede4e4f2724a941b90b5fcc3ea042aab2fba76959a41adb07696b661757716f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Release files / chargily_epay_Django-0.0.2-py3-none-any.whl
| Download URL | chargily_epay_Django-0.0.2-py3-none-any.whl |
|---|---|
| Size | 50.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3469ce98734e5f910c233070c155c276187cb260d9976c7abfe54675e386748
|
|
BLAKE2b-256 checksum How to use checksums |
e9a89c9ea39659630edbdc41794c213c16cd5439dd03b6f4ace2bef5c8e880bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|