After game restart first purchase is contained in receipt but the next ones is the same as first one so new purchases is not added. I afraid players can be charged for purchase but on my server I will not receive new purchases instead receipt with old one so they can do not receive in game currency. Will in production I receive a receipts with new consumable every time player purchase it? I use Unity3d In-app purchasing 5.0.1.
Internal testing. Receipt not always contain last consumable purchase.
//My validator
public static async Task<AppleValidationResult> ValidateReceiptAsync(string base64Receipt)
{
var requestJson = new JObject
{
["receipt-data"] = base64Receipt,
["password"] = SharedSecret
};
var content = new StringContent(requestJson.ToString(), Encoding.UTF8, "application/json");
// First try production
var response = await client.PostAsync(ProductionUrl, content);
var json = JObject.Parse(await response.Content.ReadAsStringAsync());
int status = (int) json["status"];
if (status == 21007) // Receipt from sandbox
{
response = await client.PostAsync(SandboxUrl, content);
json = JObject.Parse(await response.Content.ReadAsStringAsync());
status = (int) json["status"];
Debug.Log("status=" + status);
}
Debug.Log("status="+status);
if (status != 0)
return new AppleValidationResult { Valid = false };
// Get the last in-app purchase
var latestReceipt = json["receipt"]?["in_app"]?.Last;
Debug.Log("latest receipt = " + latestReceipt!=null);
if (latestReceipt == null)
return new AppleValidationResult { Valid = false };
return new AppleValidationResult
{
Valid = true,
TransactionId = latestReceipt["transaction_id"]?.ToString(),
ProductId = latestReceipt["product_id"]?.ToString()
};
}