Skip to main content

Subscription Example

Coming soon! This example will demonstrate how to manage subscriptions in your React Native app.

For now, see the Subscriptions API documentation for details on available methods.

Quick Preview

import { useEasy } from "@easylabs/react-native";
import { useState, useEffect } from "react";
import { FlatList, Text, View, Button } from "react-native";

function SubscriptionList() {
const { getSubscriptionPlans, createSubscription } = useEasy();
const [plans, setPlans] = useState([]);

useEffect(() => {
loadPlans();
}, []);

const loadPlans = async () => {
const result = await getSubscriptionPlans({ limit: 20 });
setPlans(result.data);
};

const handleSubscribe = async (planId) => {
await createSubscription({
subscription_plan_id: planId,
buyer_details: {
identity_id: "cust_123",
first_name: "John",
last_name: "Doe",
email: "john@example.com",
},
});
};

return (
<FlatList
data={plans}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View>
<Text>{item.plan_name}</Text>
<Text>${(item.amount / 100).toFixed(2)}</Text>
<Button title="Subscribe" onPress={() => handleSubscribe(item.id)} />
</View>
)}
/>
);
}

Next Steps