Sample App: Python
A working Python integration against the PayKore sandbox. Sync and async patterns both covered — the quickstart uses sync, the webhook server uses the stdlib http.server.
Source: samples/python/ in the PayKore repo.
What it covers
| Step | Flow |
|---|---|
| 1 | Create two wallets |
| 2 | Fund wallet A (sandbox only) |
| 3 | P2P transfer: A → B |
| 4 | Bank transfer from A (async, settles via webhook) |
| 5 | QR payment: merchant creates intent, payer pays |
| 6 | USSD payment: initiate + simulate confirmation |
| 7 | KYC: submit BVN (async, result via webhook) |
Prerequisites
- Python 3.10+ (the webhook server uses
matchstatements) - A PayKore sandbox API key — sign up at app.paykore.com
Setup
cd samples/python
pip install -r requirements.txt
Run the quickstart
export PAYKORE_API_KEY=sk_test_YOUR_KEY_HERE
python quickstart.py
You'll see a ✅ line printed for each step. The full run takes under 10 seconds.
═══════════════════════════════════════
PayKore Python Quickstart
Environment: sandbox
═══════════════════════════════════════
── Step 1: Create wallets ──
✅ Wallet A created
{
"id": "wlt_9f3kA2mXpQ",
"status": "pending",
"nuban": "0123456789"
}
...
✅ P2P transfer completed
✅ Bank transfer accepted (202)
✅ QR payment completed (payer)
✅ USSD simulation: confirm sent
✅ BVN submitted
═══════════════════════════════════════
All steps completed successfully.
Run webhook_server.py to test async event delivery.
═══════════════════════════════════════
Run the webhook server
Steps 4 (bank transfer) and 7 (KYC) produce async results. The webhook server captures and prints them.
Terminal 1 — start the server:
export PAYKORE_WEBHOOK_SECRET=whsec_YOUR_SECRET_HERE
python webhook_server.py
Terminal 2 — expose it via ngrok:
ngrok http 8080
Register the ngrok URL with PayKore:
curl -X POST https://sandbox.paykore.com/v1/webhooks \
-H "Authorization: Bearer $PAYKORE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://YOUR_NGROK_URL/webhooks",
"events": ["transaction.completed","transaction.failed","wallet.activated","kyc.verified","kyc.failed"]
}'
Save the secret from the response and export it as PAYKORE_WEBHOOK_SECRET.
Terminal 3 — run the quickstart again:
python quickstart.py
You'll see events arrive in Terminal 1:
── 2025-06-01T10:03:24+00:00 ──
Event: transaction.completed
✅ Transaction completed
ID: tx_8wXyZ1aBcD
Type: bank_transfer
Reference: py_bank_f47ac10b-...
Amount: ₦1000.00
── 2025-06-01T10:03:26+00:00 ──
Event: kyc.verified
✅ KYC verified
User ref: py_user_a_1717200000
Type: bvn
Verified at: 2025-06-01T10:03:25Z
Key files
| File | What it is |
|---|---|
quickstart.py | The runnable script — one block per flow |
webhook_server.py | The HTTP server — signature verification + event handlers |
requirements.txt | Single dependency: paykore |
Next steps
- Python SDK Reference → — Full method documentation for every SDK call used here.
- Verifying Signatures → — How
verify_signature()in the webhook server works. - Test Scenarios → — The full pre-launch checklist once the quickstart is working.