Skip to main content

flask_midtrans is a package for integrate midtrans to flask framework

Project description

Flask Midtrans

How to use:

from flask_midtrans import Midtrans
from flask import Flask

# set environments
app = Flask(__name__)
app.config['MIDTRANS_IS_PRODUCTION'] = False
app.config['MIDTRANS_SERVER_KEY'] = 'SB-Mid-server-fRTQ4YyV5mVXB'
app.config['MIDTRANS_CLIENT_KEY'] = 'SB-Mid-client-hdv0voYgqK'

# instance
midtrans = Midtrans(app)

@app.route('/')
def hello_world():
    param = {
        "transaction_details": {
            "order_id": "test-transaction-123",
            "gross_amount": 200000
        }, "credit_card": {
            "secure": True
        }
    }

    # midtrans.snap or midtrans.core
    # https://github.com/Midtrans/midtrans-python-client
    response = midtrans.snap.create_transaction(param)

    # >> response
    #  {'token': 'thistoken', 'redirect_url': 'http://midtrans..'}
    return response['token']

Contributes:

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_midtrans-0.0.1a0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

flask_midtrans-0.0.1a0-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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