I want to be able to use the AppReceiptId from the result of CurrentApp.GetAppReceiptAsync () and bind it to the username in my internal service to make sure that the user actually purchased the application.
I know that I should use CurrentAppSimulator instead of CurrentApp, but CurrentAppSimulator.GetAppReceiptAsync () always returns another random value for AppReceiptId. This makes testing difficult with my service.
Is there a way to make it always return the same value, except using hard coding only? I am worried that when I replace CurrentAppSimulator with CurrentApp and send it to the store, it will not behave as I expect. In the real world, AppReceiptId will never change, right?
The code I use to get AppReceiptId:
var receiptString = await CurrentAppSimulator.GetAppReceiptAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(receiptString); var ReceiptNode = (from s in doc.ChildNodes where s.NodeName == "Receipt" select s).Single(); var AppReceiptNode = (from s in ReceiptNode.ChildNodes where s.NodeName == "AppReceipt" select s).Single(); var idNode = (from s in AppReceiptNode.Attributes where s.NodeName == "Id" select s).Single(); string id = idNode.NodeValue.ToString();
id will always be random Guid.
source share