> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackfront.digital/llms.txt
> Use this file to discover all available pages before exploring further.

# Redeeming Points

# Redeeming Points

The `redeem` method exchanges points for a discount on an order. It is available through the `useLoyalty` hook and the `LoyaltyService`.

## Usage

```tsx theme={null}
import { useLoyalty } from 'react-native-stackfront-sdk';

function RedeemPoints({ customerId, cartTotal }: { customerId: string; cartTotal: number }) {
  const { account, redeem, loading } = useLoyalty(customerId);
  const [pointsToUse, setPointsToUse] = useState('');

  const handleRedeem = async () => {
    try {
      const result = await redeem(Number(pointsToUse), cartTotal);
      Toast.show(`Redeemed ${result.pointsRedeemed} points for $${result.discountAmount}`);
    } catch (err) {
      Toast.show(err.message);
    }
  };

  if (!account) return null;

  return (
    <View>
      <Text>Available: {account.pointsBalance} points</Text>
      <Input
        value={pointsToUse}
        onChangeText={setPointsToUse}
        placeholder="Points to redeem"
        keyboardType="numeric"
      />
      <Button
        title="Redeem"
        onPress={handleRedeem}
        disabled={loading || !pointsToUse}
      />
    </View>
  );
}
```

## Hook API

```ts theme={null}
redeem: (pointsToRedeem: number, orderTotal: number) => Promise<RedeemPointsResponse>
```

## Response Shape

```ts theme={null}
{
  success: boolean;
  pointsRedeemed: number;
  discountAmount: number;
  remainingBalance: number;
  message: string;
}
```

## Service API

```ts theme={null}
const { loyalty } = useStackfront();
const result = await loyalty.redeem({
  customerId: 'customer-id',
  pointsToRedeem: 500,
  orderTotal: 49.99,
});
```
