@zkp2p/pay-shared
v0.0.2
Published
Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.
Keywords
Readme
@zkp2p/pay-shared
Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.
- Package:
@zkp2p/pay-shared - Module format: ESM
- Contains runtime utilities and compile-time types
Install
npm install @zkp2p/pay-sharedWhat This Package Includes
- Checkout/session/order types (
CreateSessionRequest,CheckoutSession,Order,Quote, etc.) - Canonical constants (
PaymentPlatform,CheckoutMode,SessionStatus,OrderStatus,OrderErrorCode) - Merchant model types and environment constants (
Merchant,MerchantEnvironment) - Central chain/token helpers for supported destination chains and token aliases
Usage
Shared API Types
import type { CreateSessionRequest, CheckoutSession } from '@zkp2p/pay-shared';
const request: CreateSessionRequest = {
merchantId: '<merchant-id>',
checkoutMode: 'exact-token',
amountUsdc: '25.00',
destinationChainId: 8453,
destinationToken: 'USDC',
recipientAddress: '0xYourRecipientAddress',
};
function readSession(session: CheckoutSession) {
console.log(session.status, session.amountUsdc, session.netAmountUsdc);
}Constants and Enums
import { CheckoutMode, PaymentPlatform, SessionStatus } from '@zkp2p/pay-shared';
console.log(CheckoutMode.EXACT_TOKEN); // "exact-token"
console.log(PaymentPlatform.VENMO); // "venmo"
console.log(SessionStatus.ACTIVE); // "ACTIVE"Chain and Token Utilities
import {
BASE_CHAIN_ID,
getSupportedChainIds,
parseSupportedChainSelection,
resolveDestinationTokenAddress,
getSupportedDestinationTokenAliasesForChain,
} from '@zkp2p/pay-shared';
const chainId = parseSupportedChainSelection('polygon'); // 137
const usdc = resolveDestinationTokenAddress('USDC', 137); // Chain-specific USDC address
const supportedAliases = getSupportedDestinationTokenAliasesForChain(BASE_CHAIN_ID); // ["USDC"]
console.log(getSupportedChainIds(), chainId, usdc, supportedAliases);Key Exports
Core type exports:
CreateSessionRequestCreateSessionResponseCheckoutSessionOrderQuoteProofAttemptMerchantBridgeInfo
Core constants:
PaymentPlatformCheckoutModeSessionStatusOrderStatusProofAttemptStatusOrderErrorCodeMerchantEnvironment
Chain constants and helpers:
BASE_CHAIN_IDHYPEREVM_CHAIN_IDSOLANA_CHAIN_IDSUPPORTED_DESTINATION_TOKEN_ALIASESparseSupportedChainSelection(...)resolveDestinationTokenAddress(...)getChainConfig(...)getSupportedChainIds(...)getDestinationChainIds(...)getEvmChainIds(...)getNonEvmChainIds(...)
Notes
- Amount fields are strings to preserve precision across APIs and clients.
CheckoutSession.netAmountUsdcrepresents the merchant net amount and may fall back to grossamountUsdcwhen fee configuration is unavailable.- This package is ESM-only.
