Quickstart
Make your first request with a test key, then take a test payment through a payment session. Everything here runs on your server except the last step.
Create a test secret key on the Developers page. The full key is shown once, when you create it; copy it then. Keep it on your server. Never put a secret key in a web page, a mobile app or a repository.
1. Make a request
There are no server libraries. Call the API over HTTPS with the key in an Authorization: Bearer header.
curl -G https://api.cari.finance/charges \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-d limit=10
2. Open a payment session
Your server fixes the amount and currency. Amounts are integers in the smallest unit of the currency (2500 is 25.00 in USD).
Create a payment session
curl https://api.cari.finance/payment-sessions \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 2500, "currency": "usd", "description": "Order 1042"}'
The answer holds an id and a client_secret. Send both to the page that shows the checkout. See Payment sessions.
3. Complete it in the browser
<div id="checkout"></div>
<script src="https://cdn.cari.finance/js/v2/cari-finance.min.js"></script>
<script>
const cf = new CariFinance("pk_test_YOUR_PUBLISHABLE_KEY");
cf.mountCheckout("#checkout", {
sessionId: "ps_...", // from your server
clientSecret: "...", // from your server
onSuccess: (r) => console.log("Paid", r.charge_id),
onError: (e) => console.error(e.message),
});
</script>
See Checkout widget for what the script does and refuses to do.
What's next?
- Authentication: secret and publishable keys, test and live
- Payment sessions
- Charges and Refunds
- Errors
- Webhooks: not available yet