import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
interface PayLayerProviderProps {
children: ReactNode;
}
/**
* PayLayerProvider - Provides PayLayer context to the React tree
*
* @example
* ```tsx
*
*
*
* ```
*/
declare function PayLayerProvider({ children, }: PayLayerProviderProps): react_jsx_runtime.JSX.Element;
/**
* Supported currency codes based on ISO 4217 standard.
* Includes all currencies supported by Stripe, PayPal, Paddle, Lemon Squeezy, and Polar providers.
*/
declare enum Currency {
USD = "USD",// United States Dollar
EUR = "EUR",// Euro
GBP = "GBP",// British Pound Sterling
JPY = "JPY",// Japanese Yen
AUD = "AUD",// Australian Dollar
CAD = "CAD",// Canadian Dollar
CHF = "CHF",// Swiss Franc
CNY = "CNY",// Chinese Yuan
HKD = "HKD",// Hong Kong Dollar
NZD = "NZD",// New Zealand Dollar
SGD = "SGD",// Singapore Dollar
SEK = "SEK",// Swedish Krona
NOK = "NOK",// Norwegian Krone
DKK = "DKK",// Danish Krone
PLN = "PLN",// Polish Złoty
CZK = "CZK",// Czech Koruna
HUF = "HUF",// Hungarian Forint
BRL = "BRL",// Brazilian Real
MXN = "MXN",// Mexican Peso
INR = "INR",// Indian Rupee
KRW = "KRW",// South Korean Won
THB = "THB",// Thai Baht
PHP = "PHP",// Philippine Peso
MYR = "MYR",// Malaysian Ringgit
TWD = "TWD",// New Taiwan Dollar
ILS = "ILS",// Israeli New Shekel
RUB = "RUB",// Russian Ruble
ZAR = "ZAR",// South African Rand
AED = "AED",// UAE Dirham
ARS = "ARS",// Argentine Peso
CLP = "CLP",// Chilean Peso
COP = "COP",// Colombian Peso
IDR = "IDR",// Indonesian Rupiah
TRY = "TRY",// Turkish Lira
VND = "VND",// Vietnamese Dong
BGN = "BGN",// Bulgarian Lev
RON = "RON",// Romanian Leu
HRK = "HRK",// Croatian Kuna
ISK = "ISK",// Icelandic Króna
RSD = "RSD",// Serbian Dinar
UAH = "UAH",// Ukrainian Hryvnia
KZT = "KZT",// Kazakhstani Tenge
EGP = "EGP",// Egyptian Pound
SAR = "SAR",// Saudi Riyal
QAR = "QAR",// Qatari Riyal
KWD = "KWD",// Kuwaiti Dinar
BHD = "BHD",// Bahraini Dinar
OMR = "OMR",// Omani Rial
JOD = "JOD",// Jordanian Dinar
LBP = "LBP",// Lebanese Pound
PKR = "PKR",// Pakistani Rupee
BDT = "BDT",// Bangladeshi Taka
LKR = "LKR",// Sri Lankan Rupee
NPR = "NPR",// Nepalese Rupee
MMK = "MMK",// Myanmar Kyat
KHR = "KHR",// Cambodian Riel
LAK = "LAK",// Lao Kip
MNT = "MNT",// Mongolian Tögrög
BAM = "BAM",// Bosnia and Herzegovina Convertible Mark
MKD = "MKD",// Macedonian Denar
ALL = "ALL",// Albanian Lek
MDL = "MDL",// Moldovan Leu
GEL = "GEL",// Georgian Lari
AMD = "AMD",// Armenian Dram
AZN = "AZN",// Azerbaijani Manat
BYN = "BYN",// Belarusian Ruble
UZS = "UZS",// Uzbekistani Som
TJS = "TJS",// Tajikistani Somoni
TMT = "TMT",// Turkmenistani Manat
AFN = "AFN",// Afghan Afghani
IRR = "IRR",// Iranian Rial
IQD = "IQD",// Iraqi Dinar
SYP = "SYP",// Syrian Pound
YER = "YER",// Yemeni Rial
NGN = "NGN",// Nigerian Naira
GHS = "GHS",// Ghanaian Cedi
KES = "KES",// Kenyan Shilling
UGX = "UGX",// Ugandan Shilling
TZS = "TZS",// Tanzanian Shilling
ETB = "ETB",// Ethiopian Birr
MAD = "MAD",// Moroccan Dirham
TND = "TND",// Tunisian Dinar
DZD = "DZD",// Algerian Dinar
XOF = "XOF",// West African CFA Franc
XAF = "XAF",// Central African CFA Franc
AOA = "AOA",// Angolan Kwanza
MZN = "MZN",// Mozambican Metical
MWK = "MWK",// Malawian Kwacha
ZMW = "ZMW",// Zambian Kwacha
BWP = "BWP",// Botswana Pula
SZL = "SZL",// Swazi Lilangeni
LSL = "LSL",// Lesotho Loti
NAD = "NAD",// Namibian Dollar
MGA = "MGA",// Malagasy Ariary
MUR = "MUR",// Mauritian Rupee
SCR = "SCR",// Seychellois Rupee
KMF = "KMF",// Comorian Franc
DJF = "DJF",// Djiboutian Franc
ERN = "ERN",// Eritrean Nakfa
SDG = "SDG",// Sudanese Pound
SSP = "SSP",// South Sudanese Pound
BIF = "BIF",// Burundian Franc
RWF = "RWF",// Rwandan Franc
CDF = "CDF",// Congolese Franc
GNF = "GNF",// Guinean Franc
SLL = "SLL",// Sierra Leonean Leone
LRD = "LRD",// Liberian Dollar
GMD = "GMD",// Gambian Dalasi
PAB = "PAB",// Panamanian Balboa
CRC = "CRC",// Costa Rican Colón
GTQ = "GTQ",// Guatemalan Quetzal
HNL = "HNL",// Honduran Lempira
NIO = "NIO",// Nicaraguan Córdoba
DOP = "DOP",// Dominican Peso
HTG = "HTG",// Haitian Gourde
JMD = "JMD",// Jamaican Dollar
BBD = "BBD",// Barbados Dollar
BZD = "BZD",// Belize Dollar
BOB = "BOB",// Boliviano
PYG = "PYG",// Paraguayan Guaraní
UYU = "UYU",// Uruguayan Peso
VES = "VES",// Venezuelan Bolívar
GYD = "GYD",// Guyanese Dollar
SRD = "SRD",// Surinamese Dollar
TTD = "TTD",// Trinidad and Tobago Dollar
XCD = "XCD",// East Caribbean Dollar
AWG = "AWG",// Aruban Florin
ANG = "ANG",// Netherlands Antillean Guilder
BSD = "BSD",// Bahamian Dollar
BMD = "BMD",// Bermudian Dollar
KYD = "KYD",// Cayman Islands Dollar
FJD = "FJD",// Fijian Dollar
PGK = "PGK",// Papua New Guinean Kina
SBD = "SBD",// Solomon Islands Dollar
VUV = "VUV",// Vanuatu Vatu
WST = "WST",// Samoan Tala
TOP = "TOP",// Tongan Paʻanga
XPF = "XPF",// CFP Franc
PEN = "PEN",// Peruvian Sol
CUP = "CUP",// Cuban Peso
CUC = "CUC"
}
/**
* Type representing all valid currency codes from the Currency enum.
* This type can be used for type annotations and is backward compatible with string literals.
*/
type CurrencyCode = `${Currency}`;
type Provider = string;
interface ChargeInput {
amount?: number;
priceId?: string;
productId?: string;
currency: CurrencyCode;
email?: string;
successUrl?: string;
cancelUrl?: string;
metadata?: Record;
}
interface ChargeResult {
id: string;
status: "pending" | "succeeded" | "failed";
amount: number;
currency: CurrencyCode;
provider: Provider;
email?: string;
url?: string;
}
interface SubscribeInput {
plan: string;
currency: CurrencyCode;
email?: string;
successUrl?: string;
cancelUrl?: string;
metadata?: Record;
}
interface SubscriptionResult {
id: string;
status: "active" | "paused" | "cancelled" | "past_due";
plan: string;
currency: CurrencyCode;
provider: Provider;
email?: string;
url?: string;
}
interface CheckoutInput {
amount?: number;
currency: CurrencyCode;
email?: string;
plan?: string;
successUrl?: string;
cancelUrl?: string;
}
interface CheckoutResult {
url: string;
id: string;
provider: Provider;
}
interface CustomerInfo {
id?: string;
email?: string;
name?: string;
phone?: string;
address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
postalCode?: string;
country?: string;
};
}
/**
* Return type for the useCharge hook
*/
interface UseChargeReturn {
/**
* Execute a one-time payment charge
*/
charge: (input: ChargeInput) => Promise;
/**
* Loading state
*/
loading: boolean;
/**
* Error state
*/
error: Error | null;
/**
* The last successful charge result
*/
payment: ChargeResult | null;
}
/**
* Return type for the useSubscription hook
*/
interface UseSubscriptionReturn {
/**
* Create a new subscription
*/
subscribe: (input: SubscribeInput) => Promise;
/**
* Cancel a subscription
*/
cancel: (subscriptionId: string) => Promise;
/**
* Pause a subscription
*/
pause: (subscriptionId: string) => Promise;
/**
* Resume a paused subscription
*/
resume: (subscriptionId: string) => Promise;
/**
* Loading state
*/
loading: boolean;
/**
* Error state
*/
error: Error | null;
/**
* The current subscription
*/
subscription: SubscriptionResult | null;
}
/**
* Return type for the useBillingPortal hook
*/
interface UseBillingPortalReturn {
/**
* Open the billing portal for a customer
*/
open: (input: {
email: string;
}) => Promise;
/**
* Loading state
*/
loading: boolean;
}
/**
* Hook for one-time payments
*
* @example
* ```tsx
* const { charge, loading, error, payment } = useCharge();
*
* const handlePayment = async () => {
* const result = await charge({
* amount: 29,
* currency: 'USD',
* email: 'customer@example.com'
* });
* // Redirect to result.url if present
* };
* ```
*/
declare function useCharge(): UseChargeReturn;
/**
* Hook for subscription management
*
* @example
* ```tsx
* const { subscribe, cancel, pause, resume, loading, subscription } = useSubscription();
*
* const handleSubscribe = async () => {
* const result = await subscribe({
* plan: 'pro-monthly',
* currency: 'USD',
* email: 'customer@example.com'
* });
* // Redirect to result.url if present
* };
* ```
*/
declare function useSubscription(): UseSubscriptionReturn;
/**
* Hook for billing portal access
*
* @example
* ```tsx
* const { open, loading } = useBillingPortal();
*
* const handleOpenPortal = async () => {
* await open({ email: 'user@email.com' });
* // User is automatically redirected to the portal
* };
* ```
*/
declare function useBillingPortal(): UseBillingPortalReturn;
/**
* Provider types and configuration for PayLayer React
*/
/**
* Supported payment provider names
*/
type ProviderName = "stripe" | "paddle" | "paypal" | "lemonsqueezy" | "lemon-squeezy" | "polar" | "polar.sh";
/**
* Provider-specific configuration options
* These are client-side only and used for UI/API communication
*/
interface ProviderConfig {
/**
* Provider name/identifier
*/
name: ProviderName;
/**
* Display name for the provider (optional)
*/
displayName?: string;
/**
* Whether the provider is in sandbox/test mode
*/
sandbox?: boolean;
/**
* Additional provider-specific metadata
*/
metadata?: Record;
}
/**
* Provider registry entry
*/
interface ProviderRegistryEntry {
name: ProviderName;
config: ProviderConfig;
}
/**
* Payment provider interface
* All payment providers must implement this interface
*/
interface PaymentProvider {
/**
* Provider identifier (e.g., 'stripe', 'paddle')
*/
readonly name: string;
/**
* Creates a one-time payment charge
*/
charge(input: ChargeInput): Promise;
/**
* Creates a subscription
*/
subscribe(input: SubscribeInput): Promise;
/**
* Cancels a subscription
*/
cancel(subscriptionId: string): Promise;
/**
* Pauses a subscription
*/
pause(subscriptionId: string): Promise;
/**
* Resumes a paused subscription
*/
resume(subscriptionId: string): Promise;
/**
* Generates a billing portal URL
*/
portal(email: string): Promise;
/**
* Creates a checkout session/payment link
* Returns a URL that can be opened in a browser to complete payment
*/
checkout(input: CheckoutInput): Promise;
/**
* Verifies webhook signature
* For PayPal, this method is async and requires additional headers
*/
verifyWebhook(payload: string | ArrayBuffer | Uint8Array, signature: string, secret: string, headers?: Record): boolean | Promise;
/**
* Normalizes provider-specific webhook event
*/
normalizeWebhookEvent(rawEvent: unknown): unknown;
}
/**
* Provider factory - creates provider instances based on environment configuration
*/
/**
* Gets the configured payment provider instance
* Priority: explicitly set provider > config file > environment variable
*/
declare function getProvider(): PaymentProvider;
/**
* Resets the cached provider
*/
declare function resetProvider(): void;
/**
* Gets the configuration for a specific provider
*/
declare function getProviderConfig(name?: ProviderName): ProviderConfig | null;
/**
* Sets the active provider explicitly
* This takes highest priority over config file and environment variables
*/
declare function setProvider(name: ProviderName, config?: ProviderConfig): void;
/**
* Registers a provider configuration (for compatibility)
*/
declare function addProvider(name: ProviderName, config: ProviderConfig): void;
/**
* Gets all registered providers (for compatibility)
*/
declare function getRegisteredProviders(): Array<{
name: ProviderName;
config: ProviderConfig;
}>;
/**
* Checks if a provider is registered
*/
declare function isProviderRegistered(name: ProviderName): boolean;
/**
* Configuration types for PayLayer React
* Supports configuration via paylayer.config.js file
*/
/**
* Main PayLayer configuration interface
* This structure can be used in paylayer.config.js
*/
interface PayLayerConfig {
/**
* Payment provider to use
*/
provider: ProviderName;
/**
* Environment mode: 'sandbox'/'test' for testing, 'production'/'live' for production
*/
environment?: "sandbox" | "test" | "production" | "live";
/**
* Global URLs used as fallbacks across all providers
*/
successUrl?: string;
cancelUrl?: string;
checkoutBaseUrl?: string;
portalBaseUrl?: string;
/**
* Stripe provider configuration
*/
stripe?: {
/** Stripe secret key (sk_test_... or sk_live_...) */
secretKey: string;
/** Webhook secret for verifying webhook signatures */
webhookSecret?: string;
/** Success URL for checkout redirects */
checkoutSuccessUrl?: string;
/** Cancel URL for checkout redirects */
checkoutCancelUrl?: string;
/** Return URL for billing portal */
portalReturnUrl?: string;
};
/**
* Paddle provider configuration
*/
paddle?: {
/** Paddle API key */
apiKey: string;
/** Base URL for Paddle API (defaults to production or sandbox based on environment) */
baseUrl?: string;
/** API version header (defaults to "1") */
apiVersion?: string;
/** Default price ID to use when not specified in charge input */
defaultPriceId?: string;
/** Webhook secret for verifying webhook signatures */
webhookSecret?: string;
/** Whether to use sandbox mode (overrides global environment setting) */
sandbox?: boolean;
};
/**
* PayPal provider configuration
*/
paypal?: {
/** PayPal client ID */
clientId: string;
/** PayPal client secret */
clientSecret: string;
/** Base URL for PayPal API (defaults to production or sandbox based on environment) */
baseUrl?: string;
/** Return URL for successful payments */
returnUrl?: string;
/** Cancel URL for cancelled payments */
cancelUrl?: string;
/** Webhook ID for verifying webhook signatures */
webhookId?: string;
/** Brand name to display in PayPal checkout */
brandName?: string;
/** Base URL for PayPal portal (defaults to https://www.paypal.com) */
portalBaseUrl?: string;
/** Whether to use sandbox mode (overrides global environment setting) */
sandbox?: boolean;
};
/**
* Lemon Squeezy provider configuration
*/
lemonsqueezy?: {
/** Lemon Squeezy API key */
apiKey: string;
/** Base URL for Lemon Squeezy API (defaults to https://api.lemonsqueezy.com) */
baseUrl?: string;
/** Store ID required for charges and subscriptions */
storeId?: string;
/** Default variant ID to use when not specified in charge input */
defaultVariantId?: string;
/** Store subdomain for portal URLs */
storeSubdomain?: string;
/** Base URL for Lemon Squeezy portal (defaults to https://app.lemonsqueezy.com) */
portalBaseUrl?: string;
/** Webhook secret for verifying webhook signatures */
webhookSecret?: string;
/** Whether to use test mode (overrides global environment setting) */
testMode?: boolean;
};
/**
* Polar provider configuration
*/
polar?: {
/** Polar API key (can use apiKey, accessToken, or oat) */
apiKey?: string;
/** Polar access token (alternative to apiKey) */
accessToken?: string;
/** Polar OAT (Organization Access Token, alternative to apiKey/accessToken) */
oat?: string;
/** Base URL for Polar API (defaults to production or sandbox based on environment) */
baseUrl?: string;
/** Success URL for checkout redirects */
successUrl?: string;
/** Cancel URL for checkout redirects */
cancelUrl?: string;
/** Webhook secret for verifying webhook signatures */
webhookSecret?: string;
/** Whether to use sandbox mode (overrides global environment setting) */
sandbox?: boolean;
};
}
/**
* Config file loader for PayLayer React
* Loads configuration from paylayer.config.js in the project root
*/
/**
* Manually sets the configuration
* Useful for browser environments where config file loading isn't supported
* @param config The PayLayer configuration to use
*/
declare function setConfig(config: PayLayerConfig): void;
export { type ChargeInput, type ChargeResult, type CheckoutInput, type CheckoutResult, Currency, type CurrencyCode, type CustomerInfo, type PayLayerConfig, PayLayerProvider, type PayLayerProviderProps, type Provider, type ProviderConfig, type ProviderName, type ProviderRegistryEntry, type SubscribeInput, type SubscriptionResult, type UseBillingPortalReturn, type UseChargeReturn, type UseSubscriptionReturn, addProvider, getProvider, getProviderConfig, getRegisteredProviders, isProviderRegistered, resetProvider, setConfig, setProvider, useBillingPortal, useCharge, useSubscription };