使用 Hangfire 进行自动支付处理

Using Hangfire for automatic payment processing

我刚刚发现了 hangfire。我已经成功安装了 mysql 存储版本。我想在以下场景中使用它: 每天在 12:01 am 它应该触发一个 ASP.NET MVC5 与 OWIN 和 EF 应用程序控制器操作检查数据库和 select 支付参考由于在相关日期被处理。此操作以向支付处理提供商提供 api url 结束。我的问题是如果我的操作被称为 "ProcessPayments" 我如何设置 hangfire 每天重复这个过程。感谢您的帮助。

以防万一我问这个问题时有人像我一样需要启动推动。使用 Hangfire Mysql Storage、Identity 2、ASP.NET、MVC5、EF、C#,您可以在控制器中创建一个操作,如下所示,为进程添加一个循环作业。

public ActionResult PDPayment(int id)
{                     
string cronExp = "1 12 * * *";
using (ApplicationDbContext db = new ApplicationDbContext())
{
var a = db.DDs.SingleOrDefault(a => a.DDId==id);
RecurringJob.AddOrUpdate(a.id+"-"+a.DDId+"_job", () => ProcessPayments(id), cronExp);
return new EmptyResult();
}    
}

然后您为付款创建方法或逻辑。

 public static void ProcessPayments(int id)
       {
   eg fetch records with id
   create invoice
   process invoice- payment
   update records of payment
   send email
   redirect to success or failed page     
       }