Payment Backend Implementation
The code is in payment_service/. It is a separate FastAPI service with SQLite for pilot and Docker deployment files.
Why the old pipeline did not work
The app-only payment flow recorded a local pending row and offered a sandbox confirmation button. It had no merchant wallet, no server-created Paymob order, no webhook verification, no idempotency, and no server-side entitlement. That is a demo, not a payment processor.
Implemented
- Server-side authoritative plan prices for
pro_100_tier,garage_450_tier,pay_per_scan. POST /v1/billing/intentfor Vodafone Cash and Paymob.- Paymob auth → order → payment key → iframe URL flow using server-only keys.
- Paymob webhook HMAC, amount/currency checks, replay/idempotency and entitlement activation.
- Vodafone Cash manual instructions plus an admin-confirm endpoint; a signed provider webhook endpoint is ready if the provider supplies one.
- Server entitlements and report credits; app polls status and applies the returned entitlement locally.
GET /v1/configpublic config for wallet number/provider enablement; no secret keys.- Server never trusts a client price or a client confirmation for live payments.
Enabling after verification
- Deploy the service over HTTPS.
- Put Paymob/Vodafone credentials and the real wallet number in server environment variables, never in the APK.
- Set provider webhook URLs.
- Enable providers through server env and
/v1/config. - The app fetches remote config; provider/wallet changes do not require a new APK once the app has the backend base URL. Secrets never go to the app.
OTA distinction
- Payment configuration/provider enablement: remote config from backend; no APK if the backend URL is already embedded.
- Merchant secrets: backend env only, never OTA to users.
- New native payment SDK/code: APK/AAB update required.
- AI model updates: separate model OTA manifest/registry; not the same as payment config.
Pilot security gap
The app currently uses local accounts. Payment service uses a shared pilot app token plus user_id; this is not production authentication. Add server-issued user JWTs/session tokens, device binding, rate limits and fraud monitoring before public launch.