Files
iyzico/src/utils.ts
Duhan BALCI c65195d26d init
2026-01-01 18:30:21 +03:00

29 lines
774 B
TypeScript

/**
* Utility functions
*/
/**
* Generates a random number between min and max (inclusive)
* @param min - Minimum value (default: 0)
* @param max - Maximum value (default: 100)
* @returns Random number between min and max
*/
export function generateRandomNumber(min: number = 0, max: number = 100): number {
if (min > max) {
throw new Error('Min value cannot be greater than max value');
}
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/**
* Generates a random key for İyzico API requests
* Uses timestamp + random number combination
* @returns Random key string
*/
export function generateRandomKey(): string {
const timestamp = Date.now();
const random = generateRandomNumber(100000, 999999);
return `${timestamp}${random}`;
}