Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/native-owner-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PAYNEX Native Owner Android
on:
push:
branches: [feat/native-owner-android-app]
paths: ["android/**", ".github/workflows/native-owner-android.yml"]
pull_request:
branches: [main]
paths: ["android/**", ".github/workflows/native-owner-android.yml"]
jobs:
build-owner-apk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Install Android SDK
run: |
SDK_ROOT="${ANDROID_HOME:-$ANDROID_SDK_ROOT}"
SDKMANAGER="$(find "$SDK_ROOT/cmdline-tools" -type f -name sdkmanager | sort | tail -n 1)"
test -x "$SDKMANAGER"
yes | "$SDKMANAGER" --licenses >/dev/null
"$SDKMANAGER" "platforms;android-35" "build-tools;35.0.0" "platform-tools"
- name: Build LocalProof and PAYNEX Owner debug APKs
uses: gradle/gradle-build-action@v3
with:
gradle-version: "8.9"
build-root-directory: android
arguments: --no-daemon :app:assembleDebug :ownerApp:assembleDebug
- name: Upload PAYNEX Owner APK
uses: actions/upload-artifact@v4
with:
name: paynex-native-owner-debug-apk
path: android/ownerApp/build/outputs/apk/debug/ownerApp-debug.apk
if-no-files-found: error
retention-days: 14
- name: Upload LocalProof APK
uses: actions/upload-artifact@v4
with:
name: paynex-localproof-debug-apk
path: android/app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: error
retention-days: 14
49 changes: 24 additions & 25 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
# PAYNEX LocalProof Android companion (early access)
# PAYNEX Android apps

This is an opt-in notification observation companion, not a payment app or bank integration.
The Android workspace contains two separate applications:

## Build
- Android Studio with JDK 17 and Android SDK 35
- Open the `android/` folder and build the `app` debug variant.
- The CI workflow builds a debug APK and stores it as a GitHub Actions artifact.

## Pairing
1. Sign in to the PAYNEX merchant dashboard and create/use an active merchant API key.
2. Enter the Worker URL and API key in the app.
3. Add only the exact package names of UPI apps you choose to observe.
4. Tap Enroll this device.
5. Tap Enable notification access and explicitly enable PAYNEX LocalProof in Android Settings.
6. Keep the phone unlocked/online when notifications arrive.
- `app` — PAYNEX LocalProof companion for opt-in notification observation. It is not a payment gateway or bank-verification app.
- `ownerApp` — PAYNEX Native Owner operations app, with its own application ID and launcher.

The P-256 private key is generated and held by Android Keystore; it is not exported. The server receives only the public key. The app signs timestamp + nonce + exact JSON request bytes.
## Build
- Android Studio, JDK 17 and Android SDK 35
- Open `android/`
- Build LocalProof: `./gradlew :app:assembleDebug`
- Build PAYNEX Owner: `./gradlew :ownerApp:assembleDebug`

## Data minimisation
Notification text is processed locally only. The app uploads the source package, parser version, event ID, observation time and optional parsed amount/UTR. Full notification bodies, account numbers, contacts and inbox history are not uploaded. Configure an explicit package allowlist. The app does not read SMS inboxes.
GitHub Actions workflow `PAYNEX Native Owner Android` builds both debug APKs and uploads separate artifacts. Debug APKs are for testing; production distribution requires a protected signing key and release validation.

## Limits
- Notification formats vary by UPI app, bank and language; parsing is best-effort and requires real-device testing.
- Notifications may be delayed, absent, duplicated or spoofed.
- A LocalProof observation never marks an order/payment paid, posts a verified ledger journal, activates a subscription, or triggers fulfilment.
- This initial companion does not yet have a durable offline retry queue or in-app observation history.
- Do not use this as a substitute for checking the receiving bank/UPI app.
## Native Owner app scope
- Merchant-key connection over HTTPS; API key encrypted at rest using Android Keystore AES-GCM.
- Live merchant summary, transaction list and payment-link list via existing Worker endpoints.
- Direct UPI QR/Intent for the configured receiving UPI ID; opening UPI is never treated as proof of payment.
- Create hosted payment links, list/create/revoke merchant API keys where the backend permits, and access limited sandbox API key routes.
- LocalProof companion entry and truthful unverified-observation status.
- Refund/reconciliation entry points only where backend endpoints exist; unsupported endpoints are shown as unavailable, not simulated.
- Merchant administration and global admin controls are intentionally gated: a merchant API key is not an admin credential. A dedicated owner/admin session integration is required before those functions can be enabled.

