Skip to main content

Customer

The customer module gives you access to customer profiles, order history, and subscriptions. Use it to build account dashboards, order tracking pages, and subscription management UIs.

Get Customer Profile

const customer = await tagada.customer.getProfile(customerId);

By Email

const customer = await tagada.customer.getByEmail('jane@example.com');
// Returns Customer or null if not found

Update Profile

const updated = await tagada.customer.updateProfile(customerId, {
  firstName: 'Jane',
  lastName: 'Doe',
  phone: '+33612345678',
});

Orders

List Orders

const { orders, total } = await tagada.customer.getOrders(customerId, {
  limit: 10,
  offset: 0,
});

Get Single Order

const order = await tagada.customer.getOrder(orderId);

Subscriptions

List Subscriptions

const subscriptions = await tagada.customer.getSubscriptions(customerId);

Get Single Subscription

const subscription = await tagada.customer.getSubscription(subscriptionId);

React Hook

import { useCustomer } from '@tagadapay/headless-sdk/react';

function CustomerDashboard({ customerId }: { customerId: string }) {
  const {
    customer,
    orders,
    subscriptions,
    isLoading,
    error,
    loadCustomer,
    loadOrders,
    loadSubscriptions,
    updateProfile,
  } = useCustomer(customerId); // auto-loads profile when customerId is provided

  useEffect(() => {
    if (customerId) {
      loadOrders(customerId);
      loadSubscriptions(customerId);
    }
  }, [customerId]);

  if (isLoading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;

  return (
    <div>
      <h1>Welcome, {customer?.firstName}</h1>

      <h2>Orders</h2>
      {orders.map((order) => (
        <div key={order.id}>
          Order #{order.orderNumber}{order.status}
        </div>
      ))}

      <h2>Subscriptions</h2>
      {subscriptions.map((sub) => (
        <div key={sub.id}>
          {sub.name}{sub.status}
        </div>
      ))}
    </div>
  );
}

Full Hook API

Property / MethodDescription
customerCurrent customer profile (null until loaded)
ordersArray of customer orders
subscriptionsArray of customer subscriptions
isLoadingTrue during any async operation
errorLast error, if any
loadCustomer(customerId)Load customer profile (called automatically if customerId is passed to the hook)
loadOrders(customerId, opts?)Fetch orders. Optional: { limit?, offset? }
loadSubscriptions(customerId)Fetch all subscriptions
updateProfile(customerId, data)Update customer name, phone, etc.