Pricing
Our Pricing Component is the ultimate solution for effortlessly browsing and purchasing your desired plan. It showcases a list of available plans and simplifies the payment process, letting you quick.
Last updated
npm install @questlabs/react-native-sdktype onPlanSelect?: (plan: TPlan | undefined) => void
type TPlan = {
id: number | string,
plan:string,
price:number,
description:string,
offer:string[],
recurringTimePeriod: string,
}
interface ICreatePaymentIntentProps {
card: TCard;
paymentMethod: PaymentMethod.Result;
}
type createPaymentIntent: ({ card, paymentMethod }):ICreatePaymentIntentProps ) => Promise<{ clientSecret: string; intentId: string }>;
type onPaymentSuccess: (paymentIntent: PaymentIntent) => void;import { Pricing } from "@questlabs/react-native-sdk";import { Pricing } from "@questlabs/react-native-sdk";
import {
Alert,
StyleSheet,
View,
} from "react-native";
import { TCard } from "@questlabs/react-native-sdk/src/components/Payment/Payment.types";
import {
PaymentIntent,
PaymentMethod,
} from "@questlabs/react-native-sdk/src/components/PricingCom/Pricing.types";
import {
STRIPE_PUBLISHABLE_KEY,
entiyCreditTier,
pricingData,
} from "./src/config";
export default function App() {
const createPaymentIntent = async ({
card,
paymentMethod,
}: {
card: TCard;
paymentMethod: PaymentMethod;
}) => {
let clientSecret = "";
let intentId = "";
// Your logic to create a clientSecret and an intentId
return {
clientSecret,
intentId,
};
};
const onPaymentSuccess = (data: PaymentIntent) => {
Alert.alert(
"Success",
`Payment of amount ${data.amount / 100} ${data.currency} was made`
);
};
return (
<View style={styles.container}>
<Pricing
stripePublishableKey={STRIPE_PUBLISHABLE_KEY}
data={pricingData}
createPaymentIntent={createPaymentIntent}
onPaymentSuccess={onPaymentSuccess}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
paddingTop: 20,
},
});