Webhooks
7 min
as an order progresses through it's lifecycle, pay3 shares webhook events with the app's backend about the status of order and other relevant details this page explains different status and the information related to the webhook this page also explains how a app can consume the events towards the end of this page api signature the application needs to share an api endpoint to which pay3 service will be sending a webhook as a post request with a payload which contains webhook data below is an example curl of how pay3 service will be calling the provided webhook endpoint with the data the api needs to respond back with http status code 200 on receiving the data curl location 'https //your host webhookserver com/sample webhook path' \\ \ header 'content type application/json' x post \\ \ data '{ "payload" "eyjhbgcioijiuzm4ncj9 eyjvcmrlclr5cguioijgsufuiiwib3jkzxjjzci6ijdhzwqwnjrilwnimmqtndjmoc05ntywltc3ndezzgnjnwzjncisim9yzgvyu3rhdhvzijoiq09nuexfveveiiwib2zmzxjjzci6ijmzmgnkngjilte4ytutngvkzc1hmwy0lwnkmzczmzu2zgewocj9 dmig6ontowke1hegvv62gddnklt9l3fcrqrwemnlqjf565ph28l3 nr7 b1c2ktp" }' sample payload below is an example payload which is received in the webhook events provided by pay3 { "requestid" "ed821e55 7084 467c 9e3f 4279e4d39c97" "data" { "ordertype" "checkout", "orderid" "9c4dd5b3 64de 4d94 b696 3e92cd6b12ba", "orderstatus" "completed" }, "type" "pay3 sdk transaction status" } payload schema data following keys are present in this object ordertype indicates the type of order for which the event is sent for if the given order contains a crypto transaction as well as fiat transaction, two events of different order types will be sent for the same orderid checkout payment done by user using fiat currency payout withdraw fiat request done by user crypto payment done by user using crypto currency orderid it provides a unique identification of the order which is managed by pay3 orderstatus it indicates the various status in which an order can be details about different kind of statuses can be find below error (type object, optional) following keys will be present if there is an error please refer to https //docs pay3 money/fiat docs/sdk errors for reference code (type number) error code message (type string) error message requestid request id that was passed by app while initialising the modal type type of the event 1\ for fiat and crypto orders the app will receive pay3 sdk transaction status 2\ for refund orders the app will receive pay3 sdk refund status 3\ for settlement orders the app will receive pay3 sdk settlement status order status below is the list of status which are shared in webhook for orders related to fiat checkout and payout transactions true 280 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type payment status some of the order status can have payment status true 223,206 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type usage of webhooks functionality the payload of webhooks is in the form of json web tokens (jwt) these tokens can be decoded using a secret to retrieve the status for a given order this secret will be shared by pay3 team sample code to decode data const jwt = require('jsonwebtoken'); let inputdata = 'eyjhbgcioijiuzm4ncj9 eyjvcmrlclr5cguioijgsufuiiwib3jkzxjjzci6ijdhzwqwnjrilwnimmqtndjmoc05ntywltc3ndezzgnjnwzjncisim9yzgvyu3rhdhvzijoiq09nuexfveveiiwib2zmzxjjzci6ijmzmgnkngjilte4ytutngvkzc1hmwy0lwnkmzczmzu2zgewocj9 dmig6ontowke1hegvv62gddnklt9l3fcrqrwemnlqjf565ph28l3 nr7 b1c2ktp'; let secret = 'your client secret'; let decodeddata = jwt verify(data, secret); some of our downstream partners don't provide with all the statuses , in those cases some events might be skipped but completed / failed will always be the terminal events