-1

我们已经创建了问题,这与 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 中。

4

2 回答 2

0

大家好,我正在使用获取 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
于 2020-01-24T13:28:55.823 回答
0

如果您正在为似乎没有正确调用的 webhook 控制器方法而苦苦挣扎:在id参数前面加上[FromForm]属性。有了这个,这个id值就很好用了。

正如文档指出的那样,Mollie 提出的请求是经过形式编码的:

Content-Type: application/x-www-form-urlencoded

我的控制器方法如下所示:

[HttpPost, Route("paymentstatus", Name = nameof(NotifyPaymentStatusChange))]
public async Task<IActionResult> NotifyPaymentStatusChange([FromForm] string id)
{
    // Use the received id value to continue the payment verification process ...
}
于 2020-11-10T17:42:12.063 回答