Kotlin (Android) SDK

Drop-in Google Play–style checkout sheet, API client, and webhook helpers for Android apps.

AGENTS.md

Package et.payproof:payproof-android. Your backend creates a checkout; the app opens a customizable bottom sheet that lists bank accounts, copies the reference code, uploads a receipt, and streams verification progress.

Requirements

ItemValue
Min SDK24
Compile SDK34
LanguageKotlin + Jetpack Compose (bundled UI)
Artifactet.payproof:payproof-android:0.4.2

Install

Add the PayProof Maven repository supplied during onboarding, then declare the dependency.

settings.gradle.kts
dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    // Use the repository URL from your PayProof dashboard / onboarding email.
    maven { url = uri("https://your-payproof-maven-host/releases") }
  }
}
build.gradle.kts
dependencies {
  implementation("et.payproof:payproof-android:0.4.2")
}

Initialize

Application
PayProof.init(
  context = this,
  config = PayProofConfig(
    baseUrl = "https://api.payproof.et",
    clientKey = "pk_live_...", // publishable key — safe in the app
    appId = 1,                // optional when the key is app-scoped
  ),
)

Present the checkout sheet

Activity
val launcher = PayProofCheckout.register(this) { result ->
  when (result) {
    is PayProofCheckoutResult.Verified -> {
      // result.publicId, referenceCode, amountEtb
    }
    is PayProofCheckoutResult.Canceled -> Unit
    is PayProofCheckoutResult.Failed -> Unit
    is PayProofCheckoutResult.ManualReview -> Unit
  }
}

PayProofCheckout.present(
  launcher = launcher,
  context = this,
  publicId = "cs_...",
  appearance = PayProofAppearance(
    primaryColor = "#0071e3",
    ctaColor = "#0a2540",
    cornerRadiusDp = 20f,
    confirmButtonLabel = "Verify payment",
    showPayProofBadge = true,
  ),
)

What the sheet handles

StepAPI
Load checkout + banksGET /api/public/gateway/checkouts/:id/
Live statusGET …/status/ + WS /ws/gateway/checkouts/:id
Upload receiptPOST …/verify/ (multipart images)
Manual reviewPOST …/manual-review/
GET/api/public/gateway/checkouts/:public_id/
POST/api/public/gateway/checkouts/:public_id/verify/

Same contract as the hosted pay page. Branding falls back to app.brand_color / logo from the checkout payload when appearance fields are null.

Appearance

FieldDefaultNotes
primaryColorapp brand / #0071e3Accent / selection hex
ctaColor#0a2540Navy primary CTA buttons
onPrimaryColorwhiteText on primary buttons
surfaceColorwhiteSheet background (light mode)
onSurfaceColor#0a2540Primary text
mutedColor#425466Secondary text
cornerRadiusDp20Top corners of the sheet
titleOverridePayProof CheckoutHeader title
subtitleOverride—Unused in default layout
confirmButtonLabelVerify paymentCTA when a receipt is selected
showPayProofBadgetrue“Secured · PayProof” footer

Checkout results

ResultWhen
VerifiedCheckout status verified (after receipt check)
CanceledUser closed the sheet or RESULT_CANCELED
FailedTerminal failure with optional failureCode / reason
ManualReviewCheckout entered manual_review
PartialSome of the amount is paid. This is not an entitlement.

Live catalog and purchase

Your app draws the paywall. PayProof returns the current packages and opens the sheet. You own the layout. PayProofPackageList is an optional row list, and PayProofStatusCard renders live billing state (period end, grace, overpay, renewal actions) anywhere in your UI.

Kotlin
val catalog = PayProof.getOfferings()
val monthly = (catalog as PayProofResult.Ok).value.current
  ?.packages?.first { it.identifier == "monthly" }

PayProof.purchase(
  context = this,
  launcher = launcher,
  request = CreateCheckoutRequest(
    appId = appId,
    packageId = monthly?.id,
    customerRef = userId,
  ),
)

If the price changes while the sheet is open, the customer must tap Continue before a new checkout is created. Underpayment shows paid and remaining amounts and stays Partial until the receipt covers the full amount. Overpayment verifies the payment and then offers a refund form. Skipping the form still leaves the payment verified.

Optional client API

PayProof.client() exposes the same public gateway calls without UI. Creating checkouts with an API key is supported for demos only:

Kotlin
val created = PayProof.client().createCheckout(
  CreateCheckoutRequest(
    appId = 1,
    productId = 6,
    customerRef = "order_1001",
    amountEtb = "2499.00", // dynamic one_time only
  )
)
when (created) {
  is PayProofResult.Ok -> PayProofCheckout.present(launcher, this, created.value.publicId)
  is PayProofResult.Err -> { /* created.message */ }
}

Subscription cancel/resume defaults to server-side secret-key calls. Publishable keys may call them only when the app enables client-side cancel/resume. ManageSubscriptionScreen gates the buttons on that setting.

Kotlin
// Prefer secret-key calls from your backend.
when (val res = PayProof.cancelSubscription()) {
  is PayProofResult.Ok -> { /* res.value.cancelAtPeriodEnd */ }
  is PayProofResult.Err -> { /* res.message */ }
}
PayProof.resumeSubscription()

Webhook helper

Kotlin
val ok = WebhookSignature.verify(
  secret = System.getenv("PAYPROOF_WEBHOOK_SECRET")!!,
  rawBody = rawBodyBytes,
  header = payProofSignatureHeader,
)

Same algorithm as webhook signatures: HMAC-SHA256(secret, "$t.$rawBody") with header PayProof-Signature: t=…,v1=….

Diagnose

Run PayProof.diagnose() after initialization to confirm the key, its app binding, and server reachability. It returns the SDK version, key scopes, server time, and any error message in one map.

Kotlin
val report = PayProof.diagnose()
// report["ok"], report["sdkVersion"], report["key"], report["serverTime"], ...