Skip to main content

OTP SimplePay payment extension for Flask

Project description

Flask-SimplePay

OTP SimplePay integration with Flask

Usage

Initialize the extension with Flask and Flask-SQLAlchemy instances.

from flask import Flask
from flask_simplepay import SimplePay
from flask_sqlalchemy import SQLAlchemy


app = Flask(__name__)
db = SQLAlchemy(app)
simple = SimplePay(app, db)
    

if __name__ == '__main__':
    app.run()

To start payment, a Transaction is needed. After adding the transaction and commiting the session, the /simple/start/<int:transaction_id> endpoint starts the payment procedure. When the payment process is finished, the /simple/back endpoint is called. To define the behaviour upon the callback, extend the TransactionMixin class and override the back() method. Return value should be anything a Flask route method would return.

from flask import render_template
from flask_simplepay import TransactionMixin


class Transaction(db.Model, TransactionMixin):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    
    def back(self):
        return render_template(self.result, transaction=self)

The Transaction model class should be provided at initialization as transaction_class argument.

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-SimplePay-1.8.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file Flask-SimplePay-1.8.tar.gz.

File metadata

  • Download URL: Flask-SimplePay-1.8.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for Flask-SimplePay-1.8.tar.gz
Algorithm Hash digest
SHA256 3f52e91f8b8b942bf7d124cc9443832bcfb8376a483cb871bdd6a22482413113
MD5 a01830bf1da8ef17afc92d5c558532e7
BLAKE2b-256 e9a6e72d14e44775a64abd005ace51c7170d2c9dd218f022ae3dedbd28300248

See more details on using hashes here.

Supported by

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