protected SquareWebhookEvent GetSquareWebhookEvent(HttpRequestBase request, SquareSettings settings)
        {
            const string       EventKey    = "Vendr_SquareEvent";
            SquareWebhookEvent squareEvent = null;

            if (HttpContext.Current.Items[EventKey] != null)
            {
                squareEvent = (SquareWebhookEvent)HttpContext.Current.Items[EventKey];
            }
            else
            {
                try
                {
                    if (request.InputStream.CanSeek)
                    {
                        request.InputStream.Seek(0, SeekOrigin.Begin);
                    }

                    using (var reader = new StreamReader(request.InputStream))
                    {
                        var json = reader.ReadToEnd();

                        var url       = request.Url.ToString();
                        var signature = request.Headers["x-square-signature"];

                        squareEvent         = JsonConvert.DeserializeObject <SquareWebhookEvent>(json);
                        squareEvent.IsValid = ValidateSquareSignature(json, url, signature, settings);

                        HttpContext.Current.Items[EventKey] = squareEvent;
                    }
                }
                catch (Exception ex)
                {
                    Vendr.Log.Error <SquareCheckoutOnetimePaymentProvider>(ex, "Square - GetSquareWebhookEvent");
                }
            }

            return(squareEvent);
        }
 protected string GetOrderId(SquareWebhookEvent squareEvent)
 {
     return(squareEvent?.data?._object?.payment?.order_id ?? "");
 }