Git Product home page Git Product logo

django-pardakht's Introduction

django-pardakht

What's this?

You can use this app to create payments in your django project via Iranian gateways. (Right now only Zarinpal and Saman are available but the rest are coming soon)

How does it work?

You ask the app for a new payment and it will give you a link on your own site that you can redirect users to it in order to have a payment.

http://img.majidonline.com/pic/321293/1.png

http://img.majidonline.com/pic/321294/2.png

http://img.majidonline.com/pic/321295/3.png

Installation

  1. pip install django-pardakht
  2. Add pardakht to your INSTALLED_APPS
  3. python manage.py migrate
  4. Add pardakht urls to your project's urls.
from pardakht import urls as pardakht_urls
urlpatterns = [
    ...

    url(r'^<SOME_URL>/', include(pardakht_urls)),

    ...
]
  1. For any gateway you use, add GATEWAY_MERCHANT_ID in your project settings. For example if you are going to use zarinpal, You need to add ZARINPAL_MERCHANT_ID in your settings with value set to your zarinpal merchant ID or if you are using saman gateway, You need to add SAMAN_MERCHANT_ID in your settings.

Usage

There is a payment model that app uses to handle payments. Every payment you create needs 5 initial parameters.

  1. price: Price of the payment.
  2. description: Short description about this payment. Necessary for some gateways such as Zarinpal.
  3. return_function: A callable object (function) that will get called after payment is done with the payment object as it's input. It's optional and can be None.
  4. return_url: A url for user to come back where he left off on your site. It's optional and can be None.
  5. login_required: Must be True if user who is paying should be authenticated. If you're going to use this you have to set LOGIN_URL in project settings.

To create a payment:

from pardakht import handler
result = handler.create_payment(
    price,
    description,
    return_function,
    return_url,
    login_required
)

This will create a payment and returns a dict containing payment object and a link to pay it:

result['payment']   #  Created payment object
result['link']      #  Link for paying this payment that you should redirect your user to

Extra notes

This app handles all steps of payment including UI parts.

It uses semantic-ui so if you want to use it you need to serve app's static files.

But of course you can override templates to use your own templates with your own UI design.

Configurations

If you are using ZarinGate to send users directly to the bank payment page, set ZARINPAL_USE_ZARINGATE to True in your project settings.

django-pardakht's People

Contributors

ali-toosi avatar bersam avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

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.