4. Handle completed session
Receiving hooks
You should configure hooks when creating sessions that you listen to to know when a session has completed. Hooks sent by Briqpay will contain the event type, status, sessionId and merchant references. The most common Payments use-case will look like this:
Payment hooks
"hooks": [
{
"eventType": "order_status",
"statuses": ["order_pending", "order_rejected", "order_cancelled", "order_approved_not_captured"],
"method": "POST",
"url": "https://example.com/notifications"
},
{
"eventType": "capture_status",
"statuses": ["pending", "approved", "rejected"],
"method": "POST",
"url": "https://example.com/notifications"
},
{
"eventType": "refund_status",
"statuses": ["pending", "approved", "rejected"],
"method": "POST",
"url": "https://example.com/notifications"
}
],
Since hooks are unauthenticated, you must read the session to verify that the hook is valid.
Payment sessions will be placed with a pending status when completed. Usually orders will leave the pending status within a few minutes, some payment methods excluded. The first hook you receive will usually have the 'order_pending' status meaning you should create your order in a pending state and wait. When you receive a hook with the 'order_approved_not_captured' status, you can create/move your order to a 'placed' status. If for some reason the order was rejected, it will have the 'order_rejected' status.