# Demo: Round-up on every payment: Online store checkout

> An online store offers to round the order total up to the next euro at checkout. The customer ticks the round-up, picks the charity, pays the difference with the order and gets the receipt in their name.

One variant of **Round-up on every payment**, in Retail: The order total rounded up to the next euro.

A made-up site, your-store.example/checkout, 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 checkout, the round-up tick box, the order summary and the pay button.

The full guide, with edge cases: https://www.charitips.com/docs/use-cases/round-up.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": "Checkout round-up 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": "Checkout round-ups",
    "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. Round up at checkout

The customer ticks the round-up at checkout and picks a charity in the widget. Your store keeps both with the order. Nothing is sent to Charitips yet.

- The customer picks a charity from your selection.
- Button: Round my total up to 55,00 €

No call: this screen only shows the result.

### 2. Order paid with its round-up

The customer pays the order and the round-up in one payment. Your server then records the donation in the customer's name, with the order's billing name and address: the fiscal receipt goes to them, and in France 66 % of the donation comes off their income tax.

- Order total: 54,40 €
- Round-up for the charity: 0,60 €
- **Charged to the customer: 55,00 €**
- Button: Pay 55,00 €

**Your server calls:**

- [`POST /v1/donations`](https://www.charitips.com/docs/api-reference/create-donation.md) Create a donation: once the order is paid, from your payment webhook; amount in cents; hasBeenCharged puts the receipt in the customer's name, at the order's billing address

  ```json
  {
    "campaignId": "<campaignId>",
    "amount": 60,
    "uniqueExternalId": "order_20817",
    "externalId": "customer_5521",
    "charityId": "<charityId>",
    "hasBeenCharged": true,
    "withFiscalReceipt": true,
    "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.

### 3. Order refunded

The order is refunded: your server deletes its round-up, as long as it is not billed yet.

- Button: Simulate a refund of the order

**Your server calls:**

- [`DELETE /v1/donations/{donationId}`](https://www.charitips.com/docs/api-reference/delete-donation.md) Delete a donation: donationId kept with the order; only before the monthly bill

## Clone it with a coding agent

```prompt
Clone the Charitips demo "Round-up on every payment: Online store checkout" into this project. Read https://www.charitips.com/docs/demos/round-up/online-checkout.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.
```
