← All work

Linking PayPal without polling · Aug – Sep 2025

Linking PayPal without a live connection to the page

Merchants wanted PayPal as another way to get paid. Linking happens on PayPal’s site, not ours. PayPal’s webhook reached our backend, but nothing carried that news on to the dashboard the merchant had open. Rather than ask the server every few seconds, the dashboard asks at the two moments something could have changed.

Role
Frontend engineer
When
Aug – Sep 2025
Where
PayGlocal
Stack
Next.jsReactTypeScriptPayPal onboarding

The situation

To accept PayPal through us, a merchant signs in to PayPal and agrees to connect their account, on PayPal’s pages, in a flow we don’t control. When they finish, PayPal notifies our backend through a webhook, so the server knows. The dashboard doesn’t: we had no WebSocket or other push channel from server to browser. The usual fallback is polling the status API, but onboarding can take a merchant five minutes or more, and checking every few seconds for that long is dozens of calls that almost all say “not yet”, for every merchant linking at once.

What I built

  • A merchant-facing “link payment methods” page: linked accounts with their status and whether they can receive payments, linking by email, choosing a primary account (only fully linked ones qualify), and viewing a link’s status. Gated by permissions.
  • A configuration page for our internal team, inside the operations console.
  • The linking flow: pressing “Link” opens PayPal’s onboarding in a new tab. The dashboard keeps a handle to that tab and checks, in the browser, whether it’s still open. That check costs nothing on the server.
  • When the merchant finishes, PayPal sends them to our return page, which closes its own tab. The dashboard sees the tab is gone and calls the status API, then refreshes the table.
  • If the merchant switches back to the dashboard tab themselves, with PayPal still open, the dashboard checks the status then too, so it’s never showing something stale while they look at it.
  • While the merchant is on PayPal, a heartbeat keeps their dashboard session alive, and a maximum wait stops the watching if they never come back.
  • On the payment page: PayPal as a payment method, an intermediate screen before handing over to PayPal, and a fallback to card-only payment if PayPal’s details fail to load, instead of a dead end.
Try it

Link an account, the way merchants do

Your dashboard

Payment methods

No PayPal account linked yet.

Status checks, this way
0
If we polled every 5 seconds
0

    Decisions

    Ask when it matters, not on a timer

    The server already knew the answer; the page just needed to ask at the right time. Something can only have changed for the merchant when the PayPal tab closes or when they look at the dashboard again. Those two moments replace a status call every few seconds for as long as onboarding takes.

    Don’t build a socket for one answer

    A WebSocket would let the server push the result, but it’s a new piece of infrastructure to run, secure and reconnect, for one yes-or-no per linking attempt. Browser events we already had did the job.

    Let our return page close the tab

    When PayPal hands the merchant back, our page closes itself. The merchant lands straight back on the dashboard, and the dashboard gets its cue without any message passing between the two tabs.

    Treat “closed” as “go and check”, not “done”

    A merchant can close the tab without finishing. Closing only triggers a status check; the status decides what to show, including a gentle “not linked yet, try again”.

    Keep the session alive while they’re away

    PayPal’s sign-in can take a while. A heartbeat stops the dashboard logging the merchant out mid-flow, and a maximum wait makes sure it doesn’t watch forever.

    Outcome

    WhatBeforeAfterDetail
    Status checks per linking attemptone every few seconds1–2on close or return
    Merchant actions to confirm“I’m done” buttonnoneautomatic
    If PayPal fails on checkoutdead endcard payment still worksfallback

    What I learned

    ↑↓ move↵ openesc close