Everything you need to integrate in-app purchases into your React Native apps
import { CroissantPayProvider, usePurchases } from '@croissantpay/react-native';
function App() {
return (
<CroissantPayProvider
apiKey="mx_public_your_key"
userId={userId}
>
<SubscriptionScreen />
</CroissantPayProvider>
);
}
function SubscriptionScreen() {
const {
offerings,
purchaseProduct,
hasEntitlement
} = usePurchases();
const isPro = hasEntitlement('pro');
if (isPro) {
return <ProContent />;
}
return (
<View>
{offerings?.current?.packages.map(pkg => (
<Button
key={pkg.id}
title={`Subscribe for ${pkg.product.priceString}`}
onPress={() => purchaseProduct(pkg.product)}
/>
))}
</View>
);
}