@zerohash-sdk/fiat-deposits-js
v1.3.1
Published
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Deposits product.
Downloads
1,070
Readme
@zerohash-sdk/fiat-deposits-js
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Deposits product.
Connect Fiat Deposits provides a secure, customizable flow for depositing fiat currency directly within your application.
Installation
Via NPM (recommended)
npm install @zerohash-sdk/fiat-deposits-jsimport { FiatDeposits } from '@zerohash-sdk/fiat-deposits-js';Via CDN
<script
type="module"
src="https://sdk.connect.xyz/fiat-deposits-web/index.js"
></script>Or import directly in your JavaScript code:
import { FiatDeposits } from 'https://sdk.connect.xyz/fiat-deposits-web/index.js';Getting Started
1. Import the FiatDeposits module
import { FiatDeposits } from '@zerohash-sdk/fiat-deposits-js';2. Initialize and render the widget
const fiatDeposits = new FiatDeposits({
jwt: 'your-jwt-token',
env: 'prod',
theme: 'auto',
onCompleted: ({ amountDeposited, assetSymbol }) => {
console.log('Deposit completed:', amountDeposited, 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 fiatDeposits.render(document.getElementById('fiat-deposits-container'));
fiatDeposits.destroy();2.1 Using TypeScript (optional)
import { FiatDeposits, FiatDepositsConfig } from '@zerohash-sdk/fiat-deposits-js';
const config: FiatDepositsConfig = {
jwt: 'your-jwt-token',
env: 'cert',
onCompleted: ({ amountDeposited, assetSymbol }) => {
console.log(amountDeposited, assetSymbol);
},
};
const fiatDeposits = new FiatDeposits(config);
await fiatDeposits.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 | ({ amountDeposited, assetSymbol }) => void | No | - | Callback when the deposit 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<FiatDepositsConfig>): void
destroy(): void
isRendered(): boolean
getConfig(): FiatDepositsConfig
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.
