您可以通过消费该项目轻松否定购买以进行测试。
使用 Trivial Drive 示例,我在 MainActivity.java 中添加了以下代码,这将在应用程序启动时“消耗”高级升级:
// Do we have the premium upgrade?
Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
// dss added for test: Consume the premium upgrade for test purposes.
boolean testConsume = true;
if (mIsPremium && testConsume) {
Log.d(TAG, "NOT FOR PRODUCTION: We have a premium upgrade. Consuming it.");
mHelper.consumeAsync(inventory.getPurchase(SKU_PREMIUM), mConsumeFinishedListener);
mIsPremium = false;
} //dss end add
作为奖励,当您消费升级时,您将获得免费的四分之一油箱,因为样本将所有消费视为其他地方的汽油。在 MainActivity 中搜索“Provisioning”以查找位置。