public BraintreeWebhookResponse Post(BraintreeWebhook request)
        {
            // https://developers.braintreepayments.com/reference/general/webhooks/subscription/dotnet

            var gateway             = config.GetGateway();
            var shouldCancelPremium = new List <WebhookKind>
            {
                WebhookKind.SUBSCRIPTION_WENT_PAST_DUE,
                WebhookKind.SUBSCRIPTION_EXPIRED,
                WebhookKind.SUBSCRIPTION_TRIAL_ENDED
            };

            var shouldCancelSubscription = new List <WebhookKind>
            {
                WebhookKind.SUBSCRIPTION_CANCELED
            };

            var shouldSetPremium = new List <WebhookKind>
            {
                WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY
            };

            var webhookNotification = gateway.WebhookNotification.Parse(
                request.bt_signature,
                request.bt_payload
                );

            // Log?
            // Timestamp: DateTime.Now()
            // Webhook Signature: request.bt_signature
            // Webhook Payload: request.bt_payload
            // Kind: webhookNotification.Kind
            // SubscriptionId: webhookNotification.Subscription.Id


            if (webhookNotification.Subscription != null)
            {
                var subscription = webhookNotification.Subscription;
                var user         = Db.Select <User>(u => u.BraintreeSubscriptionId == subscription.Id).FirstOrDefault();

                if (user != null)
                {
                    if (shouldCancelPremium.Contains(webhookNotification.Kind))
                    {
                        CancelUserPremium(user);
                    }
                    else if (shouldSetPremium.Contains(webhookNotification.Kind))
                    {
                        SetUserPremium(user, subscription.Id, subscription.BillingPeriodEndDate);
                    }
                    else if (shouldCancelSubscription.Contains(webhookNotification.Kind))
                    {
                        CancelUserSubscription(user);
                    }
                }
            }


            return(new BraintreeWebhookResponse {
                Success = true
            });
        }
 // *
 // Braintree
 public BraintreeWebhookResponse Get(BraintreeWebhook request)
 {
     return(new BraintreeWebhookResponse {
         Success = true
     });
 }