npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ummah-pay/web-sdk

v0.8.1

Published

Ummah white-label web SDK — Card, Apple Pay, Google Pay & Swish over the Ummah backend. React component + framework-agnostic mount.

Readme

@ummah-pay/web-sdk

White-label web SDK for Ummah. Renders a secure card form (plus Apple Pay & Google Pay when available, and Swish for Swedish SEK payments) and drives the payment through the Ummah backend's browser-facing checkout surface. The payment provider is bundled inside the SDK — consumers never depend on it or even see it.

The SDK never holds a provider secret. The only credentials it needs are the publishable key (pk_…) and the single-use checkout session token (cs_…) returned by your server from POST /v1/checkout/sessions. Your secret key (sk_…) stays server-side.

  • React <UmmahCheckout> and a framework-agnostic mountUmmahCheckout(el, opts).
  • Detects the card brand and sends it to the backend so it can resolve per-method pricing.
  • Handles native 3DS2 in-component, plus a helper for full-page redirect 3DS.
  • Swish for one-off SEK payments: QR code on desktop, the Swish app on a phone.
  • Picks the Ummah API automatically from environment ("stage" for Test, "prod" for Live) — no URL to configure.
  • Currency-correct: the session's amount and currency drive the wallet sheets, the method list and the form's locale — nothing assumes GBP.
  • TypeScript, types exported. The provider's web library and its CSS are bundled in.

Install

npm install @ummah-pay/web-sdk

Peer deps: react + react-dom (only needed for the React component; the vanilla mountUmmahCheckout works without React). Import the stylesheet once:

import '@ummah-pay/web-sdk/styles.css';

No bundler? Use the script tag

The same SDK ships as a single browser-global file (styles included, no React):

<script src="https://cdn.jsdelivr.net/npm/@ummah-pay/[email protected]/dist/ummah-pay.global.js"></script>
<div id="checkout"></div>
<script>
  UmmahPay.mountUmmahCheckout(document.getElementById('checkout'), {
    publishableKey: 'pk_test_…',
    sessionToken: 'cs_…',
    environment: 'stage',
    onPaymentResult: (r) => console.log(r.resultCode),
  });
</script>

Pin a minor (@0.7) so you pick up fixes but never a breaking change. Releases and notes: https://github.com/MintedMoney/ummah-platform-web-sdk/releases.

Contributing / building locally

npm ci
npm run build      # tsup → dist/ (index.js, index.cjs, index.d.ts, index.css, ummah-pay.global.js)
npm test           # node:test unit tests in test/ (Node 22.15+, no extra dependencies)

Quick start (React)

import { UmmahCheckout } from '@ummah-pay/web-sdk';
import '@ummah-pay/web-sdk/styles.css';

function Pay({ pk, cs }: { pk: string; cs: string }) {
  return (
    <UmmahCheckout
      publishableKey={pk}
      sessionToken={cs}
      environment="stage"           // "stage" = Test, "prod" = Live — selects the Ummah API
      onPaymentResult={(r) => {
        if (r.resultCode === 'Authorised') {
          console.log('Paid!', r.pspReference);
        } else {
          console.warn('Not authorised:', r.resultCode, r.refusalReason);
        }
      }}
      onError={(e) => console.error(e)}
    />
  );
}

pk and cs come from your server calling POST /v1/checkout/sessions with the secret key — never expose sk_… to the browser.

Quick start (no framework)

import { mountUmmahCheckout } from '@ummah-pay/web-sdk';
import '@ummah-pay/web-sdk/styles.css';

const handle = mountUmmahCheckout(document.getElementById('pay')!, {
  publishableKey: pk,
  sessionToken: cs,
  environment: 'stage', // Test; 'prod' for Live
  onPaymentResult: (r) => console.log(r.resultCode, r.pspReference),
  onError: (e) => console.error(e),
});

// later, to clean up:
handle.unmount();

Props / options

