I use Bubblewrap to turn my PWA into a TWA app on Android and have Google Billing properly enabled. Everything works fine on my Android 11 device, but when I open my app on devices that run Android 6, the PaymentRequest.canMakePayment() method returns false with the error message:

Unable to download payment manifest "https://play.google.com/billing".

Since I can't find any documentation online about how Google Play Billing works with the web Payment Request API, I have no information about the requirements to make it work. I'm also pretty sure that it used to work and I managed to make payments on older Android devices.

Any help would be appreciated!

This is my code:

const getBillingService = async () => {
  if (window.PaymentRequest !== undefined) {
    const dummyMethods = [
      {
        supportedMethods: "https://play.google.com/billing",
      },
    ];
    const dummyDetails = {
      total: {
        label: `Total`,
        amount: { currency: `USD`, value: `0` },
      },
    };
    const dummyRequest = new PaymentRequest(dummyMethods, dummyDetails);
    const possible = await dummyRequest.canMakePayment();
    //true inside my app on newer Android versions, false in older ones
    //with the error Unable to download payment manifest "https://play.google.com/billing".
  }
};

All the requirements to make the Google Play Billing API work are satisfied as far as I know: https context, app downloaded from the Play Store... and it does work on newer devices.

1

There are 1 best solutions below

1
On

Indeed, web application developers are struggling to put an app on Google Play, and when they do, we still have crude limitations.

One of the main difficulties is the lack of updating documentation for web developers (TWA).

I'm currently publishing an app that sells digital goods.

One thing I noticed is that Bubblewrap and PWABuilder are generating outdated aab!

I struggled a lot to find the solution. I had to use Android Studio to open the generated TWA project and update the dependencies! I needed to edit a file called "build.gradle", the Java file and AndroidManifest.xml, for those who don't understand the Java language, it's very difficult!

My app is configured for Android version 8 or higher. Because Android is currently at version 33 of its compiler, and it supports up to Android version 13, but not below Android version 8.

An excerpt from my build.gradle file:

android {
compileSdk 33 // Sdk version with supports for Android 13
defaultConfig {
    applicationId "br.com.example.www.twa"
    minSdkVersion 26 // Sdk minimal version for Android (8.0)
    targetSdkVersion 33 // Same version of "compileSdk"
    versionCode 26 // My App version on Play Console
    versionName "1.0.26" // My App version name on Play Console

If you need your app to work on Android 13, then you will need to give up compatibility with Android versions below 8.0