## Privacy and control
Disable notification access in Android Settings to stop observation. Revoke the device in-app to invalidate its API identity. Clear app data/uninstalling the app removes local settings; server-side device revocation should be done first where possible.
## Payment and security boundaries
- The current personal UPI QR/Intent is a direct payment request; customer funds are sent by the UPI network directly to the receiving account.
- UPI app launch, redirect, screenshot, notification, or customer-provided UTR never establishes bank-confirmed success.
- Only an authorised provider's authenticated server-to-server confirmation may establish provider-verified payment. LocalProof observations remain unverified hints.
- Do not embed live API keys in websites or APK resources. The app stores the entered merchant key encrypted locally; use a scoped, revocable key and rotate it if exposed.
- No production release or payment verification claim is implied by a successful debug build.
21 changes: 21 additions & 0 deletions android/ownerApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.paynex.owner"
compileSdk = 35
defaultConfig {
applicationId = "com.paynex.owner"
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "0.1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions { jvmTarget = "17" }
}
dependencies { implementation("com.google.zxing:core:3.5.3") }
8 changes: 8 additions & 0 deletions android/ownerApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="false" android:label="PAYNEX Owner" android:usesCleartextTraffic="false" android:theme="@android:style/Theme.Material.NoActionBar">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter>
</activity>
</application>
</manifest>
93 changes: 93 additions & 0 deletions android/ownerApp/src/main/java/com/paynex/owner/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.paynex.owner
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.view.Gravity
import android.widget.*
import org.json.JSONObject
import com.google.zxing.BarcodeFormat
import com.google.zxing.MultiFormatWriter
import kotlin.concurrent.thread