| Option | Type | Default | Notes | | --- | --- | --- | --- | | publishableKey | string | — | Required. pk_… from the create-session response. | | sessionToken | string | — | Required. cs_… from the create-session response (single-use). | | environment | 'stage' \| 'prod' | stage | Selects the built-in Ummah API base URL: 'stage' = Test, 'prod' = Live (see Environments). Legacy 'test'/'staging' → stage, 'live' → prod. | | apiBaseUrl | string | (from environment) | Override the API base URL (local dev / self-hosting). | | clientKey | string | (fetched) | Card-form client key. If omitted, fetched from the backend. Pass it with amount (both are on the session response) to skip that round-trip. | | amount | { value, currency } | (fetched) | The session amount (minor units + ISO 4217), from the create-session response. Shown on the Apple Pay / Google Pay sheets, sent to /paymentMethods, picks the default locale. Display-side only — the backend charges the frozen session. | | countryCode | string | (from the session) | ISO 3166-1 alpha-2 for /paymentMethods and the wallets. Default: the merchant's country as the backend reports it, else GB. | | shopperLocale | string | (from the currency) | e.g. en-GB. Default follows the session currency: GBP → en-GB, EUR → en-IE, USD → en-US, AUD → en-AU, CAD → en-CA, SEK → en-SE. | | returnUrl | string | current URL | Used for redirect/3DS, the return from the Swish app and the return from a wallet hand-off (see Wallets without setup). The backend's frozen-session returnUrl wins server-side for redirects if set. | | buttonText | string | Pay | Card pay-button label. | | enableApplePay | boolean | true | Render Apple Pay when available. | | enableGooglePay | boolean | true | Render Google Pay when available. | | enableSwish | boolean | true | Render Swish when the session offers it (SEK, one-off — see Swish). | | applePayMerchantName | string | (trading name) | Name on the Apple Pay and Google Pay sheets. Default: your trading name, as the platform sends it. Pass it only to show something else. | | applePayOnAllBrowsers | boolean | false | Also offer Apple Pay in browsers such as Chrome. The button opens Apple's QR code, and the shopper finishes on an iPhone with iOS 18 or later. | | walletHandoff | boolean | true | Offer Apple Pay / Google Pay on a page whose domain is not set up for them, by continuing on a secure Ummah page (see Wallets without setup). false hides those wallets. | | swishAppSwitch | boolean | true | On a phone or tablet, open the Swish app as soon as the request is created instead of showing the QR code (see Swish). false keeps the QR code on every device. | | hideBranding | boolean | false | Hide the footer with the Ummah logo. | | className | string | — | Extra class on the container. | | paymentMethods | Array<'card' \| 'applepay' \| 'googlepay' \| 'swish'> | all | Which methods this page offers, e.g. ['card'] or ['googlepay'] (see Customise the checkout). | | card | UmmahCardOptions | — | Card form fields: holder name, billing address, prefill, help text, field text style. | | labels / placeholders / messages | objects | — | Your own wording for labels, placeholders and every error message. | | translations | Record<string, string> | — | Any other text of the payment form, by its own key. | | showPayButton | boolean | true | false = your own button calls submit() (mount handle or React ref). | | showErrors | boolean | true | false = render messages yourself from onErrorMessage. | | binLookup | boolean | false | Report the card's brand, issuing country and product through onBinLookup. | | googlePay / applePay | objects | — | Button type, colour, locale (Google Pay: radius too). | | swish | { buttonColor?: 'white' \| 'black', buttonText?: string } | white, no text | Colour of the Swish button, and an optional line of your own after the logo (0.7.0) — see Swish. | | walletShopperDetails | boolean \| { email, phone, billingAddress } | false | Ask the wallet sheet for contact details; returned on result.shopper. | | onPaymentResult | (r: UmmahPaymentResult) => void | — | Final settled result. | | onError | (e: Error) => void | — | Unrecoverable errors (network, init). | | onReady | () => void | — | Fires when the form is interactive. | | onBinLookup | (info: UmmahBinInfo) => void | — | With binLookup: what the card's first digits say; cleared: true when the number is removed. | | onCardValidChange | (valid: boolean) => void | — | The card form became complete and valid, or stopped being so. | | onProcessingChange | (processing: boolean) => void | — | A payment started / ended. | | onErrorMessage | (message: string \| null) => void | — | Every message the checkout shows under the form; null clears it. | | onPaymentMethodsReady | (methods: string[]) => void | — | Once, with the methods actually on the page. |

UmmahPaymentResult

