A standalone, 2-screen Android (Java) test app for the Subscription Payment flow: Subscription Page + Payment Result Screen. Built to test UPI app detection, last-used sorting, native app opening, the secure loader, and success/failure/pending/cancelled states — before integrating into the main app.
- Smart UPI detection —
UpiAppDetectorqueries installed UPI apps, filters to the supported whitelist, and sorts most-recently-used first (max 3). - Last-used logic —
LastUsedStore(SharedPreferences) records the app after a successful payment so it floats to the top next time. - Native UPI intent —
UpiIntentBuilderbuildsupi://pay?...bound to one package so only the chosen app opens. - Full UX flow — tap app → create-order (mock) → loader → launch app → callback → verify (mock) → result screen.
- Mock backend —
MockPaymentRepositorysimulates create-order / verify so the whole flow runs with no server. Interface matches the real APIs for a clean swap. - Analytics — all PRD events logged to Logcat (tag
PayAnalytics), plus the addedqr_share_clickedevent and anis_last_usedproperty onupi_app_clicked.
These are intentionally NOT implemented — they involve live money and your keys:
- Real payment SDK (Razorpay Native / Juspay HyperSDK) — see commented block
in
app/build.gradleand the// PRODUCTION:notes inSubscriptionActivity. - Real backend for
POST /create-orderandPOST /verify— replaceMockPaymentRepositorywith a Retrofit implementation (same callback interface). - Backend payment verification — signature, status, duplicate, settlement checks. NEVER trust the frontend callback. The mock returns whatever status the UPI app reported; production must verify server-side before activating.
- Real merchant VPA —
PAYEE_VPA/PAYEE_NAMEare placeholders; in production pull these from the create-order response, not hardcoded constants.
An installable
.apkis produced by Android Studio on your machine — this package is the source project.
- Install Android Studio (Hedgehog or newer) and JDK 17.
- File → Open → select this
ArivihanPaymentTestfolder. - Let Gradle sync (it downloads the Android SDK + dependencies on first run).
- Plug in an Android phone (USB debugging on) with real UPI apps installed — detection only returns apps that actually exist on the device.
- Press Run ▶ (builds + installs), or Build → Build APK(s) to get a debug
.apkunderapp/build/outputs/apk/debug/.
Minimum: minSdk 21, targetSdk 34.
- Detection + sorting: install GPay/PhonePe/Paytm on the device → open the app
→ confirm up to 3 appear under the QR. Check Logcat
upi_apps_detected count=N. - Native open: tap an app → loader shows "Opening …" → that app launches with ₹51 pre-filled.
- Last-used: complete a (test) payment in one app → reopen → that app is now first with a "Recent" badge.
- Result states: the result screen renders from whatever status the UPI app
returns (or CANCELLED if you back out). To force-test each UI, temporarily change
the reported status passed into
verifyAndShowResult(...). - No UPI apps: test on an emulator with none installed → UPI section hides, QR + Other Options remain.
app/src/main/java/com/arivihan/paytest/
ui/SubscriptionActivity.java main screen + full flow wiring
ui/PaymentResultActivity.java success/failure/pending/cancelled
ui/UpiAppAdapter.java horizontal app row
util/UpiAppDetector.java detection + last-used sort ← core logic
util/LastUsedStore.java SharedPreferences storage
util/UpiIntentBuilder.java upi://pay intent builder
util/Analytics.java event logging
data/MockPaymentRepository.java mock create-order / verify
model/ UpiApp, OrderResponse, PaymentResult