@zerohash-sdk/fiat-withdrawals-js
v1.3.1
Published
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Withdrawals product.
Readme
@zerohash-sdk/fiat-withdrawals-js
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Withdrawals product.
Connect Fiat Withdrawals provides a secure, customizable flow for withdrawing fiat currency directly within your application.
Installation
Via NPM (recommended)
npm install @zerohash-sdk/fiat-withdrawals-jsimport { FiatWithdrawals } from '@zerohash-sdk/fiat-withdrawals-js';Via CDN
<script
type="module"
src="https://sdk.connect.xyz/fiat-withdrawals-web/index.js"
></script>Or import directly in your JavaScript code:
import { FiatWithdrawals } from 'https://sdk.connect.xyz/fiat-withdrawals-web/index.js';Getting Started
1. Import the FiatWithdrawals module
import { FiatWithdrawals } from '@zerohash-sdk/fiat-withdrawals-js';2. Initialize and render the widget
const fiatWithdrawals = new FiatWithdrawals({
jwt: 'your-jwt-token',
env: 'prod',
theme: 'auto',
onCompleted: ({ amountWithdrawn, assetSymbol }) => {
console.log('Withdrawal completed:', amountWithdrawn, assetSymbol);
},
onError: ({ errorCode, reason }) => {
console.error('Error:', errorCode, 'Reason:', reason);
},
onClose: () => console.log('Widget closed'),
onEvent: ({ type, data }) => console.log('Event:', type, data),
onLoaded: () => console.log('Widget loaded and ready'),
});
await fiatWithdrawals.render(document.getElementById('fiat-withdrawals-container'));
fiatWithdrawals.destroy();2.1 Using TypeScript (optional)
import { FiatWithdrawals, FiatWithdrawalsConfig } from '@zerohash-sdk/fiat-withdrawals-js';
const config: FiatWithdrawalsConfig = {
jwt: 'your-jwt-token',
env: 'cert',
onCompleted: ({ amountWithdrawn, assetSymbol }) => {
console.log(amountWithdrawn, assetSymbol);
},
};
const fiatWithdrawals = new FiatWithdrawals(config);
await fiatWithdrawals.render(document.getElementById('container')!);API Reference
Configuration
| Prop | Type | Required | Default | Description |
| ------------- | -------------------------------------------- | -------- | -------- | -------------------------------------------------------- |
| jwt | string | Yes | - | JWT token for authentication with Connect |
| env | "prod" \| "cert" \| "dev" \| "local" | No | "prod" | Target environment |
| theme | "auto" \| "light" \| "dark" | No | "auto" | Theme mode for the interface |
| onCompleted | ({ amountWithdrawn, assetSymbol }) => void | No | - | Callback when the withdrawal flow completes successfully |
| onError | ({ errorCode, reason }) => void | No | - | Callback for error events |
| onClose | () => void | No | - | Callback when the widget is closed |
| onEvent | ({ type, data }) => void | No | - | Callback for general events |
| onLoaded | () => void | No | - | Callback when the widget is loaded and ready |
Methods
render(container: HTMLElement): Promise<void>
updateConfig(config: Partial<FiatWithdrawalsConfig>): void
destroy(): void
isRendered(): boolean
getConfig(): FiatWithdrawalsConfig
Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- All modern browsers with Web Components support
More Information & Support
For comprehensive documentation or support about Connect, visit our Documentation Page.
