Last updated: June 22, 2023Next: Webhooks

Custom Checkout

Integrate a seamless cryptocurrency checkout experience directly into your website or application.

Overview

ZenPay Custom Checkout provides a complete, customizable checkout solution that integrates directly into your website. Unlike payment buttons or checkout links, Custom Checkout gives you full control over the payment experience while maintaining security and ease of use.

Seamless Experience

Keep customers on your website throughout the payment process.

  • • No redirects to external pages
  • • Consistent brand experience
  • • Higher conversion rates

Complete Customization

Tailor the checkout UI to match your website design.

  • • Custom styling options
  • • Configurable UI components
  • • Flexible layout options

Developer-Friendly

Built with developers in mind for easy integration.

  • • Comprehensive SDK
  • • React, Vue, and Angular support
  • • Detailed documentation

Secure By Design

Security built in at every layer.

  • • PCI compliant infrastructure
  • • No cryptocurrency data stored on your server
  • • End-to-end encryption

Integration Options

ZenPay Custom Checkout offers two main integration approaches to suit different development needs:

Drop-in Checkout

The fastest way to integrate ZenPay's Custom Checkout

This option provides a pre-built checkout UI that you can customize with your colors and branding.

Use When:

  • You need a quick integration with minimal development effort
  • Customizing colors and text is sufficient for your needs
  • You prefer a solution that works out of the box

Custom UI Integration

Complete control over the checkout experience

For developers who want complete control over the checkout experience using ZenPay's SDK components.

Use When:

  • You need complete control over the checkout UI
  • Your checkout flow requires custom steps or validation
  • You want to build a native-feeling experience within your application

Drop-in Checkout Example

Here's how to quickly integrate ZenPay's Drop-in Checkout:

JavaScript Integration

JavaScript
// 1. Include ZenPay.js on your page
<script src="https://js.zenpay.io/v1/zenpay.js"></script>

// 2. Configure your checkout
<script>
  document.addEventListener('DOMContentLoaded', function() {
    const zenpay = new ZenPay('pk_test_YourPublicKey');
    
    document.getElementById('pay-button').addEventListener('click', async () => {
      try {
        // Create a checkout session
        const session = await zenpay.createCheckoutSession({
          amount: 99.99,
          currency: 'USD',
          product_name: 'Premium Membership',
          customer_email: 'customer@example.com',
          success_url: window.location.origin + '/thank-you',
          cancel_url: window.location.origin + '/cart'
        });
        
        // Launch the checkout modal
        zenpay.showCheckout(session.id, {
          theme: {
            colorPrimary: '#4F46E5',
            colorBackground: '#FFFFFF',
            colorText: '#1F2937',
            borderRadius: '8px',
            fontFamily: 'Inter, sans-serif'
          }
        });
      } catch (error) {
        console.error('Error creating checkout session:', error);
      }
    });
  });
</script>

// 3. Add a button to trigger checkout
<button id="pay-button" class="payment-button">Pay with Crypto</button>

React Custom UI Integration

For complete control over the checkout experience using React:

React SDK Example

React
// First, install the ZenPay React SDK
// npm install @zenpay/react

import React, { useState } from 'react';
import { 
  ZenPayProvider, 
  useZenPay,
  CryptoPaymentForm,
  CryptoMethodSelector,
  CheckoutSummary,
  PaymentStatus
} from '@zenpay/react';

// Your checkout component
function CustomCheckout({ amount, currency, productName }) {
  const [paymentStatus, setPaymentStatus] = useState('idle');
  const [selectedMethod, setSelectedMethod] = useState(null);
  const { createPayment, getPaymentStatus } = useZenPay();
  
  const handleSubmit = async () => {
    try {
      setPaymentStatus('processing');
      
      // Create a payment with ZenPay
      const payment = await createPayment({
        amount,
        currency,
        product_name: productName,
        payment_method: selectedMethod,
        metadata: {
          customer_id: 'cust_123456', // Your internal customer ID
          order_id: 'ord_789012'      // Your internal order ID
        }
      });
      
      // Poll for payment status
      const statusInterval = setInterval(async () => {
        const status = await getPaymentStatus(payment.id);
        
        if (status === 'completed') {
          setPaymentStatus('success');
          clearInterval(statusInterval);
        } else if (status === 'failed') {
          setPaymentStatus('error');
          clearInterval(statusInterval);
        }
      }, 5000);
      
    } catch (error) {
      console.error('Payment error:', error);
      setPaymentStatus('error');
    }
  };
  
  return (
    <div className="checkout-container">
      <CheckoutSummary 
        amount={amount} 
        currency={currency} 
        productName={productName} 
      />
      
      <CryptoMethodSelector 
        onChange={method => setSelectedMethod(method)} 
        selectedMethod={selectedMethod}
      />
      
      {selectedMethod && (
        <CryptoPaymentForm 
          method={selectedMethod} 
          onSubmit={handleSubmit}
        />
      )}
      
      {paymentStatus !== 'idle' && (
        <PaymentStatus status={paymentStatus} />
      )}
    </div>
  );
}

// Wrap your app with the provider
function App() {
  return (
    <ZenPayProvider apiKey="pk_test_YourPublicKey">
      <CustomCheckout 
        amount={99.99}
        currency="USD"
        productName="Premium Membership"
      />
    </ZenPayProvider>
  );
}

Customization Options

The Drop-in Checkout can be customized in several ways to match your website's design:

Theme Customization

Adjust the visual appearance of the checkout:

  • Colors: primary, background, text, success, error
  • Typography: font family, font sizes, weights
  • Shapes: border radius, input styles, button styles
  • Spacing: paddings, margins, layout
  • Light and dark mode support

Layout Options

Control how the checkout appears on your page:

  • Modal dialog or inline embed
  • Responsive behavior for different screen sizes
  • Single-page or multi-step checkout flow
  • Sidebar or full-width layout

Next Steps

After implementing Custom Checkout, explore these related features:

Webhooks

Set up real-time payment notifications for your backend

API Reference

Browse the complete API documentation