Upcharge

Coming soon. The Upcharge API, SDKs and MCP server aren't live yet. This is a preview of what we're building, and paths and fields may change. Leave your number for early access

The path Priya took to her first test charge

Priya's booking app needed one thing it couldn't do alone: make sure a surcharge only ever lands on a credit card, at the right amount for each groomer's state, shown before the customer pays. These are the five steps she followed. Everything runs in the sandbox, so nothing touches real money.

Get a sandbox keyAPI reference
01

Get a sandbox key

Ask us for a sandbox key. It starts with sk_test_. Keep it on your server, never in the browser, the same way you'd treat any secret.

Terminal
export UPCHARGE_KEY=sk_test_51Hx...
02

Add the card fields

Put our card fields on the page where customers pay. They sit in an iframe, so card numbers never touch Priya's servers. When the customer finishes typing, the fields hand back a token and tell you if it's a credit or debit card.

checkout.html
<script src="https://js.upchargepayments.com/v1/fields.js"></script>
<div id="card-fields"></div>
<script>
  const fields = Upcharge.fields({
    element: "#card-fields",
    publishableKey: "pk_test_...",
  });
  fields.on("complete", ({ token, cardType }) => {
    // token: "pm_7Rk2Qx", cardType: "credit"
    // send the token to your server and get a quote
  });
</script>
03

Quote the surcharge

Send the token to your server and ask for a quote. Priya's backend is Node, so she used the Node SDK (there's Python too, or plain REST). Nothing is charged yet. The answer tells you whether a surcharge applies, how much it is, and the exact words to show for that state.

quote.js
// npm install @upcharge/sdk
import Upcharge from "@upcharge/sdk";
const upcharge = new Upcharge(process.env.UPCHARGE_KEY);

const quote = await upcharge.surcharge.quote({
  amount: 100000,          // $1,000.00 in cents
  paymentMethod: "pm_7Rk2Qx",
  merchantState: "NY",
});
// quote.cardType, quote.eligible, quote.surcharge, quote.total, quote.disclosure
// nothing has been charged yet
04

Show the surcharge, then confirm

Put quote.disclosure and the new total right above the Pay button. When the customer taps Pay, confirm with the quote id, so the amount they saw is the amount that gets charged. If they walk away, don't confirm. The quote expires and nothing happens.

charge.js
// only runs when the customer taps Pay
const payment = await upcharge.payments.create({
  quote: quote.id,
});
// payment.status === "succeeded"
// payment.receipt.lines includes the surcharge on its own line
05

Listen for events

Priya listens for rules.updated so her groomers' checkout wording stays current when a state changes its law. The same webhooks tell you when payments settle and deposits go out.

webhooks.js
app.post("/webhooks/upcharge", (req, res) => {
  const event = upcharge.webhooks.verify(req.body, req.headers["upcharge-signature"]);
  if (event.type === "rules.updated") refreshDisclosures(event.data.state);
  res.sendStatus(200);
});

What Priya tested before going live

The sandbox follows the real rules, so you can see exactly what a customer in each situation would get. These four are worth trying before anything else.

Try thisWhat you get
merchantState: "CT"eligible: false. Connecticut bans surcharges, so the surcharge is 0
A debit test cardeligible: false. Debit is never surcharged
merchantState: "OK"Rate capped at 2% even if your cost is higher
Charge a quote twiceThe second call returns the first payment, not a new one
All test cards

Build it this week

Tell us what you're building. We'll send sandbox keys and put you in touch with an engineer.

Or try the calculator