Getting started
Quickstart
Updated Oct 25, 2026
This guide connects a user, verifies the connection on your server and makes a charge. You’ll need test keys from the test dashboard.
1 Install
npm install payfer2 Get your keys
Register an application in the test dashboard. Test keys are issued immediately. Keep the secret key on your server as PAYFER_SECRET_KEY; it’s shown only once.
Test keys talk to test.payfer.me, Payfer’s sandbox: Stripe test cards and Tempo testnet, so no real money moves. The SDK picks the address from your key, so there’s nothing to configure. See Test and live mode.
3 Connect a user
Call connect() from your own button. Payfer opens its hosted approval page, where the person signs in, picks a monthly limit and approves it. Someone new to Payfer pays for their first month by card as they approve; in test mode, use Stripe’s test card 4242 4242 4242 4242 with any future date and any CVC.
import { createClient } from "payfer";
const payfer = createClient({ publishableKey: "pk_test_..." });
const connection = await payfer.connect({
allowance: { amount: "5.00", period: "month" },
});4 Verify on your server
Send the connection through your existing API and verify it once before you store the association.
import { Payfer } from "payfer/server";
const payfer = new Payfer({ secretKey: process.env.PAYFER_SECRET_KEY! });
const { paymentUserId } = await payfer.verifyConnection(connection);
await savePaymentUserId(currentUser.id, paymentUserId);5 Charge
Charge the stored identity from your server. There’s no browser token and no further prompt.
await payfer.charge({
paymentUserId: currentUser.paymentUserId,
amount: "0.01",
idempotencyKey: operationId,
});For usage you can only price afterwards, use meter() to reserve a maximum, run your work, then collect the price you calculate.