我们已经创建了问题,类似于https://github.com/mollie/api-documentation/issues/583
我们在请求中将webhook URL设置为id参数,但是每次获取id为null时,我的问题是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的金额时,会自动调用,但是每次null时我们都获得ID,但是我们检测到或自动映射了当前创建的支付ID?在webhook URL中。
答案 0 :(得分:0)
您好,我正在使用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
答案 1 :(得分:0)
如果您正在使用似乎无法正确调用的webhook控制器方法而苦苦挣扎:请在id
参数前加上[FromForm]
属性。这样,id
值就可以很好地使用了。
正如documentation所指出的那样,莫里(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 ...
}