# Demo: Loyalty points turned into donations: Solidarity items in an in-game shop

> In a game's shop, some items are tied to a charity. When the player buys one with gems earned in play, the studio gives 1 € or 2 € for it; the player never pays.

One variant of **Loyalty points turned into donations**, in Culture and events: 1 € or 2 € from the studio for each solidarity item bought.

A made-up site, play.your-studio.example, 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 full guide, with edge cases: https://www.charitips.com/docs/use-cases/loyalty-points.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": "Solidarity items",
    "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": "Solidarity items",
    "charitiesSelectionId": "<charitiesSelectionId>",
    "type": "PERMANENT",
    "amountType": "FREE_AMOUNT"
  }
  ```
- [`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. Elixir bought, the studio gives to its charity

- Button: Buy the elixir

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: from your server, when it happens; amount in cents

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 100,
    "charityId": "<charityId>",
    "uniqueExternalId": "purchase_88412",
    "externalId": "player_77361"
  }
  ```

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

### 2. Seed bought, the studio gives to its charity

- Button: Buy the seed

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: from your server, when it happens; amount in cents

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 100,
    "charityId": "<charityId>",
    "uniqueExternalId": "purchase_88413",
    "externalId": "player_77361"
  }
  ```

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

### 3. Bread bought, the studio gives to its charity

- Button: Buy the bread

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: from your server, when it happens; amount in cents

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 200,
    "charityId": "<charityId>",
    "uniqueExternalId": "purchase_88414",
    "externalId": "player_77361"
  }
  ```

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

## Clone it with a coding agent

```prompt
Clone the Charitips demo "Loyalty points turned into donations: Solidarity items in an in-game shop" into this project. Read https://www.charitips.com/docs/demos/loyalty/in-game-shop.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.
```
