@doctech/fib
Version:
First Iraqi Bank payment integration for DocTech
130 lines (99 loc) • 2.46 kB
Markdown


A modern TypeScript/Node.js client for First Iraqi Bank payment integration.
- ✅ Create payment requests
- ✅ Check payment status
- ✅ Cancel payments
- ✅ TypeScript type definitions
- ✅ Modern Promise-based API
```bash
npm install @doctech/fib
yarn add @doctech/fib
pnpm add @doctech/fib
```
```typescript
import { FIBClient } from "@doctech/fib";
// Initialize client
const client = new FIBClient({
clientId: "your_client_id",
clientSecret: "your_client_secret",
baseUrl: "https://api.fib.iq", // or your specific endpoint
});
// Create a payment
const payment = await client.createPayment({
monetaryValue: {
amount: "50000",
currency: "IQD",
},
description: "Payment for order #1234",
category: "ECOMMERCE",
});
console.log("Payment created:", payment);
console.log("QR Code:", payment.qrCode);
console.log("App Link:", payment.personalAppLink);
// Check payment status
const status = await client.getPaymentStatus(payment.paymentId);
console.log("Payment status:", status.status);
// Cancel a payment (if needed)
await client.cancelPayment(payment.paymentId);
```
```typescript
interface FIBConfig {
clientId: string; // Your FIB client ID
clientSecret: string; // Your FIB client secret
baseUrl: string; // FIB API base URL
}
```
Creates a new payment request.
```typescript
interface CreatePaymentOptions {
monetaryValue: {
amount: string;
currency: "IQD";
};
statusCallbackUrl?: string;
description?: string;
expiresIn?: string;
refundableFor?: string;
category?: PaymentCategory;
}
// Available payment categories
type PaymentCategory =
| "ERP"
| "POS"
| "ECOMMERCE"
| "UTILITY"
| "PAYROLL"
| "SUPPLIER"
| "LOAN"
| "GOVERNMENT"
| "MISCELLANEOUS"
| "OTHER";
```
Retrieves the current status of a payment.
Cancels an existing payment.
The client throws errors for various failure scenarios:
```typescript
try {
const payment = await client.createPayment({
/* ... */
});
} catch (error) {
console.error("Failed to create payment:", error);
}
```
MIT © [Yad Hersh](https://github.com/YadaCoder)