android-browser-helper icon indicating copy to clipboard operation
android-browser-helper copied to clipboard

DigitalGoodsApi clientAppUnavailable rejection on service

Open brainfoolong opened this issue 2 years ago • 11 comments

I trying to integrate DigitalGoodsApi. All works fine until the point when calling any service function from the getDigitalGoodsService callback.

window.getDigitalGoodsService('https://play.google.com/billing').then((service) => {
    return service.getDetails(['test']);
})

This will throw DomException: clientAppUnavailable

service is however a proper instance of the goods API. Function getDetails, listPurchases and other's are available, but try to call any of them will throw the error.

Most of the source code bellow is generated directly from https://www.pwabuilder.com/.

Tried on Android API 24 and API 30 within emulator. Chrome version 110 on both API versions (So this should not require any origin trials anymore) CompileSDK Target is 33 (tried with 30 and 31 as well)

The counterpart delegation service is simple

public class DelegationService extends  com.google.androidbrowserhelper.trusted.DelegationService {
    @Override
    public void onCreate() {
        super.onCreate();
        registerExtraCommandHandler(new DigitalGoodsRequestHandler(getApplicationContext()));
    }
}

Gradle deps

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.androidbrowserhelper:billing:1.0.0-alpha09'
    implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0'
}

Android Manifest contains

        <service
            android:name="DelegationService"
            android:enabled="@bool/enableNotification"
            android:exported="@bool/enableNotification">            
                <meta-data
                    android:name="android.support.customtabs.trusted.SMALL_ICON"
                    android:resource="@drawable/ic_notification_icon" />        
            <intent-filter>
                <action android:name="android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </service>


brainfoolong avatar Feb 20 '23 10:02 brainfoolong

We're having this exact error too. We get it while logged into some Google accounts but not others. Did you find a fix @brainfoolong?

monstermac77 avatar Jun 21 '23 18:06 monstermac77

@monstermac77 No. Never had a working version of that. Ended up not using this API.

brainfoolong avatar Jun 22 '23 04:06 brainfoolong

@monstermac77 No. Never had a working version of that. Ended up not using this API.

Got it. What API did you end up using? Since we’re in the Play Store I figured we had to use this API so Google got their 30% cut. Is there another option?

monstermac77 avatar Jun 22 '23 14:06 monstermac77

I guess it's not a topic for this issue. But in short: I know no alternative. In-App Payments in PWA in PlayStore is still a no-no today.

brainfoolong avatar Jun 22 '23 16:06 brainfoolong

I guess it's not a topic for this issue. But in short: I know no alternative. In-App Payments in PWA in PlayStore is still a no-no today.

I assume you mean that it should work, but there's so little support that it's broken and Google doesn't care enough to fix it? It seems pretty austere to promote the use of PWAs, force us to use In-App billing, and then not support the API.

monstermac77 avatar Jun 22 '23 16:06 monstermac77

@brainfoolong Just wanted to follow-up on this since you seem to be the only active person discussing these issues.

We also have since been getting a lot of TypeError: Failed to construct 'PaymentRequest': required member details is undefined. Curious if you ran into that at all or have an idea of what the issue might be. The error is on var request = new PaymentRequest(paymentMethods); where paymentMethods is defined as:

const paymentMethods = [{
     supportedMethods: ["https://play.google.com/billing"],
     data: {
         sku: sku,
     },
}];

This is the full traceback

TypeError: Failed to construct 'PaymentRequest': required member details is undefined.   purchase.js?new1:165 
    at makePurchase (purchase.js:163)
    at HTMLDivElement.<anonymous> (purchase.js:293)
    at HTMLDocument.dispatch (jquery.min.js:5)
    at HTMLDocument.y.handle (jquery.min.js:5)

And purchase.js is: https://www.coursicle.com/all/pwa/js/purchase.js

monstermac77 avatar Jul 06 '23 17:07 monstermac77