Skip to content

JavaScript widget

Two lines of code: the widget creates the session with your public key and opens the payment page on top of your page (popup) or as a redirect. No server needed.

HTML
<script src="https://cartflox.com/cartflox.js"></script>
<script>
Cartflox.configure({ publicKey: "af_live_pub_YOUR_KEY", mode: "popup" });
</script>
<button data-cartflox-amount="5000" data-cartflox-currency="XOF"
data-cartflox-description="Odoo training">
Pay 5,000 XOF
</button>
JavaScript
Cartflox.checkout({
amount: 5000,
currency: "XOF",
customer_email: "awa@example.com",
customer_phone: "+2250700000000",
description: "Order #1042",
metadata: { order_id: "1042" },
success_url: "https://maboutique.com/merci",
cancel_url: "https://maboutique.com/panier",
onSuccess: function (data) { /* the window closes: show a waiting message */ },
onClose: function () {},
onError: function (err) { console.error(err); }
});
Option Type Required Description
publicKey string Yes Your public key af_live_pub_... (API and Logs section). It can only create sessions.
mode string No popup (window on top of your page, default) or redirect (the customer leaves your page)
currency string No Default currency for buttons
success_url, cancel_url string No Return addresses, used in redirect mode
metadata object No Data returned in the webhook (order number, customer ID…)
merchant_name string No Name shown at the top of the payment page instead of your workspace name
merchant_logo string No https address of a logo shown instead of your workspace logo