Giter Site home page Giter Site logo

chargily / chargily-epay-django Goto Github PK

View Code? Open in Web Editor NEW
18.0 1.0 7.0 151 KB

Django Package for Chargily ePay Gateway

Home Page: https://dev.chargily.com/docs/#/epay-django

License: MIT License

Python 71.11% HTML 28.89%
api chargily cib cibweb django edahabia epay gateway integration library

chargily-epay-django's Introduction

epay-gateway-django

Chargily ePay Gateway (Django Package)

Documentation

you can find more about Here

Chargily ePay Gateway

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

payment

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

payment

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

fake_payment

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

Donation website

sponsor site

Contribution tips

  1. Make a fork of this repo.
  2. Take a tour to our API documentation here
  3. Get your API Key/Secret from ePay by Chargily dashboard for free.
  4. Start developing.
  5. Finished? Push and merge.

chargily-epay-django's People

Contributors

chargilydev avatar tarek-berkane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

chargily-epay-django's Issues

function based-view to get data from the Django session

Hi

I am attempting to integrate the Chargily API into my website developed by Django, How I can integrate the API using function-based-view to get data (mode and amount etc) from the Django session without using the API form?

best regard

Request for fake-payment-view.html file content.

Issue Description:

I am attempting to integrate the Chargily API into my development environment as I believe it offers great functionality for payment processing. However, during testing, I encountered an error while trying to fill up the form in the create-payment view and clicking the submit button.

Error Description:

Upon submitting the form, I am redirected to the fake-payment-view.html page which then indicates the following :
**
TemplateDoesNotExist at /en/epay/fake-payment/17/
chargily_epay_django/fake-payment-view.html **

.
issue2

Steps to Reproduce:

Access the development environment.
Navigate to the create-payment view or form.
Fill up the form with the required payment details.
Click the submit button to process the payment.
Expected Behavior:

Upon clicking the submit button in the create-payment form, I expect the form data to be sent to the Chargily API for payment processing. Subsequently, a response should be displayed on the page indicating the payment status or any necessary further action, such as redirection to a payment gateway.

Actual Behavior:

Instead of processing the payment and displaying a relevant response, the form submission redirects to the fake-payment-view.html page, which does not seem to exist in the first place .

Additional Information:

I have followed the sponsor example in the development environment

Possible Solution:

As I am relatively new to integrating external APIs, I suspect there might be an issue in my implementation of the Chargily API or a misconfiguration related the chargily_epay_django/fake-payment-view.html template and handling the API response

. I would greatly appreciate any guidance or insights into the proper way to integrate and utilize the Chargily API in the development environment.

Thank you for your assistance in resolving this issue.

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.