Exemplo n.º 1
0
        static void Main(string[] args)
        {
            RegisterServices();
            var receipt = "MIIcSAYJKoZIhvcNAQcCoIIcOTCCHDUCAQExCzAJBgUrDgMCGgUAMIIL+QYJKoZIhvcNAQcBoIIL6gSCC+YxggviMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgEDAgEBBAMMATEwCwIBCwIBAQQDAgEAMAsCAQ4CAQEEAwIBWjALAgEPAgEBBAMCAQAwCwIBEAIBAQQDAgEAMAsCARkCAQEEAwIBAzAMAgEKAgEBBAQWAjQrMA0CAQ0CAQEEBQIDAV+QMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDIzNDAYAgEEAgECBBDE3UBUsLYaB761hfaoQuBIMBsCAQACAQEEEwwRUHJvZHVjdGlvblNhbmRib3gwHAIBBQIBAQQULgoRW+rBxXAjpb03NJlVqa2Z200wHQIBAgIBAQQVDBNjb20ubWJhYXN5Lmlvcy5kZW1vMB4CAQwCAQEEFhYUMjAxNS0wOC0xM1QwNzo1MDo0NlowHgIBEgIBAQQWFhQyMDEzLTA4LTAxVDA3OjAwOjAwWjBLAgEHAgEBBEPixSwGknvYHA7GNo11ue/NJtHjgD6PTlcYOBGS4D+bAG3hIUBsvRx0RDoaF7CUW1XeUoKFE/jqIHH5AzsHl3pS/WYgMGECAQYCAQEEWRhf33g2yaZFPTmP34+a61oc/n3P7iVoZOuazq1x1u1JXgIDY2hJpxZU4y6o5FBZ8JZC+6uvjOlYYiOd9QfeqHBV4YwCU5Mbd5L2aJji1yJYTDmqHEroWyJ4MIIBTwIBEQIBAQSCAUUxggFBMAsCAgasAgEBBAIWADALAgIGrQIBAQQCDAAwCwICBrACAQEEAhYAMAsCAgayAgEBBAIMADALAgIGswIBAQQCDAAwCwICBrQCAQEEAgwAMAsCAga1AgEBBAIMADALAgIGtgIBAQQCDAAwDAICBqUCAQEEAwIBATAMAgIGqwIBAQQDAgEBMAwCAgauAgEBBAMCAQAwDAICBq8C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PY0eAtCToLpBfGdL2I3ymDFJWiQbCuuNRa/PfGBFpMc0PGSqyQ0C5GFULTDVU=";

            if (_parserService != null)
            {
                var             data         = Convert.FromBase64String(receipt);
                AppleAppReceipt parserResult = _parserService.GetAppleReceiptFromBytes(data);
                Console.WriteLine($"Parser Works. Bundle ID:{parserResult.BundleId}");
            }
            else
            {
                Console.WriteLine($"Parser Doesn't work");
            }
            if (_verificatorService != null)
            {
                AppleReceiptVerificationResult verificationResult = _verificatorService.VerifyAppleReceiptAsync(receipt).Result;
                Console.WriteLine($"Verificator Works. Verification status:{verificationResult.Status}");
            }
            else
            {
                Console.WriteLine($"Verificator Doesn't work");
            }
        }
        public string CheckParser()
        {
            var             data = Convert.FromBase64String(_config.AppleReceiptExample);
            AppleAppReceipt verificationResult = _appleParserService.GetAppleReceiptFromBytes(data);

            return(JsonConvert.SerializeObject(verificationResult));
        }
        private async Task <AppleReceiptVerificationResult?> VerifyReceiptAsync(string receiptData, IRestService restService)
        {
            // 1. Validate incoming arguments
            if (string.IsNullOrEmpty(receiptData))
            {
                _logger.LogInformation("receiptData cannot be empty");

                return(new AppleReceiptVerificationResult(
                           "receiptData cannot be empty",
                           IAPVerificationResponseStatus.WrongArgument
                           ));
            }

            // 2. Pre-validate Receipt (Optional)
            try
            {
                var data    = Convert.FromBase64String(receiptData);
                var receipt = _receiptParserService.GetAppleReceiptFromBytes(data);

                // a. Validate bundle ID
                if (receipt != null && !_settings.Value.AllowedBundleIds.Contains(receipt.BundleId))
                {
                    _logger.LogInformation("Receipt has wrong bundle ID {bundle_id}", receipt.BundleId);

                    return(new AppleReceiptVerificationResult(
                               $"Receipt has wrong bundle ID {receipt.BundleId}",
                               IAPVerificationResponseStatus.WrongArgument
                               ));
                }

                if (_customValidation != null)
                {
                    // if custom Validator implemented
                    var validationResult = _customValidation.ValidateReceipt(receipt);

                    if (validationResult == null || validationResult.Status != IAPVerificationResponseStatus.Ok)
                    {
                        // and custom validation doesn't passed - failed
                        return(validationResult);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Something went wrong in receipt prevalidation. Seems to be invalid receipt data. Skip this step.");
            }

            // 3. Validate Receipt in Apple (verification in IAP)
            try
            {
                _logger.LogDebug("Start receipt verification in IAP...");
                var request = new IAPVerificationRequest(receiptData, _settings.Value.VerifyReceiptSharedSecret);
                IAPVerificationResponse iapVerificationResult = await restService.ValidateAppleReceiptAsync(request).ConfigureAwait(false);

                if (iapVerificationResult == null)
                {
                    return(new AppleReceiptVerificationResult(
                               "IAP receipt verification failed. Apple returned empty receipt.",
                               IAPVerificationResponseStatus.InternalVerificationFailed
                               ));
                }

                var iapStatus = iapVerificationResult.StatusCode;
                // 1.If status <> 0 - failed
                if (iapStatus != IAPVerificationResponseStatus.Ok)
                {
                    return(new AppleReceiptVerificationResult(
                               "IAP receipt verification failed",
                               iapVerificationResult
                               ));
                }

                _logger.LogInformation("IAPReceipt Verification passed.");

                return(new AppleReceiptVerificationResult(
                           "Everything is OK.",
                           iapVerificationResult
                           ));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Something went wrong in IAP receipt verification");

                return(new AppleReceiptVerificationResult(
                           "Something went wrong in IAP receipt verification",
                           IAPVerificationResponseStatus.InternalVerificationBroken
                           ));
            }
        }