private void SaveWebhookId(Database.Models.VenmoUser venmoUser, string webhookId, string status, MongoDatabase database) { // Need to save both the status and webhook id because the webhook id is the same between the payment.created and the payment.updated // which means if only the webhook id is stored when the payment is updated the notification will not be routed to the user because // the webhook id was seen during its creation. venmoUser.LastWebhook = $"{status}.{webhookId}"; database.SaveUser(venmoUser); }
private bool WebhookSeenBefore(Database.Models.VenmoUser venmoUser, string webhookId, string status) { if (!string.IsNullOrEmpty(venmoUser.LastWebhook)) { string lastWebhook = venmoUser.LastWebhook; if ($"{status}.{webhookId}" == lastWebhook) { return(true); } } return(false); }