Prerequisites
A Myaza merchant account — sign up here
Your Merchant ID from the dashboard
Node.js >= 18.0.0
1. Install the SDK
npm install @myazahq/pos-sdk
2. Initialize and Checkout
import { MyazaPOS } from '@myazahq/pos-sdk' ;
// Create an instance
const pos = new MyazaPOS ({
merchantId: 'your-merchant-id' ,
isSandbox: true , // use false for production
});
// Initialize — fetches your merchant profile
await pos . init ();
// Listen for payment events
pos . on ( 'payment.confirmed' , ( event ) => {
console . log ( 'Payment complete!' , event . session . id );
// Verify on your server, then fulfill the order
});
pos . on ( 'payment.failed' , ( event ) => {
console . log ( 'Payment failed:' , event . reason );
});
pos . on ( 'payment.cancelled' , ( event ) => {
console . log ( 'Customer cancelled payment' );
});
// Open the checkout modal
await pos . checkout ({
amount: 25.00 ,
currency: 'USD' ,
});
That’s the entire integration. The SDK handles network selection, QR code display, and payment polling automatically.
3. Checkout with Bank Payout
If your merchant needs fiat settlement to a bank account, resolve the account first:
// Fetch available banks
const banks = await pos . getBanks ( 'NGN' );
console . log ( banks );
// [{ id: '...', name: 'First Bank', networkId: 'first-bank-ng', ... }]
// Verify the account holder
const account = await pos . resolveAccount ( 'first-bank-ng' , '0123456789' );
console . log ( account . accountName ); // "John Doe"
// Open checkout with payout details
await pos . checkout ({
amount: 5000 ,
currency: 'NGN' ,
payoutAccountNumber: '0123456789' ,
payoutNetworkId: 'first-bank-ng' ,
});
4. Low-Level Session (Advanced)
If you need full control over chain and token selection (skipping the modal), use createSession() directly:
// Fetch supported networks
const networks = await pos . getNetworks ();
// [{ chain: 'polygon', name: 'Polygon', supportedTokens: [{ symbol: 'USDC', ... }] }]
// Get the exchange rate
const rate = await pos . getExchangeRate ( 'USD' , 'USDC' );
console . log ( `1 USDC = ${ rate . rate } USD` );
// Create a session with a specific chain and token
const session = await pos . createSession ({
amount: 25.00 ,
chain: 'polygon' ,
token: 'USDC' ,
});
// The SDK starts polling automatically
// Listen for events as usual
5. Clean Up
When the user navigates away or your component unmounts, terminate the SDK:
What Happens During Checkout
When you call pos.checkout():
The SDK fetches supported networks and tokens
A modal opens for the customer to select their preferred chain and token
The SDK creates a payment session and displays:
The deposit wallet address
A QR code for mobile wallets
A live countdown timer
It polls the session status every few seconds
Events fire as the payment progresses:
payment.created — session opened
payment.received — crypto received, payout processing
payment.confirmed — payout complete, safe to fulfill
payment.expired — session timed out
payment.cancelled — customer closed the modal
Always verify payment status from your backend before fulfilling an order.
Client-side events should trigger server-side verification, not direct fulfillment.
Next Steps
Configuration Theming, fraud detection, and advanced options
Framework Guides React, Next.js, Vue, and Svelte integration