class CartMandateClass

Class for CartMandate with specific functionality Uses JWT for merchant_authorization as per AP2 specification

Constructors

new
CartMandateClass(
options?: { id?: string; createdAt?: Date; status?: MandateStatus; signature?: string; merchantAuthorization?: string; },
)

Properties

Methods

getMerchantAuthorization(): string | undefined

Get merchant authorization JWT token

isSigned(): boolean

Check if mandate is signed (overrides base class for JWT support)

sign(
privateKey: string,
keyConfig?: Partial<JWTKeyConfig>,
merchantInfo: { merchantId: string; },
): Promise<void>

Sign mandate using JWT with merchant authorization Creates a JWT with cart hash for integrity verification

toString(): string
protected
validate(): Promise<void>
verify(
publicKey: string,
keyConfig?: Partial<JWTKeyConfig>,
expectedMerchantId?: string,
expectedAudience?: string,
): Promise<boolean>

Verify mandate signature using JWT

Static Methods

createNew(
options?: { id?: string; createdAt?: Date; status?: MandateStatus; signature?: string; merchantAuthorization?: string; },
signingOptions?: { privateKey: string; algorithm: JWTAlgorithm; merchantId: string; },
): Promise<CartMandateClass>

Create a new CartMandate

fromSigned(
signedMandate: CartMandate & { merchant_authorization?: string; },
publicKey?: string,
validateSignature?: boolean,
keyConfig?: Partial<JWTKeyConfig>,
expectedMerchantId?: string,
expectedAudience?: string,
): Promise<CartMandateClass>

Create from existing signed mandate