# Demo: Your users give their own money

> An app lets users give their own money: they pick a charity and an amount, then pay the app. The server records the donation after payment; the receipt is in the donor's name.

One variant of **Your users give their own money**, in Software and apps: A one-off gift, the receipt in the donor's name.

A made-up site, your-app.example/donate, 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 and their profiles. Your own UI, built with the API: the amount, the payment form and the confirmation.

The full guide, with edge cases: https://www.charitips.com/docs/use-cases/b2c.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": "Our charities",
    "charityIds": [
      "<charityId>"
    ]
  }
  ```
- [`POST /v1/campaigns`](https://www.charitips.com/docs/api-reference/create-campaign.md) Create a campaign: once: the campaign, on an account with the B2C use case

  ```json
  {
    "name": "Donations",
    "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. Give to a cause

The donor picks a charity, then an amount, and pays you. Your server records the donation once your payment succeeds, with the donor's address for the fiscal receipt in their name.

- Your donation: 50,00 €
- Cost after the 66 % tax reduction: 17,00 €
- The customer picks a charity from your selection.
- Button: Give 50 € to the charity

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: after your payment succeeds; amount in cents, donor address for the receipt

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 5000,
    "hasBeenCharged": true,
    "withFiscalReceipt": true,
    "charityId": "<charityId>",
    "uniqueExternalId": "payment_9031",
    "donor": {
      "firstName": "Camille",
      "lastName": "Martin",
      "email": "camille.martin@example.com",
      "street": "12 rue des Lilas",
      "zip": "75011",
      "city": "Paris",
      "country": "FR"
    }
  }
  ```

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

### 2. Thank you

Receipts are yearly by default. For one receipt per donation, your server asks for it once the donation is processed; before that, the API answers 403. The PDF is generated in the background.

- Button: Donation processed

**Your server calls:**

- [`POST /v1/donations/{donationId}/fiscal-receipts`](https://www.charitips.com/docs/api-reference/create-donation-fiscal-receipt.md) Create a donation fiscal receipt: once the donation is processed; skip it to keep the yearly receipt

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

### 3. Your fiscal receipt

- Donation: 50,00 €
- Receipt: PDF
- Button: Download the PDF

**Your server calls:**

- [`GET /v1/donations/{donationId}/fiscal-receipt`](https://www.charitips.com/docs/api-reference/get-donation-fiscal-receipt.md) Get a donation fiscal receipt: returns the fiscalReceiptId of the donation
- [`GET /v1/fiscal-receipts/{fiscalReceiptId}/download-url`](https://www.charitips.com/docs/api-reference/generate-fiscal-receipt-download-url.md) Generate a fiscal receipt download url: a short-lived link to the PDF; retry if it is not ready yet

## Clone it with a coding agent

```prompt
Clone the Charitips demo "Your users give their own money" into this project. Read https://www.charitips.com/docs/demos/collect.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.
```

## Variants

**Variants**: the same flow in other sectors, each with its build spec.

- [Users give their own money](https://www.charitips.com/docs/use-cases/b2c/own-money.md) (Software and apps): An app lets users give their own money: they pick a charity and an amount, then pay the app. The server records the donation after payment; the receipt is in the donor's name. A one-off gift, the receipt in the donor's name. Build spec: https://www.charitips.com/docs/demos/collect.md
- [Donation matching](https://www.charitips.com/docs/use-cases/donation-matching.md) (Professional services): A user gives 20 € and the company adds 20 €. The user picks the charity, pays and gets the receipt for their part; the company gets its own receipt for the matched part. The user gives 20 €, the company adds 20 €. Build spec: https://www.charitips.com/docs/demos/matching.md
- [An extra on a group pot](https://www.charitips.com/docs/use-cases/b2c/pot-extra.md) (Banking and insurance): On a group pot, a contributor chips in for the gift and can add a donation in their own name on top. They pick the charity; the receipt is theirs, next to the platform's fee share. A contributor's extra, next to the platform's fee share. Build spec: https://www.charitips.com/docs/demos/collect/pot-extra.md
- [Savings interest, matched](https://www.charitips.com/docs/use-cases/b2c/interest-matched.md) (Banking and insurance): A bank proposes to give 10 % of the interest just credited on a savings account, and matches it euro for euro. The customer picks the charity and confirms; two receipts, one each. 10 % of the interest, matched by the bank. Build spec: https://www.charitips.com/docs/demos/collect/interest-matched.md
- [Badge unlocked by a gift](https://www.charitips.com/docs/use-cases/b2c/paid-badge.md) (Software and apps): A community platform sells a supporter badge for a 2 € donation. The member picks the charity and pays; the badge shows on their profile and the receipt is in their name. 2 € to unlock a profile badge. Build spec: https://www.charitips.com/docs/demos/collect/paid-badge.md
- [Second-hand seller's share](https://www.charitips.com/docs/use-cases/b2c/seller-share.md) (Retail): On a second-hand marketplace, a seller gives 10 % of a sale from their payout, in their own name. A badge shows on their listings and buyers see where the share goes. 10 % of a sale, given by the seller in their name. Build spec: https://www.charitips.com/docs/demos/collect/seller-share.md
- [Part of a buyback payout](https://www.charitips.com/docs/use-cases/b2c/device-buyback.md) (Retail): A buyback service offers 182 € for a used smartphone. Before accepting, the seller can give part of the payout to a charity they pick; the receipt is in their name. A platform buys a used smartphone for 182 €, the seller gives part of the payout in their name. Build spec: https://www.charitips.com/docs/demos/collect/device-buyback.md
- [Part of a clothes buyback](https://www.charitips.com/docs/use-cases/b2c/clothes-collection.md) (Retail): A fashion store buys back clothes dropped off in store, 26,40 € for seven pieces. The customer can give part of the buyback to a charity they pick; the receipt is theirs. Clothes dropped off in store, 26,40 € bought back, part of it given in the person's name. Build spec: https://www.charitips.com/docs/demos/collect/clothes-collection.md
