Skip to content

Quickstart

This guide puts the payroll dashboard for one of your customers into your app, in Sandbox.

  1. Get your Sandbox secret key.

    In the Friendly Payroll dashboard, switch to Sandbox and copy a secret key. It starts with sk_sandbox_. Keep it on your server, for example in an environment variable called FRIENDLY_PAYROLL_SECRET_KEY.

  2. Create a Session on your server.

    Add an endpoint to your backend that your frontend can call when it’s about to show payroll. It creates a Session for the signed-in customer:

    // e.g. GET /payroll-session in your backend
    const res = await fetch(
    'https://api.sandbox.friendlypayroll.com/v1/sessions',
    {
    method: 'POST',
    headers: {
    Authorization: `Bearer ${process.env.FRIENDLY_PAYROLL_SECRET_KEY}`,
    'Content-Type': 'application/json',
    },
    body: JSON.stringify({
    screens: ['employer-dashboard'],
    // Your own ID for this customer. The name is only needed the first time.
    employer: {
    externalId: account.id,
    name: account.businessName,
    },
    }),
    },
    );
    if (!res.ok) throw new Error((await res.json()).error.message);
    const { clientSecret } = await res.json();
    return { clientSecret };

    Check that the person asking is allowed to manage this customer’s payroll before you create the Session. The Session grants access to whatever Screens you list.

  3. Render the Screen in your frontend.

    Terminal window
    npm install @friendlypayroll/react
    import { FriendlyPayroll } from '@friendlypayroll/react';
    export function PayrollPage({ clientSecret }: { clientSecret: string }) {
    return (
    <FriendlyPayroll
    clientSecret={clientSecret}
    screen="employer-dashboard"
    style={{ height: '80vh' }}
    />
    );
    }
  4. Open the page.

    The first load for a new Employer takes a few extra seconds while it’s set up. After that, Screens load immediately.