JS button guide

The hosted script /js/cxpay-button.js (versioned, no dependencies) mounts buttons that call POST /public/checkout-sessions and open hosted checkout. Amount, currency, description, and success/cancel URLs are configured on the dashboard payment button — the browser never chooses the price. Secret API keys never appear in page source.

  1. In /install, create a publishable key (cxpay_pk_test_ / cxpay_pk_live_). When logged in, snippets are pre-filled with your key.
  2. Create a payment button with a fixed USD amount and optional success/cancel URLs.
  3. Paste the snippet below. data-amount / data-currency / data-description are for your page label; checkout uses the button config. data-order-ref is sent as orderReference (and order number metadata). Optional data-customer-email is stored on the invoice/intent.
<script src="https://cxpay.cash/js/cxpay-button.js"></script>
<button
  type="button"
  class="cxpay-pay"
  data-key="cxpay_pk_live_YOUR_PUBLISHABLE_KEY"
  data-button="btn_YOUR_BUTTON_ID"
  data-amount="10.00"
  data-currency="USD"
  data-description="Order #1001"
  data-order-ref="1001"
  data-customer-email="[email protected]"
>
  Pay with CX Pay
</button>

Optional: data-api to override the API base. Call CxPay.mount() if you inject buttons after load. Legacy alias: /js/cxpay.js loads the same script.

No JavaScript? Use the hosted checkout snippet.