Skip to content

Instantly share code, notes, and snippets.

@MohamadFazuan
Last active November 6, 2022 16:35
Show Gist options
  • Save MohamadFazuan/25a52bc4090294034f9cbd723c3229b7 to your computer and use it in GitHub Desktop.
Save MohamadFazuan/25a52bc4090294034f9cbd723c3229b7 to your computer and use it in GitHub Desktop.
Billplz-API-in-Python-Flask
import requests
import json
import base64
from flask import Flask,redirect
app = Flask(__name__)
@app.route('/')
def _init_():
api_key = '70eaae3d-39fd-408a-9b06-0580e588f3dfe'
encoded_key = base64.b64encode(api_key.encode()) #'NzBlYWFlM2QtMzlmZC00MDhhLTliMDYtMDU4MGU1ODhmM2Rm'
url = "https://billplz-staging.herokuapp.com/api/v3/bills"
collection_id = "6zkhjk2g"
params = { "collection_id":collection_id,
"email":"cust@example.com",
"mobile":"0123456789",
"name":"John Doe",
"amount":2000,
"callback_url":"http://yourwebsite.com/return_url",
"description":"Test" }
headers = { "Content-Type": "application/x-www-form-urlencoded",
"Charset": "utf-8",
"Authorization": "Basic "+encoded_key.decode()}
req = requests.post(url, headers=headers, data=params)
resp = requests.head(url,allow_redirects=True)
return redirect(req.json()["url"])
if __name__=='__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment