We are servicing a game that applies Unity IAP in the Amazon AppStore.
Yesterday I got an email from one of our customers saying “I made a payment but didn’t get the product.”
When I check the log remaining on the game server (the parameter passed to the callback function called from Unity IAP is transmitted as it is), the Unity IAP’s OnPurchaseFailure callback was called, but there was a normal receipt in the product passed as a parameter. I also confirmed that the payment was OK by sending the receipt delivered to Amazon RVS.
Why was the payment made normally and the receipt was included, but the OnPurchaseFailure callback was called?
This phenomenon doesn’t always happen, of course, and it’s the first time we’ve seen it.
We are using Unity LTS 2018.4.26f1, and Unity IAP is using 2.0.0.
====== Method to send log to server
public void OnPurchaseFailed(UnityEngine.Purchasing.Product product, PurchaseFailureReason r)
{
try
{
Console.Debug(“[UnityPayment] OnPurchaseFailed”);
// ~~~~~~~ //
}
catch (Exception e)
{
Console.Exception(e);
}
finally
{
SendUnityPurchaseFailed(product, r);
}
}
void SendUnityPurchaseFailed(UnityEngine.Purchasing.Product product, PurchaseFailureReason r)
{
LogEvent logEvent = new LogEvent(
“UNITY_IAP_EVENT”,
“FAILURE”
);
JsonMap eventPayload = new JsonMap();
try
{
eventPayload[“reason”] = r.ToString();
if (product != null)
{
if (product.definition != null)
{
if (string.IsNullOrEmpty(product.definition.id) == false) eventPayload[“productCode”] = product.definition.id;
}
if (string.IsNullOrEmpty(product.transactionID) == false) eventPayload[“transactionId”] = product.transactionID;
if (string.IsNullOrEmpty(product.receipt) == false) eventPayload[“receipt”] = product.receipt;
}
}
catch (System.Exception e)
{
Console.Exception(e);
eventPayload[“exception”] = e.ToString();
}
finally
{
logEvent.EventPayload = eventPayload.ToString();
LogEvent.AddLog(logEvent);
}
}
====== Log left on the server(User ID and receipt ID are hidden because they are customer information.)
{
“reason”: “Unknown”,
“productCode”: “AMAZON.GEM_USD20”,
“receipt”: “{"Store":"AmazonApps","TransactionID":"XK0ZlsOzT5q7nVbDgIxYJ_RQM3m_dDX2sLK7eutvPQI=:1:11","Payload":"{\"receiptId\":\"\",\"userId\":\"\",\"isSandbox\":false,\"productJson\":{\"sku\":\"AMAZON.GEM_USD20\",\"productType\":\"CONSUMABLE\",\"description\":\"with 140 VIP Points\",\"price\":\"$19.99\",\"smallIconUrl\":\"http:\\/\\/ecx.images-amazon.com\\/images\\/I\\/617EokMKxbL.SL110_FMPNG_h1.png\",\"title\":\"Pouch of Gems\"},\"receiptJson\":{\"receiptId\":\"\",\"sku\":\"AMAZON.GEM_USD20\",\"itemType\":\"CONSUMABLE\",\"purchaseDate\":\"Sun Nov 01 00:43:27 MDT 2020\"}}"}”
}