How we ported Paid to Stripe card readers with one codebase

Some context

What is Paid? A no-code point-of-sale app for Stripe. It runs on iPhone, Android and directly on Stripe smart readers, and payments go straight to your own Stripe account.

Which Stripe card readers does it run on? Directly on the Stripe Reader S700 / S710, Stripe Reader T600, Verifone V660p and Verifone UX700. From a phone, it also works with the BBPOS WisePOS E, BBPOS WisePad 3, Stripe Reader M2 and Tap to Pay. See all supported readers.

Do I need to write code or use a phone? No. Paid runs on the reader itself. You sign in with Stripe and start charging. More in using the Stripe Reader S700 without a phone.

How much does it cost? 0.99% per transaction on top of Stripe's fees, with no monthly or setup fees. You buy the reader from Stripe.

How do you run your own Android app on a Stripe reader? With Stripe Terminal's Apps on Devices. That's what the rest of this post is about.

The starting point

Paid is a Kotlin Multiplatform project. Business logic and API models live in a shared module used by both the iOS and Android apps, and the Android app is built with Jetpack Compose. On phones, payments go through the Stripe Terminal SDK, using Tap to Pay or Bluetooth and internet readers.

Apps on Devices lets you install your own Android app on a Stripe smart reader. The Terminal SDK then talks to the card hardware of the device it's running on. Stripe keeps card collection, PIN entry and the certified payment screens. Your app hands the payment over and gets the result back.

That meant the POS app itself didn't need to change. Only the way it reaches the card hardware did.

One app, two flavors

We didn't fork anything. We added a phone and a reader product flavor to the existing Android module, with a build flag to tell them apart:

create("phone") {
    dimension = "device"
    buildConfigField("boolean", "IS_READER", "false")
}
create("reader") {
    dimension = "device"
    buildConfigField("boolean", "IS_READER", "true")
}

Each flavor pulls in its own Terminal SDK modules. The phone gets the full SDK plus Tap to Pay, and the reader gets the core SDK plus Apps on Devices. The reader's manifest removes permissions it has no use for, like NFC, Bluetooth, biometrics and notifications. The only flavor-specific code is one 8-line file per flavor that starts the Terminal SDK. Everything else is shared.

Connecting to the reader it runs on

On a phone, connecting a reader is a whole flow: pick a type, scan, choose a location, pair. On a smart reader, the reader is the device, so discovery returns it right away:

Terminal.getInstance()
    .discoverReaders(DiscoveryConfiguration.AppsOnDevicesDiscoveryConfiguration())

The app connects on startup and reconnects by itself if the connection drops, so there's no reader setup screen at all. We also tie each session to the hardware. The reader sends its serial number when signing in and with every connection token request, so a session belongs to one physical reader.

Reusing everything else

Checkout, the product catalog, tips, taxes, passing fees to the customer, refunds and transaction history are the same screens and logic as on the phone. The reader-specific changes were small:

  • The amount screen skips the payment method picker, since there's only one method.
  • Cancelling on Stripe's payment screen goes back to the amount screen instead of showing an error.
  • On readers with a printer, like the Verifone V660p, receipts print on the built-in thermal printer.
  • Offline payments are on, so the reader keeps working when the network drops.
  • Things that only make sense on a personal phone are hidden: account switching, reader setup, biometrics and notifications.

All in, that's 62 IS_READER checks across 34 files, out of roughly 220 Kotlin files in the Android app. The port took about two weeks.

Shipping it

The reader app doesn't go through Google Play. Apps on Devices are deployed through the Stripe Dashboard: you upload a signed APK, Stripe reviews it, and you roll it out to readers. The phone app keeps shipping to Play, and the two release independently.

What we learned

Treat the reader as a flavor, not a new app. Most of a POS app is the same on every device. Only the path to the card hardware is different.

Remove more than you add. A reader isn't a personal phone. Most of the work was hiding things.

Let the device own its connection. On a smart reader, the app should connect and reconnect by itself, and never ask.

Try it

If you have a Stripe smart reader, Paid runs on it today. Setup steps for each device are on the card readers page. Not sure which reader to get? Try the reader finder or our comparison of Stripe's smart readers. No hardware yet? Paid also runs on iPhone and Android with Tap to Pay.

Happy coding!