internal PurchaseResponseCallback(CMsgClientPurchaseResponse body) { Result = (EResult) body.eresult; ErrorCode = body.purchase_result_details; ReceiptInfo = body.purchase_receipt_info; PurchaseResult = (EPurchaseResult) ErrorCode; }
internal PurchaseResponseCallback(JobID jobID, CMsgClientPurchaseResponse msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; PurchaseResult = (EPurchaseResult) msg.purchase_result_details; if (msg.purchase_receipt_info == null) { return; } KeyValue receiptInfo = new KeyValue(); using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) { if (!receiptInfo.TryReadAsBinary(ms)) { Logging.LogNullError(nameof(ms)); return; } } List<KeyValue> lineItems = receiptInfo["lineitems"].Children; if (lineItems.Count == 0) { return; } Items = new Dictionary<uint, string>(lineItems.Count); foreach (KeyValue lineItem in lineItems) { uint packageID = lineItem["PackageID"].AsUnsignedInteger(); if (packageID == 0) { // Valid, coupons have PackageID of -1 (don't ask me why) packageID = lineItem["ItemAppID"].AsUnsignedInteger(); if (packageID == 0) { Logging.LogNullError(nameof(packageID)); return; } } string gameName = lineItem["ItemDescription"].Value; if (string.IsNullOrEmpty(gameName)) { Logging.LogNullError(nameof(gameName)); return; } gameName = WebUtility.HtmlDecode(gameName); // Apparently steam expects client to decode sent HTML Items[packageID] = WebUtility.HtmlDecode(gameName); } }
internal PurchaseResponseCallback(CMsgClientPurchaseResponse body) { Result = (EResult) body.eresult; PurchaseResult = (EPurchaseResult) body.purchase_result_details; using (MemoryStream ms = new MemoryStream(body.purchase_receipt_info)) { if (ReceiptInfo.TryReadAsBinary(ms)) { foreach (KeyValue lineItem in ReceiptInfo["lineitems"].Children) { Items.Add((uint) lineItem["PackageID"].AsUnsignedLong(), lineItem["ItemDescription"].AsString()); } } } }
internal PurchaseResponseCallback(JobID jobID, CMsgClientPurchaseResponse msg) { JobID = jobID; if (msg == null) { return; } Result = (EResult) msg.eresult; PurchaseResult = (EPurchaseResult) msg.purchase_result_details; if (msg.purchase_receipt_info == null) { return; } ReceiptInfo = new KeyValue(); using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) { if (!ReceiptInfo.TryReadAsBinary(ms)) { return; } List<KeyValue> lineItems = ReceiptInfo["lineitems"].Children; Items = new Dictionary<uint, string>(lineItems.Count); foreach (KeyValue lineItem in lineItems) { uint appID = (uint) lineItem["PackageID"].AsUnsignedLong(); string gameName = lineItem["ItemDescription"].AsString(); gameName = WebUtility.UrlDecode(gameName); // Apparently steam expects client to decode sent HTML Items.Add(appID, gameName); } } }
internal PurchaseResponseCallback(JobID jobID, CMsgClientPurchaseResponse msg) { JobID = jobID; if (msg == null) { return; } ReceiptInfo = new KeyValue(); Items = new Dictionary<uint, string>(); Result = (EResult) msg.eresult; PurchaseResult = (EPurchaseResult) msg.purchase_result_details; using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) { if (!ReceiptInfo.TryReadAsBinary(ms)) { return; } foreach (KeyValue lineItem in ReceiptInfo["lineitems"].Children) { Items.Add((uint) lineItem["PackageID"].AsUnsignedLong(), lineItem["ItemDescription"].AsString()); } } }