Example #1
0
        public static string GetFriendlyEPurchaseResultDetailMsg(EPurchaseResultDetail result)
        {
            switch (result)
            {
            case EPurchaseResultDetail.k_EPurchaseResultNoDetail:
                return("Success");

            case EPurchaseResultDetail.k_EPurchaseResultAlreadyPurchased:
                return("Already registered");

            case EPurchaseResultDetail.k_EPurchaseResultRestrictedCountry:
                return("Key restricted country");

            case EPurchaseResultDetail.k_EPurchaseResultBadActivationCode:
                return("Bad activation key");

            case EPurchaseResultDetail.k_EPurchaseResultDuplicateActivationCode:
                return("Duplicate activation code");

            case EPurchaseResultDetail.k_EPurchaseResultRegionNotSupported:
                return("Region not supported");

            case EPurchaseResultDetail.k_EPurchaseResultInvalidAccount:
                return("Invalid account");

            case EPurchaseResultDetail.k_EPurchaseResultDoesNotOwnRequiredApp:
                return("Does not own required app to register this key");

            case EPurchaseResultDetail.k_EPurchaseResultTooManyActivationAttempts:
                return("Too many activation attempts. Try again later.");

            default:
                return(result.ToString());
            }
        }
Example #2
0
            internal PurchaseResponseCallback(EResult result, EPurchaseResultDetail purchaseResult)
            {
                if (!Enum.IsDefined(typeof(EResult), result) || !Enum.IsDefined(typeof(EPurchaseResultDetail), purchaseResult))
                {
                    throw new ArgumentNullException(nameof(result) + " || " + nameof(purchaseResult));
                }

                Result = result;
                PurchaseResultDetail = purchaseResult;
            }
Example #3
0
            internal PurchaseResponseCallback(EResult result, EPurchaseResultDetail purchaseResult)
            {
                if (!Enum.IsDefined(typeof(EResult), result))
                {
                    throw new InvalidEnumArgumentException(nameof(result), (int)result, typeof(EResult));
                }

                if (!Enum.IsDefined(typeof(EPurchaseResultDetail), purchaseResult))
                {
                    throw new InvalidEnumArgumentException(nameof(purchaseResult), (int)purchaseResult, typeof(EPurchaseResultDetail));
                }

                Result = result;
                PurchaseResultDetail = purchaseResult;
            }
Example #4
0
        private void onPurchaseResponse(PurchaseResponse_t callback)
        {
            EPurchaseResultDetail result = (EPurchaseResultDetail)callback.m_EPurchaseResultDetail;

            switch (result)
            {
            case EPurchaseResultDetail.k_EPurchaseResultTooManyActivationAttempts:
                _purchaseBwg.CancelAsync();
                completedRegistration();
                break;
            }

            //_result.AddResult(Utils.GetFriendlyEPurchaseResultDetailMsg(result)); // тут баг краш при валидном ключе
            _waitingForActivationResp = false;
        }
        public PurchaseResponseCallback(JobID _jobID, CMsgClientPurchaseResponse _clientPurchaseMessage)
        {
            JobID = _jobID;
            m_PurchaseResultDetail = (EPurchaseResultDetail)_clientPurchaseMessage.purchase_result_details;
            m_Result = (EResult)_clientPurchaseMessage.eresult;

            KeyValue receiptInfo = new KeyValue();

            using (MemoryStream memoryStream = new MemoryStream(_clientPurchaseMessage.purchase_receipt_info))
            {
                if (!receiptInfo.TryReadAsBinary(memoryStream))
                {
                    return;
                }
            }

            List <KeyValue> lineItems = receiptInfo["lineitems"].Children;

            foreach (KeyValue lineItem in lineItems)
            {
                uint packageID = lineItem["PackageID"].AsUnsignedInteger();
                if (packageID == 0)
                {
                    packageID = lineItem["ItemAppID"].AsUnsignedInteger();
                    if (packageID == 0)
                    {
                        return;
                    }
                }

                string gameName = lineItem["ItemDescription"].Value;
                if (string.IsNullOrEmpty(gameName))
                {
                    return;
                }

                gameName           = WebUtility.HtmlDecode(gameName);
                m_Items[packageID] = gameName;
            }
        }
Example #6
0
            internal PurchaseResponseCallback(JobID jobID, CMsgClientPurchaseResponse msg)
            {
                if ((jobID == null) || (msg == null))
                {
                    throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
                }

                JobID = jobID;
                PurchaseResultDetail = (EPurchaseResultDetail)msg.purchase_result_details;

                if (msg.purchase_receipt_info == null)
                {
                    ASF.ArchiLogger.LogNullError(nameof(msg.purchase_receipt_info));
                    return;
                }

                KeyValue receiptInfo = new KeyValue();

                using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) {
                    if (!receiptInfo.TryReadAsBinary(ms))
                    {
                        ASF.ArchiLogger.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)
                    {
                        // Coupons have PackageID of -1 (don't ask me why)
                        // We'll use ItemAppID in this case
                        packageID = lineItem["ItemAppID"].AsUnsignedInteger();
                        if (packageID == 0)
                        {
                            ASF.ArchiLogger.LogNullError(nameof(packageID));
                            return;
                        }
                    }

                    string gameName = lineItem["ItemDescription"].Value;
                    if (string.IsNullOrEmpty(gameName))
                    {
                        ASF.ArchiLogger.LogNullError(nameof(gameName));
                        return;
                    }

                    // Apparently steam expects client to decode sent HTML
                    gameName         = WebUtility.HtmlDecode(gameName);
                    Items[packageID] = gameName;
                }
            }