react-paddle-hooks
Version:
A collection of React hooks for integrating Paddle payment platform
49 lines (48 loc) • 1.32 kB
TypeScript
/// <reference types="react" />
import { Paddle } from "@paddle/paddle-js";
interface PaddleHookOptions {
environment: "sandbox" | "production";
token: string;
eventCallback?: (data: any) => void;
checkoutSettings?: {
successUrl?: string;
};
}
interface CheckoutOptions {
items: {
priceId: string;
quantity?: number;
}[];
customer?: {
email: string;
address: {
countryCode: string;
postalCode: string;
region: string;
city: string;
firstLine: string;
};
};
settings?: {
displayMode?: "overlay" | "inline";
theme?: "light" | "dark";
locale?: string;
};
}
interface ProductPrices {
[key: string]: string;
}
interface ProductDetails {
productId: string;
monthlyPriceId: string;
yearlyPriceId: string;
}
declare const usePaddle: (options: PaddleHookOptions) => {
paddle: Paddle | undefined;
openCheckout: (checkoutOptions: CheckoutOptions) => void;
getPrices: (productDetails: ProductDetails[], cycle: "month" | "year") => void;
productPrices: ProductPrices;
billingCycle: "month" | "year";
setBillingCycle: import("react").Dispatch<import("react").SetStateAction<"month" | "year">>;
};
export default usePaddle;