zips-react-native-sdk-test
Version:
Lightweight ZIPS Payment Gateway SDK for React Native - Complete payment solution with ZApp wallet payments and Access Bank integration
52 lines (51 loc) • 2 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useState } from 'react';
const zipsContext = createContext(undefined);
export const useZipsContext = () => {
const context = useContext(zipsContext);
if (!context) {
throw new Error('useZipsContext must be used within a ZipsProvider');
}
return context;
};
export const ZipsProvider = ({ children }) => {
const [isLoading, setIsLoading] = useState(false);
const [isPaid, setIsPaid] = useState(false);
const [error, setError] = useState(null);
const [order, setOrder] = useState(null);
const [paymentMethod, setPaymentMethod] = useState({});
const [paymentDetails, setPaymentDetails] = useState({});
const [transactionDetails, setTransactionDetails] = useState(null);
const [environment, setEnvironment] = useState('sandbox');
const [apiKey, setApiKey] = useState(undefined);
const [currentStep, setCurrentStep] = useState('method-selection');
const setZips = (zips) => {
setPaymentMethod(zips === null || zips === void 0 ? void 0 : zips.paymentMethod);
setPaymentDetails(zips === null || zips === void 0 ? void 0 : zips.paymentDetails);
setEnvironment((zips === null || zips === void 0 ? void 0 : zips.environment) || 'sandbox');
setApiKey(zips === null || zips === void 0 ? void 0 : zips.apiKey);
};
return (_jsx(zipsContext.Provider, { value: {
isLoading,
setIsLoading,
isPaid,
setIsPaid,
error,
setError,
order,
setOrder,
paymentMethod,
setPaymentMethod,
paymentDetails,
setPaymentDetails,
environment,
setEnvironment,
transactionDetails,
setTransactionDetails,
apiKey,
setApiKey,
currentStep,
setCurrentStep,
setZips,
}, children: children }));
};