Game Development Reference
In-Depth Information
Log.d(TAG, "Purchase completed: " + result + ", purchase: "
+ purchase);
if (result.isFailure()) {
complain( "Purchase failed: " + result);
return ;
}
if (!verifyDeveloperPayload(purchase)) {
complain( "Authenticity verification failed." );
return ;
}
Log.d(TAG, "Purchase succeeded." );
if (purchase.getSku().equals(ITEM_SKU)) {
consumePurchasedItem();
// mHelper.consumeAsync(purchase, mConsumeFinishedListener);
}
}
};
When you receive the purchase response from Google Play, make sure to check the re-
turned data signature, orderId, and developerPayload string in the Purchase object to make
sure that you are getting the expected values. You should verify that the orderId is a unique
value that you have not previously processed, and the developerPayload string matches the
token that you sent previously with the purchase request.
Step 6: Consuming the purchased item
Once an item is purchased, it is considered to be "owned" and cannot be purchased again
from Google Play while in that state. You must send a consumption request for the item
before Google Play makes it available for purchase again.
In the event of a successful purchase, the mPurchaseFinishedListener implementation
has been configured to call a method named consumePurchasedItem() , which queries the
Search WWH ::




Custom Search