// Encrypt the receipts and save them to file. void ToCache(IList<Receipt> receipts) { 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); r.Put("priceInCents", receipt.PriceInCents); r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString()); r.Put("generatedDate", receipt.GeneratedDate.ToGMTString()); r.Put("gamerUuid", receipt.Gamer); r.Put("uuid", receipt.Uuid); 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); } } }
// Encrypt the receipts and save them to file. 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); } } }