type WalletPaySession = Record; type StitchTransactionState = 'TransactionPending' | 'TransactionSuccess' | 'TransactionFailure'; type StitchCardNetwork = 'Visa' | 'Mastercard'; type ApplePayPaymentToken = { paymentData: Record; paymentMethod: { displayName: string; network: string; type: string; }; transactionIdentifier: string; }; type StitchTransaction = { id: string; externalReference?: string | null; quantity: string; currency: string; nonce?: string | null; status: StitchTransactionState; statusReason?: string | null; interactionUrl?: string | null; }; type ValidateApplePayMerchantInput = { merchantIdentifier: string; validationUrl: string; displayName: string; initiative: string; initiativeContext: string; }; type InitiateTransactionInput = { amount: { quantity: number; currency: string; }; externalReference: string; nonce: string; paymentMethods: { applePay?: { displayName: string; network: string; type: string; requireSecure3d?: boolean; merchantDetails?: { address: { address: string; city: string; countryCode: string; postCode: string; region: string; }; merchantCategoryCode: string; name: string; phone: string; terminalId: string; url: string; }; }; samsungPay?: { requireSecure3d?: boolean; merchantDetails?: { address: { address: string; city: string; countryCode: string; postCode: string; region: string; }; merchantCategoryCode: string; name: string; phone: string; terminalId: string; url: string; }; }; googlePay?: { requireSecure3d?: boolean; merchantDetails?: { address: { address: string; city: string; countryCode: string; postCode: string; region: string; }; merchantCategoryCode: string; name: string; phone: string; terminalId: string; url: string; }; }; }; token?: string; payerInformation?: { accountCreatedDate?: string; bankAccountNumber?: string; email?: string; fullName?: string; mobileNumber?: string; payerId?: string; }; deviceInformation?: { deviceId?: string; fingerprint?: string; ip?: { address: string; location?: { country?: string; }; }; screenDimensions?: { height: number; width: number; }; }; metadata?: Record; }; type JWTToken = { exp: number; iss: string; aud: string; client_id: string; sub?: string; auth_time?: number; }; type WalletProvider = 'APPLE_PAY' | 'SAMSUNG_PAY' | 'GOOGLE_PAY'; type GooglePayPaymentToken = string; type StitchPayerInformation = { accountCreatedDate?: string; bankAccountNumber?: string; email?: string; fullName?: string; mobileNumber?: string; payerId?: string; }; type StitchDeviceInformation = { deviceId?: string; fingerprint?: string; ip?: { address: string; location?: { country?: string; }; }; screenDimensions?: { height: number; width: number; }; }; type StitchMerchantDetails = { address: { address: string; city: string; countryCode: string; postCode: string; region: string; }; merchantCategoryCode: string; name: string; phone: string; terminalId: string; url: string; }; /** * Represents a wallet payment process with methods for merchant and payment verification and payment creation. */ declare class WalletPay { _clientId: string; _clientSecret?: string; _merchantId: string; _clientToken?: string; /** * Initializes a new instance of the WalletPay class with client and merchant identifiers. * * @private * @param {string} clientId - Stitch client identifier. * @param {string} merchantId - Apple Pay merchant identifier/Stitch gateway merchant ID. * @param {string} [clientSecret] - Optional client secret for authentication. */ constructor(clientId: string, merchantId: string, clientSecret?: string); /** * Verifies the merchant and request and returns a session for wallet payments. * * @public * @param {string} wallet - Selected wallet provider * @param {string} url - Apple Pay validation URL or Samsung Pay callback URL. * @param {string} displayName - Canonical merchant name. * @param {string} initiativeContext - Fully qualified domain name (FQDN). * @param {string} [clientToken] - Optional client token for authentication. * @param {number} amount - Payment amount (required for Samsung Pay). * @param {string} currency - Payment currency in IS04127 format (required for Samsung Pay). * @returns {Promise} Session for wallet payments. * @throws {AuthenticationError} On authentication failure. * @async * @example * type VerifyRequest = { validationUrl: string; initiativeContext: string; }; type VerifyResponse = { session: WalletPaySession } export default async function handler( req: NextApiRequest, res: NextApiResponse ) { const body = JSON.parse(req.body) as ValidateRequest; try { const session = await walletPayClient.verify(body.validationUrl, "My Store", body.initiativeContext) res.status(200).json({ session }); } catch (error) { res.status(500).json({ code: 500, message: (error as Error).message, } as ErrorMessage); return; } } */ verify(wallet: WalletProvider, url: string, displayName: string, initiativeContext: string, clientToken?: string, amount?: number, currency?: string): Promise; /** * Creates a wallet payment with the provided details. * * @public * @param {ApplePayJS.ApplePayPaymentToken | string | GooglePayPaymentToken} token - Wallet provider token or token reference identifier * @param {number} amount - Payment amount. * @param {string} currency - Payment currency in IS04127 format. * @param {string} nonce - Unique transaction identifier. * @param {string} externalReference - Transaction reference. * @param {string} [clientToken] - Optional client token for authentication. * @param {boolean} [requireSecure3d] - Optional flag to enforce 3D Secure authentication. * @param {StitchPayerInformation} [payerInformation] - Optional payer information. * @param {StitchDeviceInformation} [deviceInformation] - Optional device information. * @param {Record} [metadata] - Optional metadata. * @returns {Promise} Processed transaction. * @throws {AuthenticationError} On authentication failure. * @async * @example * type CreatePaymentRequest = { token: ApplePayJS.ApplePayPaymentToken; amount: { quantity: number; currency: "ZAR"; }; externalReference: string, }; type CreatePaymentResponse = { transaction: StitchTransaction } export default async function handler( req: NextApiRequest, res: NextApiResponse ) { const body = JSON.parse(req.body) as CreatePaymentRequest; const nonce = v4() try { const transaction = await walletPayClient.create(body.token, body.amount.quantity, body.amount.currency, nonce, body.externalReference) res.status(200).json({ transaction }); } catch (error) { res.status(500).json({ code: 500, message: (error as Error).message, } as ErrorMessage); return; } } */ create(wallet: WalletProvider, token: ApplePayJS.ApplePayPaymentToken | string | GooglePayPaymentToken, amount: number, currency: string, nonce: string, externalReference: string, clientToken?: string, requireSecure3d?: boolean, merchantDetails?: StitchMerchantDetails, payerInformation?: StitchPayerInformation, deviceInformation?: StitchDeviceInformation, metadata?: Record): Promise; } /** * Factory function to initialize a WalletPay instance. Serves as the entrypoint to the Stitch SDK. * * @public * @param {string} clientId - Client Stitch identifier. * @param {string} merchantId - Apple Pay merchant identifier. * @param {string} [clientSecret] - Optional client secret for authentication. If not provided, a client token must be passed on each request. * @returns {WalletPay} Configured WalletPay instance. * @example * const clientId = process.env.STITCH_CLIENT_ID as string const clientSecret = process.env.STITCH_CLIENT_SECRET as string const applePayMerchantId = "my.merchant.identifer" const walletPayClient = init(clientId, applePayMerchantId, clientSecret) */ declare function init(clientId: string, merchantId: string, clientSecret?: string): WalletPay; declare class ApiError extends Error { constructor(message: string); } declare class AuthenticationError extends Error { constructor(message: string); } declare class UserInputError extends Error { constructor(message: string); } export { ApiError, type ApplePayPaymentToken, AuthenticationError, type GooglePayPaymentToken, type InitiateTransactionInput, type JWTToken, type StitchCardNetwork, type StitchDeviceInformation, type StitchMerchantDetails, type StitchPayerInformation, type StitchTransaction, type StitchTransactionState, UserInputError, type ValidateApplePayMerchantInput, type WalletPaySession, type WalletProvider, init };