Whenever I try to use RestoreIOSPurchases with the Unity SDK, I get "Receipt already used." Does anyone have a working example on how to do this? I understand that I need to call restoreCompletedTransactions and pass the receipt to RestoreIOSPurchases, but I can't figure out how to get the proper receipt with Unity/C# or Objective-C.
None of the documentation is helpful:
This Unity Documentation does not explain how to get the receipt:
This Unity post blames Playfab:
ios Restore Transactions appears to refresh receipts rather than restore.
This Playfab post blames Unity:
iOS Restore Purchase Receipt using Unity IAP
I am 100% certain that the Unity IAP Plugin is calling restoreCompletedTransations under the hood because I located the place where it was being called in UnityPurchasing.m.
This code called from ProcessPurchase gives me a "Receipt Already Used" error: The transaction id for the product is different every time so it does seem like a restore receipt rather than a refresh receipt
JSONNode json = JSONNode.Parse(product.receipt); var request = new RestoreIOSPurchasesRequest(); request.ReceiptData = json["Payload"].Value; PlayFabClientAPI.RestoreIOSPurchases(request, OnRestoreIOSPurchase, OnRestoreIOSPurchaseError);
I also tried using the app receipt after restore is finished, but this also gives me a "Receipt Already Used" error.
var request = new RestoreIOSPurchasesRequest(); request.ReceiptData = _appleConfig.appReceipt; PlayFabClientAPI.RestoreIOSPurchases(request, OnRestoreIOSPurchase, OnRestoreIOSPurchaseError);
I could try to bypass Unity entirely and get the receipt in Objective-C where I have direct access to SKPaymentQueue, but this is the callback for when the restore is finished:
-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
SKPaymentQueue has a list of SKPaymentTransactions transactions where "transactionReceipt" is deprecated, so how do I get a single PlayFab compatible receipt out of this function?
I have no idea whether the problem I'm having is, Apple, PlayFab, Unity, or my own bad code, so I'm wondering if anyone has managed to get this working. I've been banging my head against the wall for 2 days trying to get this working and I'm almost to the point of just adding a totally hackable CloudScript function to grant the items or switching to consumable. Please help! Anyone?