UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

58 lines (57 loc) 1.99 kB
import type { RpcHandler } from '../../../types'; /** * Representation of the payload for the JWT used in the checkout process. * This is used to supplement checkout-related information, such as voucher codes, * custom data, preferred collection point, and selected carrier. * This allows pre-filling checkout information and ensures data integrity. */ interface CheckoutJwtPayload { /** * The voucher code. */ voucher?: string; /** * Arbitrary custom data associated with the checkout process. This can be used to store * any additional information relevant to the checkout. */ customData?: Record<string, unknown>; /** * The preferred collection point. */ preferredCollectionPoint?: { /** * The collection point Id. */ id: number; /** * The collection point type. */ type: string; }; /** * The selected carrier. */ carrier?: string; } /** * Generates a checkout token, which includes a access token token that is valid for at least 30 minutes and * a JWT containing checkout information. * * The generated JWT is signed with a secret and includes information from the * provided `jwtPayload`, along with the `basketId` and `campaignKey`. * It is used to pre-fill checkout details and maintain data integrity during * the checkout process. * * @param jwtPayload The payload for the JWT. Provides checkout-related data to embed within the token. * @param context The RPC context. * * @see https://scayle.dev/en/core-documentation/storefront/checkout-guide/implementation/webcomponent#jwt-attribute * * @returns An object containing the access token and checkout JWT. * It will return an `ErrorResponse` if no session is found, no access token is present. */ export declare const getCheckoutToken: RpcHandler<CheckoutJwtPayload | undefined, { accessToken: string | undefined; checkoutJwt: string; }>; export {};