09 code Examples

Code Examples

Complete examples for common integration scenarios.


Checkout Widget (Easiest)

The fastest way to accept crypto payments. No backend required.

Basic HTML

<script src="https://api.stablix.xyz/js/checkout.js"></script>

<button onclick="pay()">Pay $49.99</button>

<script>
function pay() {
  StablixPay.setup({
    key: 'pk_live_your_public_key',
    amount: 49.99,
    currency: 'USDC',
    chain: 'solana',
    onSuccess: function(response) {
      alert('Payment successful!');
      window.location.href = '/thank-you?ref=' + response.invoice_id;
    }
  });
}
</script>

React / Next.js

Vue.js

With Backend Verification

Always verify payments on your backend before delivering goods/services:


Backend API Integration

For more control, use the API directly from your backend.

Node.js / Express

Usage


E-commerce Integration

Complete Checkout Flow


SaaS Subscription Integration

Subscription Management


Python Integration

Flask Example


PHP Integration


Webhook Testing

Test locally with ngrok

Verify webhook handling


Next Steps

Last updated