Skip to main content

Click.uz integration with Flask application, (only for Uzbekistan)

Project description

Flask-ClickUz

Only for Uzbekistan

Click.uz integration for Flask

Links

How it Works

Install

pip install Flask-ClickUz

Add your credentials from ClickUz to config file

CLICK_SECRET = 'Your secret key'
CLICK_SERVICE_ID = 'Your service ID'
CLICK_MERCHANT_ID = "Your merchant ID" 

Create Flask App With Flask-ClickUz

from flask import Flask
from flask_clickuz import Click
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
click = Click(db)
orders = [525]

def Check_Allowment(data): 
    merchant_trans_id = data.get('merchant_trans_id')
    if int(merchant_trans_id) in orders:
        return True
    return False

def Click_Callback(transaction):
    action = transaction.action # 0 - cancaled, 1 - paid
    pass

def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('config.py')
    db.init_app(app)
    
    click.Register_Callback(Click_Callback) # Register callback
    click.Register_Validator(Check_Allowment) # Register validator
    click.init_app(app)
    
    # Generate url for new orders
    url = click.Generate_Transaction(order_id=123, amount=50000, return_url = '/return_url')
    
    return app

Flask-ClickUz models schema

# Flask-ClickUz uses Flask-SQLAlchemy models to save data in database, it prefers to use Postgresql

class Click_Transaction(db.Model):
    __tablename__ = 'click_transaction'
    id = db.Column(db.Integer, primary_key=True)
    click_trans_id = db.Column(db.Integer, unique=True)
    service_id = db.Column(db.Integer)
    click_paydoc_id = db.Column(db.Integer)
    merchant_trans_id = db.Column(db.String(255))
    amount = db.Column(db.Float)
    action = db.Column(db.Integer)
    error = db.Column(db.Integer)
    error_note = db.Column(db.String(255))
    sign_time = db.Column(db.DateTime)
    sign_string = db.Column(db.String(255))

Accessing Models

Select data from models

click.model # Click_Transaction 
Click_Transaction = click.model
transaction = Click_Transaction.query.all() # You can select or filter data

Add model view to Flask-Admin

from flask_admin.contrib.sqla import ModelView
admin.add_view(ModelView(click.model, db.session))

Task List

SHOP-API methods

  • Prepare
  • Complete

Merchant API methods

  • create_invoice
  • check_invoice
  • create_card_token
  • verify_card_token
  • payment_with_card_token
  • delete_card_token
  • check_payment
  • merchant_trans_id
  • cancel

Licence

This project is licensed under the MIT License (see the LICENSE file for details).

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

Flask-ClickUz-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file Flask-ClickUz-1.0.0.tar.gz.

File metadata

  • Download URL: Flask-ClickUz-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for Flask-ClickUz-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a776740f133afe3699f27aab7d4bee6bf03ce7df9e2cb04e57d88548b6cb4373
MD5 4fb2e2a5fac034f6b7e78d33aef38c4e
BLAKE2b-256 c7c3eb6bd52ef945df4c52bfb907703b963caf516721158c8f43b537b0df86c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page