Skip to content

rahul20a/Fundamental

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arivihan — Smart UPI Payment Flow (Test Module)

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.


What's included (working source)

  • Smart UPI detectionUpiAppDetector queries installed UPI apps, filters to the supported whitelist, and sorts most-recently-used first (max 3).
  • Last-used logicLastUsedStore (SharedPreferences) records the app after a successful payment so it floats to the top next time.
  • Native UPI intentUpiIntentBuilder builds upi://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 backendMockPaymentRepository simulates 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 added qr_share_clicked event and an is_last_used property on upi_app_clicked.

What you must add (left as clearly-marked stubs)

These are intentionally NOT implemented — they involve live money and your keys:

  1. Real payment SDK (Razorpay Native / Juspay HyperSDK) — see commented block in app/build.gradle and the // PRODUCTION: notes in SubscriptionActivity.
  2. Real backend for POST /create-order and POST /verify — replace MockPaymentRepository with a Retrofit implementation (same callback interface).
  3. 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.
  4. Real merchant VPAPAYEE_VPA/PAYEE_NAME are placeholders; in production pull these from the create-order response, not hardcoded constants.

How to build the APK

An installable .apk is produced by Android Studio on your machine — this package is the source project.

  1. Install Android Studio (Hedgehog or newer) and JDK 17.
  2. File → Open → select this ArivihanPaymentTest folder.
  3. Let Gradle sync (it downloads the Android SDK + dependencies on first run).
  4. Plug in an Android phone (USB debugging on) with real UPI apps installed — detection only returns apps that actually exist on the device.
  5. Press Run ▶ (builds + installs), or Build → Build APK(s) to get a debug .apk under app/build/outputs/apk/debug/.

Minimum: minSdk 21, targetSdk 34.


How to test

  • 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.

File map

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

About

Jupyter Notebook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 100.0%