interface UmmahPaymentResult {
  resultCode: string;       // "Authorised" | "Refused" | "Error" | "Cancelled" | "Pending" | ...
  pspReference?: string;    // provider PSP reference
  refusalReason?: string;   // when refused
  transactionId?: string;   // Ummah's payment id — verify it server-side (GET /v1/payments/{id})
  brand?: string;           // "visa" | "mc" | "amex" | "applepay" | "googlepay" | "swish" | ...
  savedPaymentMethod?: UmmahSavedPaymentMethod; // 0.1.6: the card this payment saved / paid with
  subscription?: UmmahStartedSubscription;      // 0.1.6: the schedule a one-session checkout started
  subscriptionError?: string;                   // 0.1.6: …or why it was refused (payment stands)
  viaHandoff?: boolean;     // 0.5.0: paid on the secure wallet page, read back on return
  shopper?: UmmahShopperDetails; // 0.6.0: name / address from the card form, or the wallet sheet's contact details
  raw: UmmahRawResult;      // verbatim provider response
}

Since 0.1.6 the SDK also sends the browser's IANA zone (shopperTimeZone) with each payment, so the platform can bill charge-time subscriptions in the shopper's local time — nothing to configure.

A refused payment is delivered through onPaymentResult (it's a real outcome), not onError. Reserve onError for network/setup failures.

Customise the checkout

Everything below is optional (0.6.0). With none of it set the checkout looks and behaves as in 0.5 — except the Swish button, which now shows the Swish logo (see Swish). These options are read when the checkout is created; to change them, create it again (in React: a new key).

Choose the payment methods

<UmmahCheckout paymentMethods={['card']} … />                 // card form only
<UmmahCheckout paymentMethods={['googlepay']} … />            // the Google Pay button only
<UmmahCheckout paymentMethods={['applepay', 'googlepay']} … /> // wallets, no card form

Without 'card' there is no card form and no pay button. A wallet still shows only where it can work (the store offers it and the device supports it), so listen to onPaymentMethodsReady(methods): it is called once with what is actually on the page, e.g. ['googlepay'], or [] when nothing could be shown (the checkout then shows messages.noMethodAvailable).

Card fields

<UmmahCheckout
  card={{
    layout: 'stacked',             // number on its own row, expiry + CVV under it
    holderName: 'required',        // 'required' | 'optional' | 'hidden'
    holderNameOnTop: true,         // name above the card number
    billingAddress: 'full',        // 'none' (default) | 'postalCode' | 'full'
    billingAddressCountries: ['US', 'GB', 'CA'],   // limit the country list
    prefill: { holderName: 'Amina Khan', billingAddress: { country: 'US' } },
    showHelpText: true,            // "3 digits on back of card" under the fields
    showRequiredNote: false,       // "All fields are required…" line
    showBrandIcon: true,
    fieldStyles: { base: { color: '#14532d', fontSize: '16px' } },
  }}
  …
/>

| card option | Default | Notes | | --- | --- | --- | | layout | 'inline' | 'inline': card number, expiry date and security code on one row. 'stacked': the card number on a row of its own, expiry and security code side by side under it. A container narrower than 440px always stacks. | | holderName | 'required' | 'optional' shows the field without requiring it; 'hidden' removes it. | | holderNameOnTop | false | Name above the card number instead of below. | | billingAddress | 'none' | 'postalCode' adds one postal code field; 'full' adds country, street, house number, city, postal code and — where the country has them — state. The address is sent with the payment (address checks) and returned on result.shopper.billingAddress. | | billingAddressCountries | all | ISO 3166-1 alpha-2 codes to offer in the country list. | | billingAddressRequiredFields | all | Which address fields to show, e.g. ['country', 'postalCode', 'city']. | | prefill | — | { holderName, billingAddress } to start the form with. | | showBrandIcon | true | The card brand mark inside the number field. | | showHelpText | false | The help line under expiry date and security code. | | showRequiredNote | false | The "All fields are required unless marked otherwise." line. | | maskSecurityCode | false | Show the security code as dots. | | autoFocus | false | Focus the first field when the form is ready. | | fieldStyles | — | Text style inside the card number, expiry and security code fields (base, placeholder, error, validated). Those are secure frames page CSS cannot reach; only text properties apply (color, fontSize, fontFamily, fontWeight, letterSpacing, …) and fontFamily must be a font the browser already has. |

Labels, placeholders and messages

<UmmahCheckout
  labels={{
    cardNumber: 'Card number *',
    expiryDate: 'Expiry date *',
    securityCode: 'Security code *',
    holderName: 'Name on card *',
    billingAddress: 'Billing address',
    expressTitle: '',              // empty hides the "Express checkout" title
    cardDivider: 'Or pay by card',
    processing: 'One moment…',
  }}
  placeholders={{ holderName: 'As printed on the card' }}
  messages={{
    cardNumberInvalid: 'That card number does not look right.',
    cardIncomplete: 'Please fill in every card field.',
    refused: ({ refusalReason }) =>
      refusalReason === 'Insufficient funds'
        ? 'Not enough funds on this card.'
        : 'Your card was declined. Please try another card.',
    error: 'Something went wrong. Please try again.',
  }}
  …
/>
  • labels — field labels (cardNumber, expiryDate, securityCode, holderName, expiryDateHelp, securityCodeHelp, securityCodeHelpFourDigits, requiredNote, billingAddress, country, street, houseNumberOrName, postalCode, zipCode, city, stateOrProvince, state) and the checkout's own lines (expressTitle, cardDivider, processing, securePayment, paymentComplete, paymentReceived). An empty string hides expressTitle, cardDivider and securePayment. swishButton is the accessible name of the Swish button ("Pay with Swish").
  • placeholders — cardNumber, expiryDate, securityCode, securityCodeFourDigits, holderName.
  • messages — under a field: cardNumberRequired, cardNumberIncomplete, cardNumberInvalid, cardBrandUnsupported, expiryDateRequired, expiryDateIncomplete, expiryDateInvalid, securityCodeRequired, securityCodeIncomplete, holderNameInvalid, fieldRequired, fieldInvalid. Under the form: cardIncomplete, cardNotReady, refused (text, or a function of { resultCode, refusalReason, brand }), error (text, or a function of the error; return nothing to keep the default), noMethodAvailable, walletUnavailable, sessionExpired, swishExpired.
  • translations — any other text of the payment form by its own key, e.g. { 'select.country': 'Choose a country' }. Applied last.

Your own pay button and error display

const checkout = useRef<UmmahCheckoutRef>(null);
const [valid, setValid] = useState(false);
const [busy, setBusy] = useState(false);
const [message, setMessage] = useState<string | null>(null);

<UmmahCheckout
  ref={checkout}
  showPayButton={false}
  showErrors={false}
  onCardValidChange={setValid}
  onProcessingChange={setBusy}
  onErrorMessage={setMessage}
  …
/>
<button disabled={!valid || busy} onClick={() => checkout.current?.submit()}>Donate</button>
{message && <p role="alert">{message}</p>}

Without React, mountUmmahCheckout() returns the same submit() on its handle. Messages under a single card field always show at that field.

Card BIN details

<UmmahCheckout
  binLookup
  onBinLookup={(info) => {
    if (info.cleared) return resetCardHints();
    // { bin: '411111', brand: 'visa', issuingCountryCode: 'US',
    //   paymentMethodVariant: 'visacredit', detectedBrands: ['visa'],
    //   supportedBrands: ['visa'], brands: [{ brand, supported, paymentMethodVariant }] }
    showCardHints(info.brand, info.issuingCountryCode);
  }}
  …
/>

The card form already asks the processor about the card's first digits (that is how it shows the brand). binLookup: true hands you the answer: the brand, the issuer's country, the card product and whether the store accepts it. The lookup runs once the shopper has typed enough of the number for a reliable answer — 11 digits at present — and you get one call per distinct answer, plus one with cleared: true when the number is removed. bin is the first six digits; the full number never leaves the secure field. No extra request is made and you need no processor key of your own.

Shopper details from Apple Pay / Google Pay

<UmmahCheckout
  walletShopperDetails={{ email: true, phone: true, billingAddress: 'full' }}
  onPaymentResult={(result) => {
    // result.shopper → { name, firstName, lastName, email, phone,
    //                    billingAddress: { street, city, postalCode, stateOrProvince, country } }
    createDonor(result.transactionId, result.shopper);
  }}
  …
/>

By default a wallet sheet asks for nothing beyond the card. With walletShopperDetails the sheet also asks for what you list (true = email and full billing address) and the answer comes back on result.shopper. For a card payment result.shopper carries the name and billing address typed into the card form. Notes: Google Pay gives a phone number only together with a billing address; 'min' is name, country and postal code (Google Pay only); a wallet hand-off (secure Ummah page) and a full-page redirect return no shopper details — take those from the payment on your server. Treat result.shopper as what the shopper told the browser: fine for creating a donor record, never proof of payment.

The wallet buttons themselves: googlePay={{ buttonType: 'donate', buttonColor: 'black', buttonRadius: 8, buttonLocale: 'en' }} and applePay={{ buttonType: 'donate', buttonColor: 'black', buttonLocale: 'en-GB' }}. The Swish button: swish={{ buttonColor: 'black' }} (white by default), and swish={{ buttonText: '(via our payment partner)' }} for a line of your own after the logo (0.7.0).

Recipes

No name field, a blue pay button — hide the holder name with an option and colour the button with CSS variables:

<UmmahCheckout {...session} className="my-checkout" card={{ holderName: 'hidden' }} />
.my-checkout.ummah-sdk-container {
  --ummah-accent: #0778d4;            /* focus ring */
  --ummah-button-background: #0778d4; /* a flat colour instead of the gradient */
  --ummah-button-shadow: none;
}

Card number on its own row, with a billing address

<UmmahCheckout
  {...session}
  paymentMethods={['card']}
  card={{ layout: 'stacked', holderName: 'required', holderNameOnTop: true, billingAddress: 'full' }}
/>

Wallets and Swish only, dark buttons

<UmmahCheckout
  {...session}
  paymentMethods={['applepay', 'googlepay', 'swish']}
  googlePay={{ buttonColor: 'black' }}
  swish={{ buttonColor: 'black' }}
  labels={{ expressTitle: '' }}
/>

Without React — the same options, as one object:

const handle = mountUmmahCheckout(document.getElementById('checkout'), {
  ...session,
  card: { holderName: 'hidden' },
  swish: { buttonColor: 'white' },
  onPaymentResult: (result) => console.log(result.resultCode),
});

Wallets without setup

Apple Pay and Google Pay open on your page only once your domain is set up for them (in the merchant portal: Developers → Domains, and Settings → Payment methods). Until then the SDK still offers both wallets:

  • What the shopper sees. In the express area, a row with the wallet's mark, its name and "Continue on a secure page". Apple Pay shows only where Apple Pay can work (Safari on Apple devices, or any browser with applePayOnAllBrowsers); Google Pay shows in any browser.
  • What happens. A tap asks the platform for a single-use link (POST /sdk/checkout/handoff) and moves the shopper to a short page on the Ummah checkout that shows your name, the amount and the wallet's own button. The payment runs on the same checkout session, so the amount, fees, reference and webhooks are unchanged. No key or session token is in the link.
  • The way back. The shopper returns to your returnUrl (default: the current page) with ummah_handoff on the query, paid or not. returnUrl must be on one of your approved domains. On that page, create the checkout again with the SAME publishableKey and sessionToken — exactly as after a 3-D Secure redirect. The SDK sees the marker, removes it from the address bar, asks the platform how the session ended (GET /sdk/checkout/status) and then: paid → onPaymentResult with viaHandoff: true and the transactionId, and the form is replaced by a short confirmation; refused → onPaymentResult with the refusal; not paid yet → the form, as normal; expired → onError. Verify the payment on your server with GET /v1/payments/{transactionId}, as always.
  • If your page mints a new session on every load, call completeUmmahHandoff() when the URL carries ummah_handoff, before you create a session — like completeUmmahRedirect() after 3-D Secure. It needs no arguments and resolves to the payment result (viaHandoff: true), or null when the shopper came back without paying.
  • Turning it off. walletHandoff: false hides these wallets. enableApplePay / enableGooglePay still hide a wallet completely.
  • Skipping the detour. Once your domain is registered for Apple Pay (and for Google Pay, or you add your own Google Pay merchant id), the wallet's own button opens directly on your page. Nothing changes in your code.

The wallet sheets show your trading name. applePayMerchantName overrides it.

Currency

The SDK is currency-agnostic. The session's amount ({ value, currency }, minor units) is what the Apple Pay and Google Pay sheets display and what the default locale follows — a EUR session shows € and reads en-IE, a USD one $ and en-US. Nothing in the SDK assumes GBP, and the browser never tells the backend what to charge: the amount is frozen on the session when your server creates it. Pass amount (and clientKey) from the create-session response to skip the bootstrap call; otherwise the SDK reads both from GET /sdk/checkout/client-key.

Swish (Sweden, SEK)

Swish is Sweden's mobile payment app. The SDK shows a Swish button — the Swish logo on a button with the height and corners of the Apple Pay / Google Pay buttons, in the same row — when, and only when, the session can use it:

  • SEK only, Sweden only. The session's currency must be SEK and the merchant set up for Swish (EU platform, a Swish number on file — done by Ummah during onboarding).
  • One-off payments only. No subscriptions, no saving a card (savePaymentMethod), no card set-up / card-update sessions, no manual capture. The backend leaves Swish out of /paymentMethods for those sessions, and the SDK never shows it on a zero-amount session. Swish has no recurring payments.
  • enableSwish: false hides it.
  • swish: { buttonColor: 'black' } gives a black button with the white wordmark (default: white with an outline). labels.swishButton sets its accessible name ("Pay with Swish"). Height and corners follow --ummah-wallet-height and --ummah-control-radius.
  • By default the button has no text. swish: { buttonText: '(via our payment partner)' } (0.7.0) prints one line of your own after the logo — at most 60 characters, shown as text, read out after the accessible name. A button with text is as wide as its logo and text need, so it shares a row with a wallet button only where the whole text fits; on a narrow form it takes a row of its own and the wallet buttons go under it. A text too long even for a whole row ends in "…". Restyle it with .ummah-sdk-swish-button__text.

Desktop: the shopper clicks the button; the SDK starts the payment and the component shows a QR code with a 3-minute timer. The shopper scans it with the Swish app and approves; the component checks the status by itself and the SDK settles the payment — onPaymentResult with brand: "swish".

Phone (iOS, iPadOS, Android): no QR code. As soon as the request is created the SDK opens the Swish app (it follows the processor's link; an "Open app" button stays on the page as a fallback, with the amount and the timer). After approving, the shopper comes back to your returnUrl with redirectResult on the URL — call completeUmmahRedirect() there, exactly as for a 3DS redirect (see below). The app may hand back to a new browser tab; the SDK keeps the session breadcrumb for Swish in localStorage for 15 minutes (removed as soon as the payment ends), so the new tab can finish it. swishAppSwitch: false keeps the QR code on every device. On a TEST account the app opens but shows no request: test tokens never reach the real Swish network, and the processor approves the request by itself.

Outcomes, all through onPaymentResult (never onError):

| resultCode | Meaning | | --- | --- | | Authorised | Paid. | | Pending / Received | Approved, Swish still confirming (e.g. the shopper came back from the app quickly). Final result by webhook. Do not ask for a second payment. | | Refused | Declined or cancelled in the Swish app. The Swish button comes back for another try. | | Cancelled, refusalReason: "Expired" | The 3-minute QR window ran out on the page ("Not completed": the status check ended without an answer). The SDK shows "If you approved it in Swish, wait a few minutes before paying again" and puts the button back. |

A shopper can approve in the last seconds of the window, so treat the browser result as a hint: your server confirms with the payment.* webhook or GET /v1/payments/{transactionId} (transactionId is on every Swish result, the expired one included). Refunds work as for cards; Swish has no chargebacks.

On the test environment a Swish payment is authorised within about 15 seconds.

Environments

environment picks the Ummah API host — you never configure a URL:

| environment | Ummah API | Use for | | --- | --- | --- | | stage | https://api.stage.ummah.com | Test — build and test your integration (test keys and test cards, no real money). Default. | | prod | https://api.ummah.com | Live payments. | | dev / local | — | Ummah internal. Don't use these. |

Use the keys issued for that environment — a pk_/sk_ pair only works on the environment it was created in (pk_test_… on stage, pk_live_… on prod). The old names still work as aliases: test and staging → stage, live → prod. apiBaseUrl overrides environment altogether.

Always set environment explicitly. Up to 0.2.1, test, staging and an omitted environment all resolved to dev, an Ummah-internal host where no merchant key works.

Look and feel

The checkout opens with an "Express checkout" row of official wallet buttons, then the secure card form and the pay button. A wallet appears only when the store offers it and the device can use it. With no wallets, the page starts at the card form.

To match your site, set these on .ummah-sdk-container, or on a class you pass as className:

.my-checkout.ummah-sdk-container {
  --ummah-accent: #2f7d4f;       /* focus ring and pay button */
  --ummah-accent-deep: #25633e;  /* pay button, lower edge */
  --ummah-ink: #1a1a1a;          /* text */
  --ummah-font: Inter, sans-serif;
  --ummah-control-radius: 12px;  /* fields and wallet buttons */

  /* single parts (0.6.0) — each defaults to the tokens above */
  --ummah-max-width: none;       /* 560px by default */
  --ummah-font-size: 15px;
  --ummah-label-color: #334155;
  --ummah-label-size: 13px;
  --ummah-label-weight: 600;
  --ummah-field-height: 50px;
  --ummah-field-background: #f8fafc;
  --ummah-field-gap: 12px;       /* space between fields on one row */
  --ummah-placeholder: #94a3b8;
  --ummah-button-background: #f60362;  /* replaces the accent gradient */
  --ummah-button-color: #fff;
  --ummah-button-radius: 12px;   /* 999px (pill) by default */
  --ummah-button-height: 52px;
  --ummah-button-font-size: 16px;
  --ummah-button-shadow: none;
  --ummah-wallet-height: 50px;
}

Other variables: --ummah-ink-soft, --ummah-border, --ummah-surface, --ummah-error, --ummah-error-wash.

The characters typed into the card number, expiry and security code fields sit in secure iframes that page CSS cannot reach: style them with card.fieldStyles (see Card fields). The name and address fields are ordinary inputs and follow --ummah-font.

How it talks to the backend

All calls automatically attach X-Ummah-Publishable-Key and X-Ummah-Session, against the base URL selected by environment (or apiBaseUrl):

  1. GET /sdk/checkout/client-key — bootstrap: client key, environment, the session amount and the merchant's countryCode (skipped only when both clientKey and amount are given as options).
  2. POST /sdk/checkout/paymentMethods { amount?, countryCode?, shopperLocale? } — the session amount as the SDK knows it, so the method list and the wallet sheets agree; the backend prices the frozen session regardless.
  3. POST /sdk/checkout/payments { paymentMethod, browserInfo, billingAddress?, riskData?, origin?, returnUrl?, brand } — no amount; the backend injects amount + splits from the frozen session.
  4. If a further shopper action is returned, the SDK handles it → POST /sdk/checkout/payments/details { details }.
  5. A wallet in hand-off mode: POST /sdk/checkout/handoff { wallet, returnUrl } → { url, expiresAt }; back on returnUrl, GET /sdk/checkout/status → { status, resultCode, transactionId, refusalReason }.

3DS redirect return

Most test cards use native 3DS2 (handled in-component — no redirect). For the redirect-type challenge — and for a shopper back from the Swish app — call completeUmmahRedirect() on your return page:

import { completeUmmahRedirect, isAuthorised } from '@ummah-pay/web-sdk';

// On the returnUrl page (the SDK stashed the context before the shopper left):
const result = await completeUmmahRedirect(); // result.brand: "swish" after the Swish app
if (result && isAuthorised(result)) {
  // success
}

Content-Security-Policy

If your site sends a CSP, allow our payment processor's secure domain in frame-src (and child-src), connect-src, script-src and form-action — the card fields and the native 3DS2 challenge are iframes from that domain, and a redirect-type challenge is a full-page form POST to it, so form-action 'self' leaves the shopper stuck on the card form. Ask Ummah support for the current host list; a blocked host is also named in the browser console's CSP violation. Add https://pay.google.com and https://applepay.cdn-apple.com (script-src, frame-src, connect-src) if you show wallets, and the Ummah API host in connect-src. Google Pay also needs https://google.com/pay and https://www.google.com/pay in connect-src: Chrome looks up the Google Pay app at these two addresses before it opens the payment sheet; without them it logs a CSP error and Google Pay opens in a pop-up window instead.

Swish needs no new host: its QR code image, the Swish logo and the status checks the component makes while the QR code is shown are all on https://*.adyen.com too — so a policy that restricts img-src must also allow that host there (connect-src already covers the status checks). The button that opens the Swish app is a normal page navigation, which CSP does not restrict.

Build output

tsup emits dist/index.js, dist/index.cjs, dist/index.d.ts, and dist/index.css. Import the CSS once in your app: import '@ummah-pay/web-sdk/styles.css' (or '@ummah-pay/web-sdk/dist/index.css').

Test cards (test environment)

| Scheme | Number | Expiry | CVC | | --- | --- | --- | --- | | Visa | 4111 1111 1111 1111 | any future date | 737 | | Mastercard | 5555 5555 5555 4444 | any future date | 737 | | Amex | 3700 0000 0000 002 | any future date | 7373 |

3DS2 test card (triggers a challenge): 4917 6100 0000 0000.