We are making some changes to the Digital Goods API (DGAPI) that will address feedback we’ve heard from you and other developers, as well as close some potential fraud avenues. DGAPI 2.0 will require some changes in your web app and backend, but you won’t need to upload a new package to the Play Store.
The new API will land in Chrome 96 whose stable launch is scheduled for November 15th on Android, and November 30th on ChromeOS.
This guide will take you through the steps to update your web app and backend in order to make it compatible with both DGAPI 1.0 and 2.0. In order to avoid breakage, please make your changes before the Chrome 96 launch date.
Both DGAPI 1.0 and 2.0 use the async
getDigitalGoodsService() method to retrieve the service object. In DGAPI 1.0, this method would return
null if the given service URL is not supported. In DGAPI 2.0, the method throws an error instead.
In order to handle this change, use the following snippet to instantiate your service object:
In DGAPI 1.0, the acknowledgement and consumption of items that can be purchased multiple times is handled by calling the
acknowledge() method with
DGAPI 2.0 introduces the
consume() method to mark such items as consumed.
If you offer consumable in-app purchases in your app, follow these steps:
- Check if the
- If yes, this means the client is running DGAPI 1.0 on Chrome 95 or earlier. Use the
acknowledge()method to consume the item.
- Otherwise, the client is running DGAPI 2.0 on Chrome 96 or later. Use the
consume()method to consume the item.
Here’s a snippet:
DGAPI 2.0 removes the
acknowledge() method. Purchase acknowledgement must be made instead on the backend using Google Play Developer API’s acknowledge methods.
If you currently acknowledge purchases on the client, follow these steps to move it to your backend:
- Remove all references to the DGAPI
acknowledge()method called with the
'onetime'purchase type in your web app.
In DGAPI 1.0, the
purchaseDetails object returned by the
listPurchases() method includes the
purchaseState field that can be used to determine whether to grant entitlements.
DGAPI 2.0 reduces the
purchaseDetails object to contain only the
purchaseToken and the
itemId. Thus, you must grant entitlement to a purchase by checking with your backend instead.
Follow our guideline to verify purchases on your back-end server before granting entitlements to replace your client side code.
Please note that Digital Goods API 2.0 will be run as a new origin trial. The Digital Goods API 1.0 origin trial will still last until its expiry date but will apply only to users on M95 and below.
You will need to register separately for the 1.0 and the 2.0 origin trials, and place both keys in your website in order to keep compatibility with both APIs.
Here are the links to both Origin Trials:
The full interface to DGAPI 2.0 is available in the explainer
As announced at Chromium Dash:
- October 21: Chrome 96 beta
- November 15: Chrome 96 stable. DGAPI 2.0 is available on Android.
- November 30: ChromeOS 96 stable. DGAPI 2.0 is available on ChromeOS.