Add PayPal checkout provider
This commit is contained in:
@@ -21,9 +21,11 @@ interface CheckoutWizardContextType {
|
||||
currentStep: CheckoutStepId;
|
||||
isAuthenticated: boolean;
|
||||
authUser: unknown;
|
||||
lemonsqueezyConfig?: {
|
||||
store_id?: string | null;
|
||||
test_mode?: boolean | null;
|
||||
paypalConfig?: {
|
||||
client_id?: string | null;
|
||||
currency?: string | null;
|
||||
intent?: string | null;
|
||||
locale?: string | null;
|
||||
} | null;
|
||||
paymentCompleted: boolean;
|
||||
checkoutSessionId: string | null;
|
||||
@@ -119,9 +121,11 @@ interface CheckoutWizardProviderProps {
|
||||
initialStep?: CheckoutStepId;
|
||||
initialAuthUser?: unknown;
|
||||
initialIsAuthenticated?: boolean;
|
||||
lemonsqueezy?: {
|
||||
store_id?: string | null;
|
||||
test_mode?: boolean | null;
|
||||
paypal?: {
|
||||
client_id?: string | null;
|
||||
currency?: string | null;
|
||||
intent?: string | null;
|
||||
locale?: string | null;
|
||||
} | null;
|
||||
}
|
||||
|
||||
@@ -132,7 +136,7 @@ export function CheckoutWizardProvider({
|
||||
initialStep,
|
||||
initialAuthUser,
|
||||
initialIsAuthenticated,
|
||||
lemonsqueezy,
|
||||
paypal,
|
||||
}: CheckoutWizardProviderProps) {
|
||||
const customInitialState: CheckoutState = {
|
||||
...initialState,
|
||||
@@ -153,7 +157,7 @@ export function CheckoutWizardProvider({
|
||||
if (savedState) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedState);
|
||||
const hasValidPackage = parsed.selectedPackage && typeof parsed.selectedPackage.lemonsqueezy_variant_id === 'string' && parsed.selectedPackage.lemonsqueezy_variant_id !== '';
|
||||
const hasValidPackage = parsed.selectedPackage && typeof parsed.selectedPackage.id === 'number';
|
||||
if (hasValidPackage && initialPackage && parsed.selectedPackage.id === initialPackage.id && parsed.currentStep !== 'confirmation') {
|
||||
// Restore state selectively
|
||||
if (parsed.selectedPackage) dispatch({ type: 'SELECT_PACKAGE', payload: parsed.selectedPackage });
|
||||
@@ -284,7 +288,7 @@ export function CheckoutWizardProvider({
|
||||
currentStep: state.currentStep,
|
||||
isAuthenticated: state.isAuthenticated,
|
||||
authUser: state.authUser,
|
||||
lemonsqueezyConfig: lemonsqueezy ?? null,
|
||||
paypalConfig: paypal ?? null,
|
||||
paymentCompleted: state.paymentCompleted,
|
||||
checkoutSessionId: state.checkoutSessionId,
|
||||
selectPackage,
|
||||
|
||||
Reference in New Issue
Block a user