Assembly: embedded payments for platforms
Fieldhouse, a booking-software platform, boards independent fitness studios as sub-merchants on GP API, takes payments on their behalf, splits each payment, holds risky funds and pays studios out.
The story
Fieldhouse is a fictional booking-software platform for independent fitness studios. It acts as an ISV / PayFac: it boards each studio as a sub-merchant, takes class and membership payments on the studio's behalf, splits every payment between the studio and Fieldhouse's platform fee, holds funds when a payment looks risky, and pays studios out. Assembly is the platform operator's console for all of that on GP API, through the typed TypeScript SDK.
| At a glance | |
|---|---|
| Global Payments vertical | Embedded payments for platforms (ISV / PayFac) |
| GP API operations | 18 |
| Live app | gpx-assembly.pages.dev |
| Stack | Vite, React, TypeScript, Tailwind; Hono on Cloudflare Pages Functions |
Screens
| Screen | What you do | SDK calls |
|---|---|---|
| Onboarding | See every studio in a boarding pipeline, open one to read its boarding timeline and what GP holds on file, board a new studio (address lookup, business, owner), edit or resubmit details, upload a verification document and watch GP verify it | merchants.getMerchants, .getMerchantSingle, .addressLookup, .boardMerchant, .editMerchant, accounts.getMerchantAccounts, fileProcessing.createUrl, .uploadFile, .getFileDetails |
| Payments & splits | Charge a booking for a studio with a sandbox test card, set the platform fee, and see the split drawn as money flowing to the studio and to Fieldhouse. Reverse all or part of any split | transactionsApi.createSaleOrRefundTransaction, .splitTransaction, transfers.listTransfers, .reverseExistingSplit |
| Risk holds | Fieldhouse's own rules score last week's bookings; hold a payment so it does not fund, or release it | transactionsApi.holdTransaction, .releaseTransaction, transfers.listTransfers |
| Payouts | A six-week payout calendar per studio: splits landing each day and every payout; pay out the available balance now, or top a studio up | funds.listFunds, .fundMerchant, accounts.getMerchantAccounts, transfers.listTransfers |
The Wire drawer (bottom of every screen, or press the backtick key) shows every typed SDK call a screen made, with the HTTP request and response, timing, retries and how any error was translated. It can make GP rate-limit the next read or expire the access token, to show the retry and refresh paths. Ctrl+K / ⌘K jumps to a screen, a studio (MER_…) or a payment (TRN_…).
GP API operations
| Operation | SDK method | Used for |
|---|---|---|
| Create access token | accessToken.getAccessToken | Platform credentials: nonce + SHA512 secret, cached |
| Address lookup | merchants.addressLookup | Validate the studio's address while boarding |
| Board a merchant | merchants.boardMerchant | Create the studio as a sub-merchant |
| List merchants | merchants.getMerchants | The studio roster |
| Get a merchant | merchants.getMerchantSingle | Boarding status and details |
| Edit a merchant | merchants.editMerchant | Update studio details |
| Create upload URL | fileProcessing.createUrl | Get a URL for a KYC document |
| Upload a file | fileProcessing.uploadFile | Send the KYC document |
| Get file details | fileProcessing.getFileDetails | Document review status |
| List merchant accounts | accounts.getMerchantAccounts | The studio's transaction and funding accounts |
| Create sale or refund | transactionsApi.createSaleOrRefundTransaction | Take a payment for the studio |
| Split a transaction | transactionsApi.splitTransaction | Studio share and platform fee |
| List transfers | transfers.listTransfers | The split graph |
| Reverse a split | transfers.reverseExistingSplit | Undo a split |
| Hold a transaction | transactionsApi.holdTransaction | Hold risky funds |
| Release a transaction | transactionsApi.releaseTransaction | Release after review |
| Fund a merchant | funds.fundMerchant | Pay the studio out |
| List funds | funds.listFunds | Payout history |
The flow: from a new studio to its first payout
- Token. Fieldhouse mints a platform access token with
accessToken.getAccessToken. - Board. The wizard validates the studio's address with
merchants.addressLookup, then boards it withmerchants.boardMerchant. - KYC. For each document,
fileProcessing.createUrlreturns an upload URL,fileProcessing.uploadFilesends the file andfileProcessing.getFileDetailstracks its review.merchants.getMerchantSingledrives the status timeline. - Accounts. Once the studio is active,
accounts.getMerchantAccountsreturns the accounts payments and payouts use. - Pay. A member pays for a class:
transactionsApi.createSaleOrRefundTransactionon the studio's account. - Split.
transactionsApi.splitTransactionmoves the platform fee to Fieldhouse and the rest to the studio;transfers.listTransfersdraws the split, andtransfers.reverseExistingSplitundoes one. - Hold. A risky payment is held with
transactionsApi.holdTransactionand released withtransactionsApi.releaseTransaction. - Payout.
funds.fundMerchantpays the studio, andfunds.listFundslists its payouts.
The prompt
Build Assembly, the operator console for Fieldhouse, our booking-software platform for independent fitness
studios, on Global Payments' GP API. We are a PayFac: each studio is a sub-merchant.
First, install the Global Payments Context Plugin and use it for all GP API code:
npx context-plugins install https://gpx-apimatic-poc.pages.dev/__downloads/plugin.zip
What to build:
- React, TypeScript and Tailwind, with a Hono API on Cloudflare Pages. GP's look, with a real dark mode.
- Onboarding: a boarding wizard for a studio (address lookup, details, KYC document upload) and a status timeline.
- Payments & Splits: take a payment for a studio, split it between the studio and our platform fee, show the
split, reverse a split.
- Risk holds: hold a payment's funds and release them. Payouts: fund a studio and list its payouts.
- A drawer that shows every GP API call: the typed SDK call, the request and response, timing and retries.
Must get right:
- The access token: nonce + SHA512 secret, cached, refreshed once on a 401. The sandbox host is chosen explicitly.
- Never split more than the payment, never fund a studio that is not active, and every write carries an
idempotency key.
- Show GP's own reason on a refusal.
Done when: it builds cleanly, the tests pass, and a README explains how to set it up.Code: the typed SDK
From server/payments.ts. A studio payment is taken on the studio's behalf (the paymentFacilitator block names the sub-merchant), and only a captured payment is split: the studio's share to its funds account, Fieldhouse's fee to the platform's. Each write carries an X-GP-Idempotency key derived from the intent, so a repeat is the same request.
// the studio must be live and have a funds account before money is taken for it
const s = await studio(env, input.studioId);
if (s.status !== "ACTIVE" || !s.fundsAccount) {
const msg = `${s.name} is ${s.status.toLowerCase().replace("_", " ")}. Only an active studio can take payments.`;
guard("transactionsApi.createSaleOrRefundTransaction", { studio: s.id }, msg);
throw new HttpError(422, msg, { outcome: "not_sent" });
}
const reference = `FH-${input.intentId.slice(0, 12).toUpperCase()}`;
const req = {
xGpIdempotency: `asm:sale:${input.intentId}`,
body: {
accountName: accountName(env),
channel: "CNP" as const,
type: "SALE" as const,
// amount, currency, reference, description, paymentMethod …
paymentFacilitator: {
name: PLATFORM.name,
subMerchantReference: s.id,
subMerchantName: s.name.slice(0, 50),
subMerchantCountry: "US",
},
},
};
const sale = await g.call("transactionsApi.createSaleOrRefundTransaction", req,
(c) => c.transactionsApi.createSaleOrRefundTransaction(req));
if (sale.status !== "CAPTURED") return { declined: sale.status === "DECLINED", status: String(sale.status) };
const fee = feeFor(input.amount, input.feeBps);
const split = {
id: sale.id ?? "",
xGpIdempotency: `asm:split:${input.intentId}`,
body: {
transfers: [
{ recipientAccountId: s.fundsAccount.id, amount: String(input.amount - fee), reference: `${reference}-S`, description: "Studio share" },
...(fee > 0 ? [{ recipientAccountId: PLATFORM.fmaId, amount: String(fee), reference: `${reference}-F`, description: "Fieldhouse platform fee" }] : []),
],
},
};
const res = await g.call("transactionsApi.splitTransaction", split, (c) => c.transactionsApi.splitTransaction(split));Tideline: café payments
A payments console for Copperline, a three-café chain, on GP API. 3-D Secure checkout, capture, refund and void, batch close, and dispute defence, with every typed SDK call in the Wire drawer.
Cadence: patient billing for healthcare
Northgate Dental Group keeps patients as payers on GP API, stores cards on file with explicit consent, sends pay-by-link invoices for treatment plans, offers installments, runs scheduled charges and refunds.