Как использовать веб-хуки в быстрых книгах онлайн, чтобы показывать уведомление, когда срок оплаты счета истек? - PullRequest
0 голосов
/ 23 октября 2019

Как я могу использовать webhooks в быстрых книгах онлайн, чтобы показывать уведомление, когда срок оплаты счета истек?

Я получил этот код от разработчика intuit, но это не сильно помогает. Я не могу понять, как это сделать.

public class HomeController : Controller
{
    // [ValidateAntiForgeryToken]
    public ActionResult Index()
    {
        // Add intial Data to DB by running the sql cmds from Scripts->InsertScriptWebhooks.sql

        // Get webhooks response payload
        string jsonData = null;
        object hmacHeaderSignature=null;
        if (System.Web.HttpContext.Current.Request.InputStream.CanSeek)
        {
            // Move the cursor to beginning of stream if it has already been by json process
            System.Web.HttpContext.Current.Request.InputStream.Seek(0, SeekOrigin.Begin);
            jsonData = new StreamReader(this.Request.InputStream).ReadToEnd();
            // Get the value of webhooks header's signature
            hmacHeaderSignature = System.Web.HttpContext.Current.Request.Headers["intuit-signature"];
        }

        // Validate webhooks response by hading it with HMACSHA256 algo and comparing it with Intuit's header signature
        bool isRequestvalid = ProcessNotificationData.Validate(jsonData, hmacHeaderSignature);

        // If request is valid, send 200 Status to webhooks sever
        if (isRequestvalid == true)
        {
            return new HttpStatusCodeResult(HttpStatusCode.OK);
        }

        // Default page displayed will be the Index view page when application is running
        return View();
    }
}
...