Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Payment Services Functions

The Payment Services drop-in provides GraphQL helpers for vaulted (saved) card checkout. Additional functions may appear in the generated section below when sourced from the drop-in repository.

FunctionDescription
getCustomerPaymentTokensLoads vaulted Payment Services card tokens for the signed-in customer via the customerPaymentTokens query.
createPaymentOrderForVaultCreates a PayPal / MP payment order for vault checkout using createPaymentOrder.
syncVaultToCartRuns vault createPaymentOrder then setPaymentMethod using your checkout fetchGraphQl and cart APIs.
normalizedVaultTokenToStoredCardPropsMaps a NormalizedVaultToken to props for the StoredCards container.

The getCustomerPaymentTokens function retrieves customer payment tokens using this package’s GraphQL client (GET). The initializer must configure the endpoint and headers (see Initialization). Results are filtered to Payment Services vaulted card tokens and returned as NormalizedVaultToken[].

export async function getCustomerPaymentTokens(): Promise<NormalizedVaultToken[]>

Returns NormalizedVaultToken[]. See the StoredCards container and normalizedVaultTokenToStoredCardProps (including Related types).

The createPaymentOrderForVault function calls the vault createPaymentOrder mutation and returns the PayPal and MP order IDs used to build the payment method payload.

export async function createPaymentOrderForVault(
cartId: string
): Promise<VaultPaymentOrderIds>
ParameterTypeReq?Description
cartIdstringYesActive cart id for the checkout session.

Returns { paypalOrderId, paymentsOrderId }. Throws if the mutation returns no order ids.

The syncVaultToCart function manages the vault checkout flow for storefronts that provide checkout (or mesh) fetchGraphQl and cart setPaymentMethod. It follows the same createPaymentOrder flow as createPaymentOrderForVault, builds the vault-specific additional data using the token’s public_hash, and then calls setPaymentMethod with PaymentMethodCode.VAULT.

export async function syncVaultToCart(
token: { publicHash?: string },
cartId: string | undefined,
deps: VaultCheckoutSyncDeps
): Promise<Record<string, unknown> | null>
ParameterTypeReq?Description
token{ publicHash?: string }YesVault token; must include publicHash for vault additional data.
cartIdstring | undefinedYesActive cart id; if missing, the function returns null.
depsVaultCheckoutSyncDepsYesfetchGraphQl and setPaymentMethod implementations from your checkout integration.

Returns the payment method payload passed to setPaymentMethod, or null on failure.

Maps a NormalizedVaultToken to the VaultStoredCardProps shape (aligned with StoredCards cards rows).

export function normalizedVaultTokenToStoredCardProps(
token: NormalizedVaultToken
): VaultStoredCardProps

Use these types from @dropins/storefront-payment-services/api.js for advanced integrations:

/** Normalized vault token used in checkout / StoredCards wiring. */
type NormalizedVaultToken = {
publicHash?: string;
methodCode: string;
type: string;
brand: string;
masked: string;
expiry: string;
holder: string;
};