androidgoogle-playprogressive-web-appstrusted-web-activitypayment-request-api

service.acknowledge is undefined using Digital Goods API with Google Play in TWA


I have an web app in development to which I am trying to add Google Play Billing on Android and Chrome OS. My implementation is basically the same as in Google's own documentation, however it fails at the point of acknowledging the purchase after it completes, throwing TypeError: service.acknowledge is not a function. Everything else works fine, but not being able to acknowledge the purchase means Google Play automatically reverses it after a period of time.


Solution

  • Apparently that is because they changed the API and just have not yet updated that page of documentation. Apparently service.acknowledge was removed, and they now require passing the purchase token to your own back-end, and then having that call the Google Play Developer API to acknowledge the purchase.

    Unfortunately, that does not seem likely to change, so options like Cordova continue to be the best option for client-only web apps with in-app purchases for the moment.