Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mollie gets HTTPresponse 502 back from webhook #9

Closed
owingruters opened this issue Aug 5, 2016 · 6 comments
Closed

Mollie gets HTTPresponse 502 back from webhook #9

owingruters opened this issue Aug 5, 2016 · 6 comments

Comments

@owingruters
Copy link

Hi Vincent,

I have implemented the webhook like this

        [HttpPost]
        public async Task<System.Net.Http.HttpResponseMessage> WebHook([System.Web.Http.FromBody] string id)
{
            string paymentId = id;

            //Do things (that do not throw an error)

            return new HttpResponseMessage(HttpStatusCode.OK);
}

I tried a few methods of returning a httpresponse 200, but it keeps failing which keeps Mollie retrying the webhook call.
I cannot see an implementation in your test project of the webhook and that makes sense, but you must have one, so my question is how do you let Mollie know that their webhook call succeeded?

Thanx a bunch!

Owin

@Viincenttt
Copy link
Owner

Viincenttt commented Aug 5, 2016

Hi Owin,

Here's an example I copied from one of my real life projects:

[HttpPost]
public async Task<ActionResult> ProcessPayment(string id) {
    await this._paymentService.ProcessPayment(id);
    return new HttpStatusCodeResult(HttpStatusCode.OK);
}

Your code looks fine to me. Is this a production or a test environment? Make sure your site publicly available on the internet and isn't blocked by a firewall or something.

You could also try to post a payment id to your site yourself to see if that also gives the same 502 error.

@owingruters
Copy link
Author

Thanx!

It's a test environment. It is publicly available in the cloud, so there
should not be a firewall.
It is also getting reached, because my code is firing and handled, only
the response is not correct.

I see a difference between our codes is that you use an actionresult where
I have used an HttpResponseMessage. I changed it and now I only get 1 call,
so I think they now recieve correct responsecode. Thanx!

Owin

On Fri, Aug 5, 2016 at 10:46 AM, Vincent Kok notifications@github.com
wrote:

Hi Owin,

Here's an example I copied from one of my real life projects:

[HttpPost]public async Task ProcessPayment(string id) {
await this._paymentService.ProcessPayment(id);
return new HttpStatusCodeResult(HttpStatusCode.OK);
}

Your code looks fine to me. Is this a production or a test environment?
Make sure your site publicly available on the internet and isn't blocked by
a firewall or something.

You could also try to post a payment id to site yourself to see if that
also gives the same 502 error.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#9 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALCR14anBwAzg-thPKtKcjXyn1hFU-qxks5qcvhngaJpZM4Jddgc
.

@Viincenttt
Copy link
Owner

Good to hear it's working.

@DianaLaa
Copy link

DianaLaa commented Apr 12, 2018

Sorry to open such an old topic, but could someone help please?

I've tried everything from [FromBody] to just plain string and whatever I do, Mollie gets a 404.

// Nope
[HttpPost]
public HttpResponseMessage Post(string id)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

// Nope
[HttpPost]
public HttpResponseMessage Post([FromBody] string id)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

When I completely remove the id parameter from my method, then Mollie can call it. But obviously, then I don't have the paymentId! :(

// Works, but no id :(
[HttpPost]
public HttpResponseMessage Post()
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

My routing is just default, shouldn't be a big deal right?

config.Routes.MapHttpRoute(
   name: "DefaultApi",
   routeTemplate: "api/{controller}/{id}",
   defaults: new { id = RouteParameter.Optional }
);

Can anyone shed some light on this? I'm pulling my hair out....

@Viincenttt
Copy link
Owner

Looks like it might be a routing issue. Are you able to post to the API controller method yourself? You can test using using a simple plugin such as Postman (https://www.getpostman.com/)

@DianaLaa
Copy link

DianaLaa commented Apr 13, 2018

Hi Vincent,

thank you kindly for your reply.

I've been using Postman, but I am struggling to figure out what to enter for the body:

  • form-data entering key: "id" and value: "test" fails magnificently with an UnsupportedMediaTypeException
  • raw fares no better: If I enter "test", my action is called :) but [FromBody] string id is still null :(
  • Update: Raw with input "{ "id": "test" }" => [FormBody] string id still null

Do you know what the exact format is?

I wish they'd just chosen a querystring parameter.... Would be so much easier.

Final update
Found it!

  1. Set body to "raw" and type to "JSON (application/json)"
  2. Use as body: { id: "test" } (I'm a doofus)
  3. Don't use [FromBody]string id, but create a dedicated object to hold a property:
        public class PaymentId
        {
            public string id { get; set; }
        }

        [HttpPost]
        public HttpResponseMessage Post([FromBody]PaymentId id)
        {
            return new HttpResponseMessage(HttpStatusCode.OK);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants