public async Task <IActionResult> Check() { try { var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync(); WebhookEvent webhookEvent = JsonConvert.DeserializeObject <WebhookEvent>(json); if (webhookEvent.event_type == "PAYMENT.CAPTURE.COMPLETED") { var captureWebhook = JsonConvert.DeserializeObject <PaypalCapture>(json); var captureIntent = await _paypalService.GetCaptureIntent(captureWebhook.Resource.Links[2].Href); if (captureIntent.Status == "COMPLETED") { _donationTransactionService.DeliverByPaypalId(captureIntent.PurchaseUnits[0].Description); return(Ok()); } } else { return(Ok()); } return(BadRequest()); } catch { return(BadRequest()); } }