Webhooks

7min
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 ( webhooks docid zgiyfgasxs2uqr272qa ) paymentstatus it indicates the payment status of the order details about different kind of payment statuses can be find below ( webhooks docid zgiyfgasxs2uqr272qa ) error (type object, optional) following keys will be present if there is an error please refer to 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 all order status / payment status changes, the type will be pay3 sdk transaction status order status below is the list of status which are shared in webhook for orders related to fiat checkout and payout transactions order status order status description created order initiated order started payment partner has started the order order payment awaiting payment partner is waiting for user to complete the payment order payment processing payment partner checking for payment record user will be shown processing screen order payment initiated payment partner is checking for payment record and will make the payment user can close the pay3 payment screen completed payment is successfully completed failed error occurred during the process abandoned transaction timeout payment status some of the order status can have payment status payment status parent order status payment status description success/completed completed payment completed successfully declined failed declined by payment partner canceled failed user cancelled the transaction max retries reached abandoned transaction timeout under paid failed crypto amount received is less than expected order amount over paid completed crypto amount received is more than order amount refunded failed refund has been completed refund initiated failed refund has been initiated by pay3 refund failed failed there was in issue with refund transaction review created completed in cases where the payment partner requires additional documents before settlement, the payment status changes from completed to review created review submitted completed status after the details are submitted to payment partner for review review inprogress completed status when the payment partner starts reviewing the documents submitted review completed completed status on completion of review, this will be followed by review settled review failed completed expiry of the review request review settled completed status once the funds are transfered from payment partner to app's account, in the cases where review & settlement flow is needed review max retries reached completed review did not reach a terminal status within configured time frame terminal states are review settled, review failed, review max retries reached 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