0

We have already created issues and this similar this https://github.com/mollie/api-documentation/issues/583

We have set webhook URL the id parameter in request but every time we got id is null so my question is id parameter are we pass or your side passed the parameter? let me know we are big trouble at this moment.

Create a payment response

{
    "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"
        }
    }
}

When we paid amount specific to payment method Webhook URL automatically called but we got id every time null, but we detected or auto mapped currently created payment id? in webhook URL.

jishan siddique
  • 1,848
  • 2
  • 12
  • 23
  • Show us how you are handling the actual incoming webhook request then …? – 04FS Jan 24 '20 at 10:11
  • For just testing purpose I have created the `method` ` public virtual HttpResponseMessage Webhook(string id) { StringBuilder sb = new StringBuilder(); string filePath = "Path" try { string mollieResponse = new MollieService(_apiKey).Get(string.Concat("payments/", id)); sb.AppendLine("ID - " + id); sb.Clear(); } catch (Exception ex) { //erro log set } }` – jishan siddique Jan 24 '20 at 10:40
  • Is there any way to get recent created payment id in mollie becue we are got hold response when we created payment but main question is when we are are send the request in mollie server we pass the `Webhook` URL and `redirect UR` after payment user back in the `redirect URL` but webhook URL call in background but `id` is empty way? mollie webhook URL - `https://docs.mollie.com/guides/webhooks` – jishan siddique Jan 24 '20 at 10:44
  • What is `"webhookUrl": "https://devee05.solvisoft.net/api/mollie/webhook?id=TestID"` supposed to be? Why does that contain a GET parameter named `id` at this point? – 04FS Jan 24 '20 at 10:44
  • If I'm not sending in parameter mollie not sending any id? just for testing purpose I passed the `TestID` – jishan siddique Jan 24 '20 at 10:45
  • Is there any way to get `payment` after payment status change in the mollie server auto called any callback URL? – jishan siddique Jan 24 '20 at 10:46
  • 1
    _“If I'm not sending in parameter mollie not sending any id?”_ - what gave you that idea? That should most likely be just `https://devee05.solvisoft.net/api/mollie/webhook` at this point. – 04FS Jan 24 '20 at 10:47
  • If we don't pass `payment id` in webhook URL `(while Create payment API call)` then when provider automatically calls webhook URL. is that contains `paymentId` in post-call of `webhook`? – jishan siddique Jan 24 '20 at 10:52
  • 1
    You just specify the endpoint URL under which you want to receive this, no extra parameters. They will then make a POST request to that URL, and include a parameter named `id` with that. I don’t know how that could be put any simpler or clearer. – 04FS Jan 24 '20 at 10:56
  • i am facing similar issue and from mollie support i didn't receive any response – Nishang Raiyani Jun 09 '23 at 04:06
  • hi @NishangRaiyani, please check this https://stackoverflow.com/a/59897425/5855884 – jishan siddique Jun 09 '23 at 04:56
  • @jishansiddique i want to integrate in nodejs so this is not possible in nodejs if you have another solution so please provide i highly appreciate it – Nishang Raiyani Jun 09 '23 at 05:39
  • Sorry @NishangRaiyani, I was not aware of this. just a request if you found the solution could you please add the answer? so if anyone finds the issue he/she can get the right path. – jishan siddique Jun 10 '23 at 07:41
  • 1
    @jishansiddique Certainly! If I find a solution, I will share it here. – Nishang Raiyani Jun 12 '23 at 03:41

2 Answers2

1

If you are struggling with the webhook controller method appearing not to be properly called: prefix the id parameter with the [FromForm] attribute. With that, the id value is nicely available.

As the documentation points out, the request made by Mollie is form encoded:

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

My controller method looks like this:

[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 ...
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
0

Hello all I'm getting the webhook URL data using 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);
}

Output

Request content - id=tr_dCCujJWqK9
jishan siddique
  • 1,848
  • 2
  • 12
  • 23