Community SDK for parsing, validating, and generating Egyptian InstaPay payment links. Zero dependencies for the core API.
Project description
instapay-eg
Community SDK for Egyptian InstaPay payment links.
Parse, validate, audit, and generate QR codes - with zero core dependencies.
What is instapay-eg?
instapay-eg is a Python SDK for working with Egyptian InstaPay payment links (https://ipn.eg/S/...).
InstaPay is Egypt's national instant payment network, built by the Egyptian Banks Company (EBC). Developers building Egyptian fintech applications - food delivery, e-commerce, booking platforms, freelance marketplaces - regularly need to:
- Parse the multi-line share-sheet text the InstaPay app produces
- Verify that a link is genuinely from InstaPay and not a phishing URL
- Extract a user's handle for display or storage
- Generate QR codes for payment requests
- Integrate payment link validation into their Pydantic/FastAPI or Django models
This SDK solves all of that with a clean, typed, zero-dependency core API.
Features
| Feature | Details |
|---|---|
| 🔍 Smart Parsing | Extracts the URL from raw multi-line share-sheet text automatically |
| 🛡️ Anti-Phishing | Detects lookalike domains, homoglyph attacks, and injection payloads |
| 🔬 Security Audit | audit_link() returns a structured SecurityReport for logging |
| 📱 QR Codes | PNG, SVG, bytes, and base64 - covers every web and mobile use case |
| 🤝 Pydantic v2 | Annotated types (InstaPayLink, InstaPayHandle) for FastAPI schemas |
| 🦄 Django | InstaPayLinkField ORM field and InstaPayHandleFormField form field |
| 💻 CLI | instapay parse "...", instapay audit "..." |
| ✅ 100% Typed | Full py.typed marker, passes strict type checking |
| 🧪 100% Tested | 100% branch coverage enforced in CI |
Installation
Using pip:
pip install instapay-eg
Using uv:
uv add instapay-eg
With Optional Extras
# For Pydantic / FastAPI integration:
pip install "instapay-eg[pydantic]"
# For QR code generation:
pip install "instapay-eg[qrcode]"
# For Django integration:
pip install "instapay-eg[django]"
# Everything at once:
pip install "instapay-eg[all]"
Quick Demo
from instapay_eg import parse_text
# Paste the raw text from the InstaPay app share sheet:
raw = """
https://ipn.eg/S/alice/instapay/2DcFGv
Click the link to send money to
alice@instapay
Powered by InstaPay
"""
data = parse_text(raw)
print(data.link) # https://ipn.eg/S/alice/instapay/2DcFGv
print(data.handle) # alice
print(data.formatted_handle) # alice@instapay
print(data.raw_url_id) # 2DcFGv
print(data.is_verified) # True
Security Audit
from instapay_eg import audit_link
# Check a suspicious link:
report = audit_link("https://ipn.eg.evil.com/S/alice/instapay/fake")
print(report.is_safe) # False
print(report.phishing_risk) # True
print(report.failure_reason) # "Domain 'ipn.eg.evil.com' matches a known phishing pattern."
Pydantic / FastAPI
from fastapi import FastAPI
from pydantic import BaseModel
from instapay_eg.integrations.pydantic import InstaPayLink, InstaPayHandle
class PaymentRequest(BaseModel):
# Users can paste raw share-sheet text - the link is extracted & verified automatically
link: InstaPayLink
recipient: InstaPayHandle
app = FastAPI()
@app.post("/payments")
async def create_payment(payment: PaymentRequest):
return {"link": payment.link, "recipient": payment.recipient}
QR Code Generation
from instapay_eg.integrations.qrcode import qr_as_base64, save_qr
link = "https://ipn.eg/S/alice/instapay/2DcFGv"
# Return in a JSON API response - no file I/O needed:
b64 = qr_as_base64(link)
# → Use in HTML: <img src="data:image/png;base64,{b64}" />
# Or save to disk:
save_qr(link, "alice_payment_qr.png")
CLI
# Parse share-sheet text:
$ instapay parse "https://ipn.eg/S/alice/instapay/2DcFGv Click to pay..."
Link: https://ipn.eg/S/alice/instapay/2DcFGv
Handle: alice
Format: alice@instapay
Safe: ✅ Yes
# Audit a suspicious URL:
$ instapay audit "https://ipn.eg.evil.com/S/alice/instapay/fake"
Status: ❌ UNSAFE - DO NOT USE
Phishing: ❌ LOOKALIKE DOMAIN DETECTED
Documentation
Full documentation is available at mohamedmostafa259.github.io/instapay-eg.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
Disclaimer
This is an community-driven utility package. It is not affiliated with, endorsed by, or associated with the Egyptian Banks Company (EBC) or InstaPay Egypt.
License
MIT - see LICENSE 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instapay_eg-0.1.1.tar.gz.
File metadata
- Download URL: instapay_eg-0.1.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4486ff80f82eac52ec618eb1e6ced45b9d046c11388cb03ec488a9f306591ba3
|
|
| MD5 |
da3d1af4808637720a1fa71e719d9619
|
|
| BLAKE2b-256 |
6649f49293911ff58ec860798d54e696a25c24dc085ebea26794cfb9a46ed246
|
Provenance
The following attestation bundles were made for instapay_eg-0.1.1.tar.gz:
Publisher:
publish.yml on MohamedMostafa259/instapay-eg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instapay_eg-0.1.1.tar.gz -
Subject digest:
4486ff80f82eac52ec618eb1e6ced45b9d046c11388cb03ec488a9f306591ba3 - Sigstore transparency entry: 1725397097
- Sigstore integration time:
-
Permalink:
MohamedMostafa259/instapay-eg@103a560d045b09e52982ab68fed8f212ff71bfca -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MohamedMostafa259
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@103a560d045b09e52982ab68fed8f212ff71bfca -
Trigger Event:
release
-
Statement type:
File details
Details for the file instapay_eg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: instapay_eg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0b37c12b65182df1dd7da14998c92139102f5755289ca5eb853f884a1dc2335
|
|
| MD5 |
bcc777ac399d1485d769da0f80c579ee
|
|
| BLAKE2b-256 |
7cc87f25979a6a5c5862eea37232bfaa70252d53a3cb6c7ac8220d2f229d70d0
|
Provenance
The following attestation bundles were made for instapay_eg-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on MohamedMostafa259/instapay-eg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instapay_eg-0.1.1-py3-none-any.whl -
Subject digest:
d0b37c12b65182df1dd7da14998c92139102f5755289ca5eb853f884a1dc2335 - Sigstore transparency entry: 1725397198
- Sigstore integration time:
-
Permalink:
MohamedMostafa259/instapay-eg@103a560d045b09e52982ab68fed8f212ff71bfca -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MohamedMostafa259
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@103a560d045b09e52982ab68fed8f212ff71bfca -
Trigger Event:
release
-
Statement type: