Checkout

Take payments on your own page

Card payments: Test mode

Skerry’s payment form, pay button and checkout page, in your page or on Skerry’s. The card and wallet fields are the card processor’s own: Stripe processes the payment, and card data goes from the payer to Stripe without passing through Skerry or you. Skerry is software; it is not the payment provider. Every piece below is the real script running in sandbox against a stand-in, so it needs no key and moves no money.

Script
https://api.skerry.xyz/js/skerry.js
Packages
@skerry/js, @skerry/react
Sandbox keys
platform.skerry.xyz
The API
Reference

On your page

Card and payment fields

The whole form: who is paid and how much, the email for the receipt, the card fields and the pay button.
import { SkerryCheckout } from "@skerry/react";

<SkerryCheckout
  session={sessionId}
  onComplete={() => router.push("/thanks")}
/>
import { mountCheckout } from "@skerry/js";

mountCheckout("#pay", { session: sessionId });

The form has labels, works with the keyboard and announces its state. While it is busy the button says so and cannot be pressed twice. A failed payment says why and leaves the form ready to try again.

On your page

Pay button

One button. Pressed, it opens the form in place; or, as a link, it takes the payer to Skerry's checkout page.
<SkerryPayButton session={sessionId} inline />

With no code at all, from Skerry’s host:

<div data-skerry-checkout="{session id}"></div>
<script type="module" src="https://api.skerry.xyz/js/skerry.js"></script>

On your page

Wallets

A wallet the payer's device offers comes first, then “Or pay another way”, then the card fields.

Which wallets appear is the card processor’s answer for the payer’s device, browser and country, and for the methods your account takes. You add nothing to your page for them. A payer whose device offers none sees the card fields alone.

Skerry's page

Hosted checkout

Skerry's own page, on Skerry's host. Nothing to build: send the payer there.
curl https://api.skerry.xyz/checkout-sessions \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: order-1042" \
  -H "Content-Type: application/json" \
  -d '{ "customer_id": "cus_…", "currency": "eur", "ui": "skerry",
        "line_items": [{ "name": "Charts of the outer islands", "amount": 5500 }],
        "success_url": "https://shop.example/thanks" }'

# then send the payer to
https://api.skerry.xyz/checkout/{id}

The page shows who is paid and for what, then the same form. It is in the Praecise look, light or dark as the payer’s device prefers, and reads at phone width. When the payment is made the payer goes to your success_url, or to Skerry’s paid page when you gave none. A payment that did not go through brings the payer back to the form to try again.

curl https://api.skerry.xyz/payment-links \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: mooring-link" \
  -H "Content-Type: application/json" \
  -d '{ "customer_id": "cus_…", "amount": 2500, "currency": "eur",
        "description": "Mooring, one night", "reusable": true, "max_uses": 40 }'

# the link's page
https://api.skerry.xyz/pay-link/{id}

# or its button on your page
<SkerryPayButton link={linkId} />

The checkout behind a link is made only when the payer presses the button, so link previews and crawlers open nothing. A link with max_uses counts each completed payment once; at the cap it closes and its open checkouts expire.

End to end

A whole checkout, end to end

Five steps from your server to your page and back. Your secret key never reaches the page.

01

Your server makes the session

With your secret key, POST /checkout-sessions with ui "skerry", the amount or line items, the currency and the customer. Keep the session's id; nothing else goes to the page.

02

Your page shows the form

Mount the form or a pay button with the session's id. The script reads the session's public description from Skerry and mounts the card processor's own fields.

03

The payer pays

A wallet, or the card fields and the pay button. Card data goes from the payer's browser to the card processor and never reaches Skerry or you.

04

The page hears the outcome

onComplete runs when the processor confirms the payment. Show your thanks; do not ship on it.

05

Your server hears it for certain

Skerry sends checkout_session.completed or checkout_session.expired to your webhook endpoint, signed. Fulfil the order on the completed event.

// your server
const made = await fetch("https://api.skerry.xyz/checkout-sessions", {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.SKERRY_KEY}`, "content-type": "application/json", "idempotency-key": orderId },
  body: JSON.stringify({ customer_id, currency: "eur", ui: "skerry",
    line_items: [{ name: "Charts of the outer islands", amount: 5500 }] }),
});
const { id } = await made.json();   // send only the id to the page

// your page
<SkerryCheckout session={id} onComplete={() => router.push("/thanks")} />

// your webhook endpoint
if (event.type === "checkout_session.completed") fulfil(event.data);

Your look

Your brand colour

Give one colour. The script uses it only where it stays readable.
Theme

The pay button takes #5b2a86 with white words on it. The focus ring takes it too.

<SkerryCheckout session={sessionId} accent="#5b2a86" theme="auto" />

<div data-skerry-checkout="…" data-skerry-accent="#5b2a86"></div>

The pay button takes your colour when its words reach a contrast of 4.5:1 on it; the focus ring takes it when it reaches 3:1 against the form. Otherwise the Praecise accent stays. The theme follows the payer’s device unless you set light or dark.

Your look

Your payer's language

Amounts and the card fields follow the payer's language. Skerry's own words come from your page.
Language
<SkerryCheckout
  session={sessionId}
  locale="fr-FR"
  messages={{ pay: "Payer {amount}", paymentTo: "Paiement à" }}
/>

locale is the browser’s language unless you give one. It sets how the amount is written and the language of the card processor’s fields. Skerry’s words are written in English, the source; messages replaces any of them with your page’s own, in any language you offer.

Sandbox

What runs on this page

The forms above are Skerry’s script and React components. Two things are stood in for: Skerry’s description of the checkout, served by this site, and the card processor’s fields, which here are plain inputs that never leave the page. With a sandbox key from the platform, the same code mounts Stripe’s own fields in test mode against a real sandbox session.