Mangopay / mangopay

MANGOPAY API Known Issues
3 stars 2 forks source link

How Mango Pay HOOKS Works? #54

Closed Aasif001 closed 5 years ago

Aasif001 commented 6 years ago

May i know how this hooks works! I have read the mango pay documentation from here https://docs.mangopay.com/endpoints/v2.01/hooks#e246_the-hook-object but I didn't get an idea about! I just want to know how this hooks works and how we can implement it ? (are works like a cron job??) Please let me know! Thank You!

dkirchhof commented 5 years ago

Hey, i try to steer you in the right direction.

  1. You have to register a specifc route on your server.
    Example in nodejs + express:
    app.get('/payInSucceededHook', (req, res) => {
    // parse the query params here
    });
  2. Add this route to your mangopay account via the api or the dashboard.
  3. As soon as a payin will succeed (in this example), your server will receive the request with some query params. The paying succeeded request will look like this: GET ...serverUrl/payInSucceededHook?Date=1548806400&EventType=PAYIN_NORMAL_SUCCEEDED&RessourceId=123456

If you want to try the hooks before implementing anything, you can use for example this website: https://webhook.site. There you can figure out, which params the hooks will append to your urls (there is no documentation about it). In the dashboard of your mangopay account there is a test the hook option. It will send a request to your specified url.

mickaelpois commented 5 years ago

Thanks @Aasif001 for your question and thanks @dkirchhof for your answer and help. I hope it has been helpful, and feel free to discuss directly on our various SDKs repositories.

julienreszka commented 10 months ago

Can I verify that a request really comes from Mangopay? Or do I have to query the api mangopay to verify the event really happened on the resource?