TS
createHeadless(
	clientToken: string,
	options?: HeadlessUniversalCheckoutOptions,
): Promise<PrimerHeadlessCheckout>
Create an instance of PrimerHeadlessCheckout, which is used to interact with the Primer API in a headless environment.
Starting from the version 2.45.0, the options parameter should be used instead of the deprecated configure method. If both are used simultaneously, the SDK will throw an error.Note: the configure method must be called before the start method.
  • The start method must be called to begin the checkout process.

Parameters

Returns

Example

See guide on initializing Headless Checkout for more details.
TS
import { Primer } from "@primer-io/checkout-web";

const clientToken = "YOUR_CLIENT_TOKEN";
const paymentMethodType = "PAYMENT_CARD";

async function createHeadlessCheckout() {
  const primerHeadlessCheckout = await Primer.createHeadless(
    clientToken,
    options
  );
  // Use the instance to create a payment method manager
  const paymentMethodManager =
    await primerHeadlessCheckout.createPaymentMethodManager(paymentMethodType);
  // Start the checkout process
  primerHeadlessCheckout.start();
}