Skip to main content

OTP SimplePay payment extension for Flask

Project description


OTP SimplePay integration with Flask


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__':

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 what behaviour, 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 method 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.

Files for Flask-SimplePay, version 0.11
Filename, size File type Python version Upload date Hashes
Filename, size Flask-SimplePay-0.11.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page