首页 > 解决方案 > 调用 Mollie webhook URL 但未获取付款 ID

问题描述

我们已经创建了问题,这与 https://github.com/mollie/api-documentation/issues/583 类似

我们已经在请求中设置了 webhook URL 的 id 参数,但是每次我们得到的 id 都是空的,所以我的问题是 id 参数是我们传递还是你方传递了参数?让我知道我们现在遇到了大麻烦。

创建付款响应

{
    "resource": "payment",
    "id": "tr_pCHpdCbpb5",
    "mode": "test",
    "createdAt": "2020-01-24T09:40:18+00:00",
    "amount": {
        "value": "100.10",
        "currency": "EUR"
    },
    "description": "46-201800046",
    "method": null,
    "metadata": null,
    "status": "open",
    "isCancelable": false,
    "expiresAt": "2020-01-24T09:55:18+00:00",
    "profileId": "pfl_wv9K6uRbg7",
    "sequenceType": "oneoff",
    "redirectUrl": "http://localhost:60991/nl-nl/OrderValidation?paymentType=mollie",
    "webhookUrl": "https://devee05.solvisoft.net/api/mollie/webhook",
    "_links": {
        "self": {
            "href": "https://api.mollie.com/v2/payments/tr_pCHpdCbpb5",
            "type": "application/hal+json"
        },
        "checkout": {
            "href": "https://www.mollie.com/payscreen/select-method/pCHpdCbpb5",
            "type": "text/html"
        },
        "documentation": {
            "href": "https://docs.mollie.com/reference/v2/payments-api/create-payment",
            "type": "text/html"
        }
    }
}

当我们支付特定于支付方式的金额时,Webhook URL 自动调用但我们每次都获得 id 为空,但我们检测或自动映射当前创建的支付 id?在 webhook URL 中。

标签: mollie

解决方案


大家好,我正在使用获取 webhook URL 数据Request content

 public virtual HttpResponseMessage Webhook(string id)
{
    StringBuilder sb = new StringBuilder();
    string filePath = System.Web.Hosting.HostingEnvironment.MapPath("~/MollieLog/MollieStatus.txt");
    HttpContent requestContent = Request.Content;
    string jsonContent = requestContent.ReadAsStringAsync().Result;
    sb.AppendLine("Request content - " + jsonContent);

    try
    {
        string mollieResponse = new MollieService(_apiKey).Get(string.Concat("payments/", id));
        sb.AppendLine("ID - " + id);
        sb.AppendLine("Current Date Time " + DateTime.Now);
        sb.AppendLine(mollieResponse);
        sb.AppendLine(Newtonsoft.Json.JsonConvert.SerializeObject(Request.Headers));               
        sb.AppendLine("---------------------------------------");
        File.AppendAllText(filePath, sb.ToString());
        sb.Clear();
    }
    catch (Exception ex)
    {
        sb.AppendLine("Error " + ex.Message);       
        File.AppendAllText(filePath, sb.ToString());
    }
    return Request.CreateResponse(HttpStatusCode.OK);
}

输出

Request content - id=tr_dCCujJWqK9

推荐阅读