Skip to main content

MyazaPOSConfig

Pass a configuration object when creating a MyazaPOS instance:
import { MyazaPOS } from '@myazahq/pos-sdk';

const pos = new MyazaPOS({
  merchantId: 'your-merchant-id',
  isSandbox: true,
  theme: {
    primaryColor: '#6C47FF',
    colorScheme: 'dark',
  },
});

Options

merchantId
string
required
Your Myaza merchant ID from the dashboard.
isSandbox
boolean
default:"false"
Enable sandbox mode for testing without real funds.
apiBaseUrl
string
Override the API base URL. Defaults to the production or sandbox URL based on isSandbox.
defaultChain
string
Pre-select a blockchain in the checkout modal (e.g. "polygon").
defaultToken
string
Pre-select a token in the checkout modal (e.g. "USDC").
pollIntervalMs
number
default:"5000"
How often to poll for payment status in milliseconds.
maxPollDurationMs
number
Maximum duration to poll before timing out.
requestTimeoutMs
number
Timeout for individual API requests in milliseconds.
maxRetries
number
Maximum number of retries for failed API requests.
redirectUrl
string
URL to redirect the customer to after payment completes.
theme
ThemeConfig
Customize the checkout modal appearance. See Theme below.
fraud
FraudConfig
Configure fraud detection rules. See Fraud Detection below.
plugins
MyazaPlugin[]
Register plugins at initialization. See the Plugins guide.
telemetry
TelemetryConfig
Configure logging and observability. See Telemetry below.

Theme

Customize the look and feel of the checkout modal:
const pos = new MyazaPOS({
  merchantId: 'your-merchant-id',
  theme: {
    primaryColor: '#6C47FF',
    secondaryColor: '#9B7FFF',
    backgroundColor: '#FFFFFF',
    textColor: '#1A1A2E',
    borderRadius: 12,
    fontFamily: 'Inter, sans-serif',
    logoUrl: 'https://example.com/logo.png',
    colorScheme: 'light',
    customCss: '.myaza-modal { box-shadow: 0 8px 32px rgba(0,0,0,0.12); }',
  },
});

ThemeConfig

PropertyTypeDescription
primaryColorstringPrimary brand color for buttons and accents
secondaryColorstringSecondary color for hover states and highlights
backgroundColorstringModal background color
textColorstringPrimary text color
borderRadiusnumberBorder radius in pixels for UI elements
fontFamilystringCSS font family string
logoUrlstringURL to your logo displayed in the modal header
colorScheme'dark' | 'light' | 'system'Color scheme preference
customCssstringAdditional CSS injected into the modal

Fraud Detection

The SDK includes a built-in fraud engine that evaluates payments before processing:
const pos = new MyazaPOS({
  merchantId: 'your-merchant-id',
  fraud: {
    blockedAddresses: ['0xknown-bad-address'],
    maxAmountUsd: 10000,
    velocityLimitPerHour: 5,
    blockThreshold: 80,
    reviewThreshold: 50,
    customChecks: [
      async (ctx) => {
        if (ctx.amount > 5000 && !ctx.deviceFingerprint) {
          return {
            type: 'custom',
            description: 'High-value payment without device fingerprint',
            severity: 60,
          };
        }
        return null;
      },
    ],
  },
});

FraudConfig

PropertyTypeDescription
blockedAddressesstring[]Wallet addresses to block outright
maxAmountUsdnumberMaximum payment amount in USD
velocityLimitPerHournumberMax payments per hour before flagging
blockThresholdnumberFraud score (0-100) that triggers automatic blocking
reviewThresholdnumberFraud score that triggers manual review
customChecksFraudCheckFn[]Custom check functions returning FraudSignal or null

Fraud Signals

When a fraud check triggers, the SDK emits fraud.review_started and fraud.review_completed events:
pos.on('fraud.review_started', (event) => {
  console.log('Fraud review:', event.signals);
});

pos.on('fraud.review_completed', (event) => {
  console.log(`Score: ${event.score}, Action: ${event.action}`);
  // action: 'allow' | 'block' | 'review'
});
Built-in signal types:
Signal TypeDescription
velocity_exceededToo many payments in a short period
address_blacklistedWallet address is on the block list
amount_anomalyAmount exceeds configured maximum
device_fingerprintSuspicious device characteristics
customFrom your custom check functions

Telemetry

Configure logging and performance tracking:
const pos = new MyazaPOS({
  merchantId: 'your-merchant-id',
  telemetry: {
    logLevel: 'info',
    otelEndpoint: 'https://otel.example.com/v1/traces',
    enablePerformanceTiming: true,
  },
});
PropertyTypeDescription
logLevel'debug' | 'info' | 'warn' | 'error'Minimum log level
otelEndpointstringOpenTelemetry collector endpoint
enablePerformanceTimingbooleanEmit performance.timing events
Subscribe to telemetry events:
pos.on('log.emit', (event) => {
  console.log(`[${event.level}] ${event.message}`, event.context);
});

pos.on('performance.timing', (event) => {
  console.log(`${event.operation}: ${event.durationMs}ms`);
});

pos.on('metrics.emit', (event) => {
  console.log(`Metric: ${event.name} = ${event.value} ${event.unit}`);
});