internal static async Task <AppStoreValidationResult> ValidateReceiptAsync(string receipt) { var responseString = await ValidateReceiptRawAsync(receipt, false); var result = new AppStoreValidationResult(responseString); var json = JsonValue.Parse(responseString); int status = json[_statusValueName]; if (status == 0) { ParseValidationResponse(json, result); } else if (status == 21007) { // This receipt is from the test environment, but it was sent to the production environment for verification. Send it to the test environment instead. responseString = await ValidateReceiptRawAsync(receipt, true); json = JsonValue.Parse(responseString); status = json[_statusValueName]; if (status == 0) { ParseValidationResponse(json, result); } } result.StatusCode = status; result.Status = GetStatusText(status); return(result); }
private static void ParseValidationResponse(JsonValue json, AppStoreValidationResult result) { var receiptData = json[_receiptValueName]; result.Environment = json[_environmentValueName]; result.Receipt = new AppStoreReceipt(); ParseAppReceipt(receiptData, result.Receipt); }