How do I detect when a Switch Kit / Bill Switch flow has completed events / callbacks?
There are two ways to detect completion: client-side Link events for real-time UI feedback, and server-side webhooks as the authoritative record. We recommend using webhooks as your source of truth, since the client-side events can be missed if a user closes the browser or app before the event fires.
Client-side (Link SDK events/callbacks):
The
onSuccesscallback fires once for each job that completes successfully. Its payload includes ajobfield telling you which job completed (for exampledirect_deposit_switch).If you use the more granular
onEventcallback (or the equivalent specialized callbacks), you'll see asuccessevent for each completed direct deposit switch, andbill_switch_success/bill_switch_failureevents for each individual bill switch attempt.The
exitevent fires when the user closes the modal, with error details included if the session ended because of an error.Because a single Switch Kit session can include both a direct deposit switch and one or more bill switches, you may receive multiple
successand/orbill_switch_successevents within one session — one per completed job.
Server-side (webhooks) — the authoritative source:
Subscribe to
account.added(fires once the user successfully logs into the payroll platform or merchant),direct_deposit_switch.added(fires once a deposit switch completes), andbill_switch.added(fires once a bill switch completes).These fire from Pinwheel's backend once the job is confirmed, independent of whether the client-side event was received, so they're the reliable way to know a switch actually completed.
In practice, most integrations use the client-side events to update the UI in real time, and the webhooks to update their own system of record. See Pinwheel's Link Events guide and Webhooks guide for full payload details, and the Switch Kit implementation guide for the Switch-Kit-specific webhook examples.