class MainActivity : Activity() {
private val defaultBase="https://paynex-api.sbn50088.workers.dev"
private val prefs by lazy { getSharedPreferences("paynex_owner",MODE_PRIVATE) }
private lateinit var root:LinearLayout; private lateinit var content:LinearLayout
private lateinit var base:EditText; private lateinit var key:EditText; private lateinit var upi:EditText
private var current="Overview"; private var summary=JSONObject(); private var upiProfile=JSONObject()
private val bg=Color.rgb(7,15,30); private val panel=Color.rgb(17,31,53); private val fg=Color.rgb(238,245,255); private val muted=Color.rgb(151,170,194); private val lime=Color.rgb(184,244,119)
override fun onCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState);login()}
private fun d(v:Int)=(v*resources.displayMetrics.density).toInt()
private fun txt(s:String,size:Float=14f,color:Int=fg,bold:Boolean=false)=TextView(this).apply{text=s;textSize=size;setTextColor(color);if(bold)setTypeface(null,android.graphics.Typeface.BOLD)}
private fun btn(s:String,run:()->Unit)=Button(this).apply{text=s;isAllCaps=false;setTextColor(bg);backgroundTintList=android.content.res.ColorStateList.valueOf(lime);setOnClickListener{run()}}
private fun input(h:String,v:String="",secret:Boolean=false)=EditText(this).apply{hint=h;setText(v);setSingleLine(true);setTextColor(fg);setHintTextColor(muted);setPadding(d(13),d(12),d(13),d(12));if(secret)inputType=android.text.InputType.TYPE_CLASS_TEXT or android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD}
private fun login(){
root=LinearLayout(this).apply{orientation=1;setPadding(d(24),d(36),d(24),d(24));setBackgroundColor(bg)}
root.addView(txt("PAYNEX",32f,lime,true));root.addView(txt("OWNER • NATIVE CONTROL CENTER",11f,muted,true))
root.addView(Space(this).apply{minimumHeight=d(45)})
root.addView(txt("Connect your PAYNEX workspace",23f,fg,true))
root.addView(txt("Merchant API keys provide merchant-scoped tools. Admin and cross-merchant actions require the secure PAYNEX owner/admin session.",13f,muted))
base=input("PAYNEX Worker HTTPS URL",prefs.getString("base",defaultBase)!!)
key=input("Active API key",SecureStore.decrypt(prefs.getString("key_enc","")),true)
upi=input("Receiving UPI ID",prefs.getString("upi_id","kr69@ptyes")!!)
root.addView(base);root.addView(key);root.addView(upi);root.addView(btn("Connect securely"){connect()})
root.addView(txt("API keys are encrypted locally with Android Keystore. Never share a live key.",11f,muted))
setContentView(root)
}
private fun connect(){
val b=base.text.toString().trim();val k=key.text.toString().trim()
if(!b.startsWith("https://")||k.isBlank()){toast("HTTPS URL and API key required");return}
prefs.edit().putString("base",b).putString("key_enc",SecureStore.encrypt(k)).putString("upi_id",upi.text.toString().trim()).apply()
thread{try{val s=PaynexApi.request(b,"/api/v1/summary",key=k); val u=PaynexApi.request(b,"/api/v1/merchant/upi",key=k);runOnUiThread{summary=s;upiProfile=u;workspace()}}catch(e:Exception){runOnUiThread{toast(e.message?:"Connection failed")}}}
}
private fun workspace(){
root=LinearLayout(this).apply{orientation=1;setBackgroundColor(bg)}
val head=LinearLayout(this).apply{orientation=1;setPadding(d(18),d(18),d(18),d(10))}
head.addView(txt("PAYNEX / OWNER",20f,lime,true));head.addView(txt("Your payment operations",12f,muted));root.addView(head)
val nav=HorizontalScrollView(this);val row=LinearLayout(this).apply{orientation=0}
listOf("Overview","Collect","Transactions","Links","API Keys","LocalProof","Refunds","Reconcile","Merchants","Admin").forEach{n->row.addView(txt(n,12f,if(n==current)lime else muted,true).apply{setPadding(d(12),d(12),d(12),d(12));setOnClickListener{current=n;render()}})}
nav.addView(row);root.addView(nav)
val sc=ScrollView(this);content=LinearLayout(this).apply{orientation=1;setPadding(d(16),d(12),d(16),d(28))};sc.addView(content);root.addView(sc,LinearLayout.LayoutParams(-1,0,1f));setContentView(root);render()
}
private fun card(t:String,b:String){val box=LinearLayout(this).apply{orientation=1;setPadding(d(15),d(14),d(15),d(14));setBackgroundColor(panel);addView(txt(t,12f,muted,true));addView(txt(b,20f,fg,true))};val p=LinearLayout.LayoutParams(-1,-2);p.bottomMargin=d(10);content.addView(box,p)}
private fun action(t:String,sub:String,run:()->Unit){val box=LinearLayout(this).apply{orientation=1;setPadding(d(14),d(13),d(14),d(13));setBackgroundColor(panel);addView(txt(t,15f,fg,true));addView(txt(sub,11f,muted));setOnClickListener{run()}};val p=LinearLayout.LayoutParams(-1,-2);p.bottomMargin=d(8);content.addView(box,p)}
private fun render(){
content.removeAllViews();content.addView(txt(current,25f,fg,true));content.addView(txt("Connected workspace • live Worker data",11f,muted))
when(current){
"Overview"->{val tx=summary.optJSONObject("transactions")?:JSONObject();val links=summary.optJSONObject("payment_links")?:JSONObject();card("VERIFIED COLLECTION",money(tx.optLong("verified_volume_minor")));card("TRANSACTIONS",tx.optInt("total").toString()+" total • "+tx.optInt("verified")+" verified • "+tx.optInt("pending")+" pending");card("PAYMENT LINKS",links.optInt("total").toString()+" total • "+links.optInt("active")+" active");action("Payment collection","UPI QR, intent and hosted links"){current="Collect";render()};action("Transactions","Payment state monitoring"){current="Transactions";render()};action("Integrations","API keys and sandbox tools"){current="API Keys";render()}}
"Collect"->collect()
"Transactions"->load("/api/v1/transactions?limit=50&offset=0")
"Links"->load("/api/v1/payment-links")
"API Keys"->keys()
"LocalProof"->{card("LOCALPROOF","Device observations are unverified hints, never bank confirmation.");action("Pair LocalProof companion","Open the separate companion app to enroll/revoke a device"){toast("Install and pair PAYNEX LocalProof companion separately.")}}
"Refunds"->{card("REFUND CONTROL","Submit full refund requests for verified transactions. Approval is not a money movement; settlement requires an authorised provider webhook.");load("/api/v1/refunds")}
"Reconcile"->{card("RECONCILIATION","Global reconciliation cases require the secure owner/admin session. Merchant-scoped refund status is shown in Refunds. UTR or screenshot alone is not bank confirmation.");action("Open owner admin session","Admin reconciliation is not available with a merchant API key"){login()}}
"Merchants","Admin"->{card("OWNER SESSION REQUIRED","A merchant API key cannot access admin or cross-merchant records. Use PAYNEX secure owner/admin authentication.");action("Reconnect","Return to secure sign-in"){login()}}
}
}
private fun collect(){
content.addView(txt("Direct UPI collection",15f,fg,true));content.addView(txt("Funds go directly to the configured UPI account. UPI app launch is not payment verification.",12f,muted))
val upi=input("Receiving UPI ID",upiProfile.optString("upi_id",""));val amount=input("Amount in INR");val note=input("Payment description");content.addView(upi);content.addView(btn("Save receiving UPI profile"){val v=upi.text.toString().trim();if(!v.contains("@")){toast("Enter valid UPI ID");return@btn};thread{try{val p=PaynexApi.request(baseUrl(),"/api/v1/merchant/upi","POST",apiKey(),JSONObject().put("upi_id",v).put("account_type","personal"));val u=PaynexApi.request(baseUrl(),"/api/v1/merchant/upi",key=apiKey());runOnUiThread{upiProfile=u;toast(p.optString("message","UPI profile saved. Ownership approval reset."));}}catch(e:Exception){runOnUiThread{toast(e.message?:"UPI profile save failed")}}}});content.addView(amount);content.addView(note)
content.addView(btn("Generate UPI QR + open UPI app"){
val v=amount.text.toString().toDoubleOrNull();if(v==null||v<=0){toast("Enter valid amount");return@btn}
val receivingUpi=upi.text.toString().trim();if(!receivingUpi.contains("@")){toast("Enter a valid receiving UPI ID");return@btn}
val uri="upi://pay?pa="+Uri.encode(upiProfile.optString("upi_id",receivingUpi))+"&pn="+Uri.encode(upiProfile.optString("business_name","PAYNEX"))+"&am="+String.format(java.util.Locale.US,"%.2f",v)+"&cu=INR&tn="+Uri.encode(note.text.toString())
qr(uri);val i=Intent(Intent.ACTION_VIEW,Uri.parse(uri));if(i.resolveActivity(packageManager)!=null)startActivity(i)else toast("No UPI app found; scan the QR")
})
val title=input("Payment link title");val price=input("Payment link amount INR");content.addView(txt("Hosted payment link",15f,fg,true));content.addView(title);content.addView(price)
content.addView(btn("Create payment link"){
val v=price.text.toString().toDoubleOrNull();if(title.text.isBlank()||v==null||v<=0){toast("Enter title and valid amount");return@btn}
thread{try{val out=PaynexApi.request(baseUrl(),"/api/v1/payment-links","POST",apiKey(),JSONObject().put("title",title.text.toString()).put("amount_minor",(v*100).toLong()).put("currency","INR"));runOnUiThread{card("LINK CREATED",out.toString())}}catch(e:Exception){runOnUiThread{toast(e.message?:"Create failed")}}}
})
}
private fun qr(value:String){try{val m=MultiFormatWriter().encode(value,BarcodeFormat.QR_CODE,d(240),d(240));val bmp=Bitmap.createBitmap(m.width,m.height,Bitmap.Config.ARGB_8888);for(x in 0 until m.width)for(y in 0 until m.height)bmp.setPixel(x,y,if(m[x,y])Color.BLACK else Color.WHITE);content.addView(ImageView(this).apply{setImageBitmap(bmp);setPadding(d(10),d(10),d(10),d(10));setBackgroundColor(Color.WHITE)},LinearLayout.LayoutParams(d(260),d(260)));content.addView(txt("UPI ID: "+upiProfile.optString("upi_id","Not configured")+" • "+upiProfile.optString("account_type","personal")+" • "+(if(upiProfile.optBoolean("public_collection_eligible"))"ownership approved" else "private testing only")+" • Pending until independently verified",12f,muted))}catch(e:Exception){toast("QR error: "+e.message)}}
private fun load(path:String){val wait=txt("Loading…",12f,muted);content.addView(wait);thread{try{val out=PaynexApi.request(baseUrl(),path,key=apiKey());runOnUiThread{content.removeView(wait);content.addView(txt(out.toString(2),12f,fg))}}catch(e:Exception){runOnUiThread{content.removeView(wait);card("UNAVAILABLE",e.message?:"Endpoint not available")}}}}
private fun keys(){card("API KEY SECURITY","New keys are shown once. Existing plaintext keys cannot be recovered.");val l=input("Key label");content.addView(l);content.addView(btn("Create API key"){thread{try{val o=PaynexApi.request(baseUrl(),"/api/v1/api-keys","POST",apiKey(),JSONObject().put("label",l.text.toString().ifBlank{"Native Owner App"}));runOnUiThread{card("COPY AND STORE THIS KEY NOW",o.toString(2))}}catch(e:Exception){runOnUiThread{toast(e.message?:"Key creation failed")}}}});action("List and revoke keys","Key metadata and revocation"){load("/api/v1/api-keys")};action("Sandbox keys","Limited-access pn_test_ keys"){load("/api/v1/limited/api-keys")}}
private fun baseUrl()=prefs.getString("base",defaultBase)!!
private fun apiKey()=SecureStore.decrypt(prefs.getString("key_enc",""))
private fun money(v:Long)=if(v==0L)"—" else "₹"+String.format(java.util.Locale.US,"%.2f",v/100.0)
private fun toast(s:String)=Toast.makeText(this,s,Toast.LENGTH_LONG).show()
}
17 changes: 17 additions & 0 deletions android/ownerApp/src/main/java/com/paynex/owner/PaynexApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.paynex.owner
import org.json.JSONObject
import java.net.HttpURLConnection
import java.net.URL
object PaynexApi {
fun request(base:String,path:String,method:String="GET",key:String,body:JSONObject?=null):JSONObject {
require(base.startsWith("https://",true)) { "HTTPS Worker URL required" }
val c=URL(base.trimEnd('/')+path).openConnection() as HttpURLConnection
c.requestMethod=method; c.connectTimeout=15000; c.readTimeout=15000
c.setRequestProperty("Accept","application/json"); c.setRequestProperty("x-api-key",key)
if(body!=null){c.doOutput=true;c.setRequestProperty("Content-Type","application/json");c.outputStream.use{it.write(body.toString().toByteArray())}}
val code=c.responseCode; val stream=if(code in 200..299)c.inputStream else c.errorStream
val raw=stream?.bufferedReader()?.use{it.readText()} ?: "{}"; c.disconnect()
if(code !in 200..299) throw IllegalStateException("PAYNEX API HTTP $code: $raw")
return JSONObject(raw)
}
}
Loading
Loading