id on the payment socket. You
get its current state straight away, then a message each time its status
changes, until it settles or expires.
The socket runs on Socket.IO, on the same host as the REST
API, in the payment namespace:
Connecting
The socket takes the same API key as the REST API. Send it in the handshake asauth.apiKey, or as an x-api-key header if your client sets
headers.
Subscribing to a payment
Subscribe with theid that
POST /pub/v2/payment returned:
Payment not found,
exactly as if it did not exist.
The acknowledgement
The callback you pass tosubscribe receives:
Where the payment stands now, in the same shape as a
PAYMENT_UPDATE.Why the subscription was refused, when
ok is false. The same message is
also sent as an ERROR event.paymentIdis missing or is not a 24-character hex id:A valid paymentId is required.- No payment of your business has that id:
Payment not found. - The connection already watches 50 payments. Unsubscribe from payments that have finished to stay under the limit, or open a second connection.
- The payment could not be looked up at that moment:
Could not look up the payment, try again. You are not subscribed; sendsubscribeagain.
Updates
EveryPAYMENT_UPDATE carries the whole current state of one payment, not just
what changed, so you can handle each one on its own. It has the same shape as
the create payment response, so the type you
use for that response works here too.
Where the payment stands. See Statuses.
The
currency, accountNumber and accountName, for a FIAT payment. The
bank is not included on the socket; use the one from the create response.A deposit may fall up to 0.1% short of
totalAmount and still settle as
SUCCESSFUL, credited for what actually landed; so may one that overpays.
Compare receivedAmount with totalAmount to see what arrived. A deposit any
shorter is not settled: the payment moves to ERROR and stays there.Statuses
Treat
SUCCESSFUL and EXPIRED as the end of a payment. If a payment stays in
ERROR, contact Paj with its id.
Staying connected
Subscriptions belong to the connection. When a connection drops, its subscriptions go with it, and Socket.IO reconnects with a fresh connection and none of them. Subscribe again on everyconnect, not just the first: