uz-pay-sdk
Version:
🚀 Universal Payment SDK for Uzbekistan - Integrate Payme, Click, UzCard, Humo & Apelsin with one simple API. Battle-tested, production-ready, 95% faster integration.
121 lines • 4.58 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnalyticsService = void 0;
const common_1 = require("@nestjs/common");
const logger_config_1 = require("../logger/logger.config");
let AnalyticsService = class AnalyticsService {
// Payment statistics
async getPaymentStatistics(period = 'day') {
// Real implementation would query database
return {
totalTransactions: 1250,
totalAmount: 45600000, // in tiyin
successRate: 98.5,
topProviders: [
{ provider: 'payme', count: 520, percentage: 41.6 },
{ provider: 'click', count: 380, percentage: 30.4 },
{ provider: 'uzcard', count: 200, percentage: 16.0 },
{ provider: 'humo', count: 100, percentage: 8.0 },
{ provider: 'apelsin', count: 50, percentage: 4.0 },
],
failureReasons: [
{ reason: 'insufficient_funds', count: 15 },
{ reason: 'invalid_card', count: 3 },
{ reason: 'network_error', count: 1 },
],
averageProcessingTime: {
payme: 2.5, // seconds
click: 3.2,
uzcard: 1.8,
humo: 2.1,
apelsin: 2.9,
},
revenueByProvider: {
payme: 18720000,
click: 13680000,
uzcard: 7200000,
humo: 3600000,
apelsin: 1800000,
},
timeDistribution: {
'00-06': 45, // night
'06-12': 320, // morning
'12-18': 580, // afternoon
'18-24': 305, // evening
},
};
}
// Real-time metrics
async getRealTimeMetrics() {
return {
activeTransactions: 23,
transactionsPerMinute: 8.5,
systemStatus: 'healthy',
providerStatus: {
payme: 'online',
click: 'online',
uzcard: 'maintenance',
humo: 'online',
apelsin: 'online',
},
currentLoad: {
cpu: 45, // percentage
memory: 62,
requests: 156, // per minute
},
};
}
// Fraud detection metrics
async getFraudMetrics() {
return {
suspiciousTransactions: 3,
blockedTransactions: 1,
riskScore: 'low',
commonFraudPatterns: [
'rapid_multiple_attempts',
'unusual_amounts',
'foreign_ip_addresses',
],
preventedLoss: 250000, // in tiyin
};
}
// Customer behavior analytics
async getCustomerAnalytics() {
return {
newCustomers: 45,
returningCustomers: 203,
customerLifetimeValue: 450000, // average in tiyin
popularPaymentTimes: [
{ hour: 14, transactions: 89 },
{ hour: 20, transactions: 76 },
{ hour: 12, transactions: 68 },
],
deviceDistribution: {
mobile: 65, // percentage
desktop: 30,
tablet: 5,
},
};
}
// Export data for external analytics tools
async exportAnalyticsData(format, dateRange) {
logger_config_1.logger.info('Analytics data export requested', { format, dateRange });
// Would generate and return export file
return {
filename: `uz-pay-analytics-${Date.now()}.${format}`,
url: `/exports/analytics-${Date.now()}.${format}`,
expiresAt: new Date(Date.now() + 3600000), // 1 hour
};
}
};
exports.AnalyticsService = AnalyticsService;
exports.AnalyticsService = AnalyticsService = __decorate([
(0, common_1.Injectable)()
], AnalyticsService);
//# sourceMappingURL=analytics.service.js.map