# Demo: Unused gift card balance

> When a gift card keeps a small balance or is about to expire, the store suggests giving it. The holder picks the charity, the card drops to zero and the store funds the donation.

One variant of **Loyalty points turned into donations**, in Retail: The remaining balance, given by the holder.

A made-up site, your-store.example/gift-cards, walked through screen by screen with the Charitips API calls the product makes at each step. Rebuild it in your own project to start from a working flow.

The charity choice in this demo is the Charitips [charity selection widget](https://www.charitips.com/docs/widgets/charity_selection.md), a ready-made proposal. Use it whole, use parts of it, or build your own experience from scratch with the API: [List charities](https://www.charitips.com/docs/api-reference/list-charities.md) gives the charities to show, and the calls below carry the chosen `charityId`.

Charitips widget: the charity cards, their profiles and the thank-you card with sharing, matching and newsletter. Your own UI, built with the API: the gift card and its balance, the choice to keep or give it, and the confirmation once the thank-you card is closed.

The full guide, with edge cases: https://www.charitips.com/docs/use-cases/gift-card-balance.md.

The full guide, with edge cases: https://www.charitips.com/docs/use-cases/gift-card-balance.md.

**Once, before the first customer:**

- [`POST /v1/charities-selections`](https://www.charitips.com/docs/api-reference/create-charities-selection.md) Create a charities selection: once: the charities you offer, from the catalog

  ```json
  {
    "name": "Gift card charities",
    "charityIds": [
      "<charityId>"
    ]
  }
  ```
- [`POST /v1/campaigns`](https://www.charitips.com/docs/api-reference/create-campaign.md) Create a campaign: once: the campaign the donations go to

  ```json
  {
    "name": "Gift card balances",
    "charitiesSelectionId": "<charitiesSelectionId>"
  }
  ```
- [`POST /v1/campaigns/{campaignId}/activate`](https://www.charitips.com/docs/api-reference/activate-campaign.md) Activate a campaign: once: the campaign starts taking donations

## Screens and calls

### 1. Your gift card

Keeping the balance is the default. For a small balance or a card about to expire, the page suggests giving it: the holder picks the charity, then one call records the donation. Your store funds it and gets the fiscal receipt.

- Card: •••• 5521
- Balance left: 3,40 €
- The customer picks a charity from your selection.
- Button: Give 3,40 € to the charity

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: when the holder confirms, with the chosen charity: the donation is assigned at once; amount in cents; then your system sets the card to zero

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 340,
    "charityId": "<charityId>",
    "uniqueExternalId": "card_5521"
  }
  ```

Charitips then sends the `donation_create` webhook to your endpoint.

## Clone it with a coding agent

```prompt
Clone the Charitips demo "Unused gift card balance" into this project. Read https://www.charitips.com/docs/demos/gift-cards.md: it lists each screen and the Charitips API calls behind it. Build the same flow in this codebase, on the sandbox (https://api.sandbox.charitips.com), with my client id and secret read from environment variables, and follow the rules of https://www.charitips.com/docs/skill.md. Make every API call from the server, never from the browser. When it works, show me each call and its response.
```
