Beautiful UI widget for Kashybee voucher payments - React, Vue, and Vanilla JS
npm install @kashybee/ui-widget
π¨ Beautiful, framework-agnostic UI widget for Kashybee voucher payments
Features β’
Installation β’
Quick Start β’
Frameworks β’
Configuration β’
Theming
---
| Feature | Description |
| ------------------------- | ---------------------------------------------------------------- |
| π¨ Beautiful Design | Premium, modern UI matching Kashybee's brand identity |
| π Framework Agnostic | First-class support for React, Vue 3, and Vanilla JS |
| π― Zero CSS Config | Styles are automatically injectedβno manual imports needed |
| π± Mobile Responsive | Optimized modal experience on all screen sizes |
| π³ Dual Flows | Separate "Add Funds" and "Withdraw" modal experiences |
| ποΈ Fully Customizable | Theme support for colors, fonts, and more |
| π Secure | All transactions go through your secure backend |
| π¦ Lightweight | Minimal bundle size with no heavy dependencies |
---
``bashnpm
npm install @kashybee/ui-widget
---
π Quick Start
$3
`jsx
import {
KashybeeAddFundsButton,
KashybeeWithdrawButton,
} from "@kashybee/ui-widget/react";function App() {
return (
addFundsUrl="https://api.yoursite.com/kashybee/add-funds"
withdrawFundsUrl="https://api.yoursite.com/kashybee/withdraw-funds"
userId="user-123"
walletCurrency="USD"
country="US"
onSuccess={(response) => console.log("β
Success:", response)}
onError={(error) => console.error("β Error:", error)}
/> addFundsUrl="https://api.yoursite.com/kashybee/add-funds"
withdrawFundsUrl="https://api.yoursite.com/kashybee/withdraw-funds"
userId="user-123"
walletCurrency="USD"
country="US"
onSuccess={(response) => console.log("β
Success:", response)}
onError={(error) => console.error("β Error:", error)}
/>
);
}export default App;
`$3
`vue
`$3
`javascript
import { createKashybeeWidget } from "@kashybee/ui-widget";const widget = createKashybeeWidget({
addFundsUrl: "/api/add-funds",
withdrawFundsUrl: "/api/withdraw-funds",
userId: "user-123",
walletCurrency: "USD",
country: "US",
onSuccess: (response) => console.log("β
Success:", response),
onError: (error) => console.error("β Error:", error),
});
// Create separate Add Funds and Withdraw buttons
const container = document.getElementById("kashybee-container");
const addBtn = widget.createButton("Add Funds", "add");
const withdrawBtn = widget.createButton("Withdraw Funds", "withdraw");
container.appendChild(addBtn);
container.appendChild(withdrawBtn);
`$3
`html
Kashybee Widget Demo
`$3
For environments that don't support ES modules, use the UMD build:
`html
Kashybee Widget Demo
`---
πΌοΈ Frameworks
$3
The React package exports specialized components and a hook for custom implementations:
#### Components
| Component | Description |
| ------------------------ | -------------------------------------------- |
|
KashybeeAddFundsButton | Pre-configured button for adding funds |
| KashybeeWithdrawButton | Pre-configured button for withdrawing funds |
| KashybeeButton | Generic button with configurable mode prop |#### Hook:
useKashybeeWidgetFor complete control, use the hook to build custom UI:
`jsx
import { useKashybeeWidget } from "@kashybee/ui-widget/react";function CustomPaymentUI() {
const { open, close } = useKashybeeWidget({
addFundsUrl: "/api/add-funds",
withdrawFundsUrl: "/api/withdraw-funds",
userId: "user-123",
onSuccess: (response) => {
console.log("Transaction complete:", response);
},
});
return (
);
}
`#### Custom Children
You can also use your own button design with the component:
`jsx
addFundsUrl="/api/add-funds"
withdrawFundsUrl="/api/withdraw-funds"
userId="user-123"
>
Add Funds with Kashybee
`---
$3
The Vue package exports a single flexible component:
`vue
mode="add"
:add-funds-url="'/api/add-funds'"
:withdraw-funds-url="'/api/withdraw-funds'"
:user-id="'user-123'"
wallet-currency="USD"
button-text="Top Up My Wallet"
@success="onSuccess"
@error="onError"
@open="onModalOpen"
@close="onModalClose"
/> mode="withdraw"
:add-funds-url="'/api/add-funds'"
:withdraw-funds-url="'/api/withdraw-funds'"
:user-id="'user-123'"
wallet-currency="USD"
button-text="Cash Out"
@success="onSuccess"
@error="onError"
@open="onModalOpen"
@close="onModalClose"
/>
`#### Props
| Prop | Type | Default | Description |
| ------------------ | --------------------- | ------- | ------------------------------------------ |
|
mode | 'add' \| 'withdraw' | 'add' | Modal mode to open |
| addFundsUrl | string | β | Your server endpoint for adding funds |
| withdrawFundsUrl | string | β | Your server endpoint for withdrawing funds |
| userId | string | β | User ID for the transaction |
| walletCurrency | string | 'USD' | Default currency code |
| country | string | β | User's country code |
| buttonText | string | Auto | Custom button text |#### Events
| Event | Payload | Description |
| ---------- | --------------------- | ------------------------------- |
|
@success | TransactionResponse | Fired on successful transaction |
| @error | Error | Fired when an error occurs |
| @open | β | Fired when modal opens |
| @close | β | Fired when modal closes |---
$3
Auto-initialize widgets using HTML attributes only:
`html
data-kashybee-widget
data-mode="add"
data-add-funds-url="/api/add-funds"
data-withdraw-funds-url="/api/withdraw-funds"
data-user-id="user-123"
data-wallet-currency="USD"
data-button-text="Add Funds"
>---
βοΈ Configuration
$3
| Option | Type | Required | Default | Description |
| ------------------ | --------------- | :------: | ------- | ------------------------------------------ |
|
addFundsUrl | string | β
| β | Your server endpoint for adding funds |
| withdrawFundsUrl | string | β
| β | Your server endpoint for withdrawing funds |
| userId | string | β
| β | Unique identifier for the user |
| walletCurrency | string | β | "USD" | Default currency code |
| country | string | β | β | User's country code (e.g., "US", "BD") |
| headers | object | β | β | Custom headers for API requests |
| theme | KashybeeTheme | β | β | Theme customization options |
| onSuccess | function | β | β | Callback on successful transaction |
| onError | function | β | β | Callback on error |
| onOpen | function | β | β | Callback when modal opens |
| onClose | function | β | β | Callback when modal closes |
| editableFields | object | β | β | Configure which fields are editable |---
π¨ Theming
Customize the widget's appearance with the
theme option:`javascript
const widget = createKashybeeWidget({
// ... other config
theme: {
primaryColor: "#00D9FF",
primaryHoverColor: "#00B8D9",
textColor: "#1A1A2E",
backgroundColor: "#FFFFFF",
borderRadius: "12px",
fontFamily: "Inter, system-ui, sans-serif",
},
});
`$3
| Property | Type | Default | Description |
| ------------------- | -------- | ----------- | -------------------------- |
|
primaryColor | string | #00D9FF | Primary brand color |
| primaryHoverColor | string | #00B8D9 | Hover state color |
| textColor | string | #1A1A2E | Main text color |
| backgroundColor | string | #FFFFFF | Modal background color |
| borderRadius | string | 12px | Border radius for elements |
| fontFamily | string | System font | Font family for text |---
π Server Integration
The widget communicates with your backend, which then uses the
@kashybee/node-sdk to securely interact with the Kashybee API.$3
`
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Your Client ββββββΆβ Your Server ββββββΆβ Kashybee API β
β (UI Widget) βββββββ (Node SDK) βββββββ β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
`$3
Your endpoint receives:
`json
{
"voucherCode": "ABC123XYZ",
"amount": 100,
"userId": "user-123",
"walletCurrency": "USD",
"country": "US"
}
`$3
Your endpoint receives:
`json
{
"email": "user@example.com",
"amount": 50,
"userId": "user-123",
"walletCurrency": "USD",
"country": "US"
}
`$3
`javascript
const express = require("express");
const { KashybeeClient } = require("@kashybee/node-sdk");const app = express();
app.use(express.json());
const kashybee = new KashybeeClient({
apiKey: process.env.KASHYBEE_API_KEY,
hmacSecret: process.env.KASHYBEE_HMAC_SECRET,
isSandbox: true,
});
app.post("/api/add-funds", async (req, res) => {
const result = await kashybee.addFunds(req.body);
res.json(result);
});
app.post("/api/withdraw-funds", async (req, res) => {
const result = await kashybee.withdrawFunds(req.body);
res.json(result);
});
app.listen(3000);
`@kashybee/node-sdk---
π TypeScript Support
This package is written in TypeScript and ships with full type declarations.
`typescript
import type {
KashybeeWidgetConfig,
KashybeeTheme,
ModalMode,
TransactionResponse,
AddFundsPayload,
WithdrawFundsPayload,
} from "@kashybee/ui-widget";
``---
| Browser | Supported |
| ------- | :-------: |
| Chrome | β
|
| Firefox | β
|
| Safari | β
|
| Edge | β
|
| IE 11 | β |
---
MIT Β© Kashybee
---
Built with β€οΈ by the Kashybee Team
Website β’
Documentation β’
GitHub