static void ToCache(IList<Receipt> receipts, string gamerUuid)
{
OuyaFacade.Log("Caching receipts");
var json = new JSONObject();
var array = new JSONArray();
foreach (var receipt in receipts)
{
var r = new JSONObject();
r.Put("identifier", receipt.Identifier);
// PriceInCents is now deprecated. Use LocalPrice and CurrencyCode instead.
// Retain field for compatibility.
r.Put("priceInCents", 0);
r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString());
r.Put("generatedDate", receipt.GeneratedDate.ToGMTString());
r.Put("gamerUuid", receipt.Gamer);
r.Put("uuid", receipt.Uuid);
r.Put("localPrice", receipt.LocalPrice);
r.Put("currencyCode", receipt.Currency);
array.Put(r);
}
json.Accumulate("receipts", array);
var text = json.ToString();
var encryptedReceipts = CryptoHelper.Encrypt(text, gamerUuid);
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var writer = new StreamWriter(store.OpenFile(receiptsFileName, FileMode.OpenOrCreate)))
{
writer.Write(encryptedReceipts);
}
}
}