Use cases · Commerce
A donation with every order
Above a basket amount, you give and your customer chooses the charity.
- Who paysYour company
- Starts withA purchase
- Tax receiptIn your company's name
Needs API access on a validated account. Plans
your-store.example/checkout
Step by step
Click through the site. Each step shows what your customer does, what your server sends and what Charitips answers.
1Order paid
To comeYour customer does…
Clicks “Pay 76,00 €”.
Your server sends…
Creates a 2 € donation for order #1042 on the campaign “Checkout donations”.
POSTcreate-donation
Charitips answers…
Charitips records the donation and returns its id: it waits for your customer to pick a charity.
Charitips will then tell your server the donation was created.
2Charity chosen
To comeYour customer does…
Clicks “Give 2 € to the charity”.
Your server sends…
Assigns that donation to the charity your customer picks.
POSTclaim-donation
Charitips answers…
The donation now goes to the charity your customer picks.
Charitips will then tell your server the donation was updated.
3Order history
To comeYour customer does…
Sees “Your orders”.
Your server sends…
Your server reads the donation_update webhook and keeps the charity on the order. An order still waiting for a choice offers it again.
Charitips answers…
Nothing: Charitips is not called at this step.
How to read this demo: the site shows what your customer does, and the panel what your server sends and what Charitips answers, step by step.
The site is made up and nothing is sent. The endpoints, fields and webhook events are the real ones, and so are the charities.
This demo is one example. 2 € for every order over 50 €: that is the case the demo plays. The same flow also covers:
One flow, 3 variants
Each card is this flow in another sector or use case. Pick one: the demo above plays it, with its site, its amounts and its charities. The API calls stay the same.
Build it
The calls behind the demo, in order. Each step shows the request your server sends.
donation_createdonation_updateCreate the campaign
Once, create a charities selection with the charities you want to offer, create the campaign with its
charitiesSelectionId, then activate it, as in steps 3 to 5 of Your first donation. It works as a charity cashback for an online store: the customer picks the charity after paying, so your checkout stays as it is.POST /v1/campaignscurl -X POST https://api.sandbox.charitips.com/v1/campaigns \ -H "Authorization: Bearer $CHARITIPS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Order donations", "charitiesSelectionId": "<charitiesSelectionId>" }'Built from the spec and the API codeRequest bodies are written for this docs and checked against the API's validation; ids in angle brackets are placeholders. Response values are placeholders built from the schema.
Give on each paid order
When an order is paid, create a donation with the order id as
uniqueExternalId.amountis in cents. Create it from your payment webhook, not from the browser: if the customer closes the tab, the donation still exists.POST /v1/donationscurl -X POST https://api.sandbox.charitips.com/v1/donations \ -H "Authorization: Bearer $CHARITIPS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "campaignId": "<campaignId>", "amount": 200, "uniqueExternalId": "<orderId>" }'Built from the spec and the API codeRequest bodies are written for this docs and checked against the API's validation; ids in angle brackets are placeholders. Response values are placeholders built from the schema.
Show the charities
Read the selection with its charities from your server and render them on the confirmation page. Each charity comes with its
charityId,nameandlogoUrl. The list changes only when you edit the selection: cache it rather than reading it for every order.Shellcurl "https://api.sandbox.charitips.com/v1/charities-selections/<charitiesSelectionId>?includeCharities=true" \ -H "Authorization: Bearer $CHARITIPS_TOKEN"Claim it for the customer's charity
Claim the donation for the charity the customer picks. If the customer never chooses, the donation is assigned automatically when it expires or when the campaign closes. No donation is lost.
POST /v1/donations/<donationId>/claimcurl -X POST https://api.sandbox.charitips.com/v1/donations/<donationId>/claim \ -H "Authorization: Bearer $CHARITIPS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "charityId": "<charityId>" }'Built from the spec and the API codeRequest bodies are written for this docs and checked against the API's validation; ids in angle brackets are placeholders. Response values are placeholders built from the schema.
Listen for the claim
Create a webhook for
donation_updateonce, with Create a webhook. Each delivery, shortened here, holdsevent,payload, the donation as it is now, anddiff, the fields that changed. Whendiffholds acharityId, the donation is claimed, by the customer or automatically: find the order withpayload.uniqueExternalId. Verify the signature first, as shown in Webhooks configuration, and key your handler ondonationIdandstatus, since a delivery can arrive more than once.JSON{ "event": "donation_update", "payload": { "donationId": "<donationId>", "status": "DONE", "charityId": "<charityId>", "uniqueExternalId": "<orderId>" }, "diff": { "status": "DONE", "charityId": "<charityId>" }}
Edge cases
- Your payment webhook fires twice. The second create returns
409 Unique constraint failed on uniqueExternalId. Treat it as success. - The order is refunded. Delete the donation before it is billed or paid out; after that the API answers 403 (
Donation already invoiced,Donation already paidorDonation already processed). Once claimed, its amount is fixed. - You want the choice by email instead. Use a time-limited campaign with
sendingModeset toEMAILand pass the customer indonorwith the day to send it insendingDate: Charitips sends the email.
The memo
Send the memo to your team
Already written for this flow
- What it does and who pays, in a few sentences
- What you need: plan, API calls and webhooks
- What you can report: donations, charities, impact and receipts
To paste in an email, a document or a note.
Email it

