Hey there, We are currently moving over from V1 to V2. I'm struggling to get in app purchases using real money working as in V1. I am able to make a successful purchase on the google play store. The app switches over to google play's overlay; I purchase the product; and then receive a success on the Unity IAP side.
At this point, I am making the assumption that I need to call RedeemGooglePlayInventoryItems end point in the economy api list. So this is what I am doing. My code is as follows:
public override void ValidateReceipt(PurchaseEventArgs eventArgs,
Action<PlayFabResultCommon> successCallback,
Action<PlayFabError> failedCallback)
{
GooglePlayReceiptDataObject receiptData = new GooglePlayReceiptDataObject();
receiptData.Purchase = GooglePlayReceiptDataObject.GooglePurchase.FromJson(eventArgs.purchasedProduct.receipt);
List<GooglePlayProductPurchase> purchases = new List<GooglePlayProductPurchase>(1);
purchases.Add(new GooglePlayProductPurchase
{
ProductId = eventArgs.purchasedProduct.definition.id,
Token = receiptData.Purchase.PayloadData.signature
});
RedeemGooglePlayInventoryItemsRequest request = new RedeemGooglePlayInventoryItemsRequest
{
Purchases = purchases,
Entity = new PlayFab.EconomyModels.EntityKey
{
Id = PlayFabSettings.staticPlayer.EntityId,
Type = "title_player_account"
}
};
PlayFabEconomyAPI.RedeemGooglePlayInventoryItems(request, successCallback, failedCallback);
}
The json request body generated by this is the following:
{ "CollectionId": null, "CustomTags": null, "Entity": { "Id": "9RemovedTheseCharactersB", "Type": "title_player_account" }, "Purchases": [{ "ProductId": "gold_pack_100", "Token": "ZmPtdNTJE9YeSfgAvRahpFmLyDheTsIP0A12WWXaqaWiS5DjX40ui/Up7ohtW8ETsGbHCxoT5NwqbY3REmovedSomeCharacters+jO6FFkV2+ko6cKkuhV9Q9WzaRnMzqQDwbLiZIuVyFE/0XPy13B0N0q9JTW0Q8AHR+C4vVs6yav6dq6j2GZ/8tYOVMIxbntCOY008ytZaErU/g6PLolU4sEarwW7bH8pFL/ZNYxvVl4yf1xVaWCcmPkLMEjQiO9nblYY/Fv405/Lm+wZQw76ZXtFlPzQhzvlJrdvy0p6Jg==" }], "AuthenticationContext": null }
The response I get back is: { "code": 400, "status": "BadRequest", "error": "InvalidRequest", "errorCode": 1071, "errorMessage": "GetInAppPurchasesFailure: Failed to get purchases from GooglePlay \nReason:Error deserializing JSON credential data." }
I feel like I'm missing something very important here and hoping someone can call out what I might be doing wrong. I should mention that GooglePlayReceiptDataObject is the equivalent of the data objects found in this documentation: https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/tutorials/getting-started-with-unity-and-android With the above documentation being noted as incorrect, I'm unclear on if that data object is even desired?
Also, its important that I am attempting to purchase a bundle and not a store item. The Marketplace ids and friendly ids all match up. In this case is "gold_pack_100", and I am actually able to purchase this item, just not redeem it.
I would REALLY appreciate any help on resolving this as it is a critical piece of the application.
Thanks, ~Nick Thompson