Integrate
Widgets
The ready-made blocks you can embed in your product, the key or token each one opens with, and how to install them for React, React Native or any web page.
Widgets are ready-made blocks of the Charitips interface that you embed in your product: choosing a charity, giving with a card, following a campaign, filling billing details. They load in a frame from Charitips and talk to the API for you. They are one way to integrate among others: use them whole, next to your own screens, or build everything yourself with the API.
In short
- Install
@charitips/embed-react,@charitips/embed-react-nativeor@charitips/embed, or load the script on any page. - Point them at
https://embed.sandbox.charitips.comon the sandbox andhttps://embed.charitips.comon live. - The charity selection widget opens with the campaign's
publicKey, which can be public. Admin and donor widgets need a token your server creates, valid one day. - Your API credentials never reach the browser: when a widget needs a donation created, it calls your server, which calls Charitips.
The widgets
| Widget | What it does | Opens with |
|---|---|---|
| Charity selection | shows the campaign's charities and lets the person choose one | the campaign's publicKey |
| Donor | the person gives with their own card, once or every month (B2C) | the publicKey, or a donor token from Create a donor widget token |
| Admin | campaign metrics, fiscal receipts and the selection, for your customers or your team | an admin token from Create an admin widget token |
| Billing | a business customer fills its billing details and payment method | the secret of a shareable billing link |
Find a campaign's publicKey in the create response or in its information tab in the dashboard.
Install
npm install @charitips/embed-reactimport { CharitipsProvider } from '@charitips/embed-react'; export function App({ children }) { return ( // https://embed.charitips.com on live <CharitipsProvider baseUrl="https://embed.sandbox.charitips.com"> {children} </CharitipsProvider> );}The libraries come with their TypeScript types.
Options every widget shares
size:fillContainerfills the parent element;fitContentgrows with the content, for a widget inside a scrolling page. Admin and donor widgets default tofitContent, the others tofillContainer.locale:fr(default) oren, on every widget but billing.id: a name of your own, to tell apart several widgets on one page.
Related
Authentication, Charities and selections, Your users give their own money.