@flixora/airxpay-sdk-init-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +623 -0
  3. package/dist/api/client.d.ts +2 -0
  4. package/dist/api/client.js +78 -0
  5. package/dist/api/merchantProxy.d.ts +11 -0
  6. package/dist/api/merchantProxy.js +170 -0
  7. package/dist/assets/images/airxpay.png +0 -0
  8. package/dist/assets/images/flixora.png +0 -0
  9. package/dist/components/common/CountryDropdown.d.ts +17 -0
  10. package/dist/components/common/CountryDropdown.js +138 -0
  11. package/dist/components/common/FileUploader.d.ts +16 -0
  12. package/dist/components/common/FileUploader.js +219 -0
  13. package/dist/components/common/StepIndicator.d.ts +11 -0
  14. package/dist/components/common/StepIndicator.js +269 -0
  15. package/dist/components/steps/BankDetails.d.ts +10 -0
  16. package/dist/components/steps/BankDetails.js +630 -0
  17. package/dist/components/steps/BasicDetailsForm.d.ts +10 -0
  18. package/dist/components/steps/BasicDetailsForm.js +569 -0
  19. package/dist/components/steps/KYCVerification.d.ts +11 -0
  20. package/dist/components/steps/KYCVerification.js +867 -0
  21. package/dist/components/steps/OnboardingComplete.d.ts +8 -0
  22. package/dist/components/steps/OnboardingComplete.js +566 -0
  23. package/dist/components/steps/onboarding/FinalStepScreen.d.ts +10 -0
  24. package/dist/components/steps/onboarding/FinalStepScreen.js +455 -0
  25. package/dist/components/steps/onboarding/MerchantOnboarding.d.ts +4 -0
  26. package/dist/components/steps/onboarding/MerchantOnboarding.js +678 -0
  27. package/dist/contexts/AirXPayProvider.d.ts +21 -0
  28. package/dist/contexts/AirXPayProvider.js +116 -0
  29. package/dist/error/errorHandler.d.ts +10 -0
  30. package/dist/error/errorHandler.js +87 -0
  31. package/dist/etc/constants.d.ts +37 -0
  32. package/dist/etc/constants.js +41 -0
  33. package/dist/hooks/useAirXPaySheet.d.ts +3 -0
  34. package/dist/hooks/useAirXPaySheet.js +20 -0
  35. package/dist/hooks/useMerchantOnboarding.d.ts +15 -0
  36. package/dist/hooks/useMerchantOnboarding.js +108 -0
  37. package/dist/index.d.ts +13 -0
  38. package/dist/index.js +41 -0
  39. package/dist/options/configOptions.d.ts +28 -0
  40. package/dist/options/configOptions.js +56 -0
  41. package/dist/plugins/tokenRefreshPlugin.d.ts +10 -0
  42. package/dist/plugins/tokenRefreshPlugin.js +91 -0
  43. package/dist/schema/validators.d.ts +9 -0
  44. package/dist/schema/validators.js +57 -0
  45. package/dist/sdk/airxpay.d.ts +9 -0
  46. package/dist/sdk/airxpay.js +26 -0
  47. package/dist/services/apiService.d.ts +34 -0
  48. package/dist/services/apiService.js +133 -0
  49. package/dist/types/dev.d.ts +1 -0
  50. package/dist/types/dev.js +4 -0
  51. package/dist/types/dev.ts +2 -0
  52. package/dist/types/merchantTypes.d.ts +111 -0
  53. package/dist/types/merchantTypes.js +2 -0
  54. package/dist/types/merchantTypes.ts +116 -0
  55. package/dist/types/type.d.ts +8 -0
  56. package/dist/types/type.js +3 -0
  57. package/dist/types/type.ts +11 -0
  58. package/dist/utils/jwt.d.ts +10 -0
  59. package/dist/utils/jwt.js +28 -0
  60. package/dist/utils/tokenStorage.d.ts +5 -0
  61. package/dist/utils/tokenStorage.js +69 -0
  62. package/package.json +52 -0
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ // src/plugins/tokenRefreshPlugin.ts
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.TokenRefreshPlugin = void 0;
14
+ const tokenStorage_1 = require("../utils/tokenStorage");
15
+ const merchantProxy_1 = require("../api/merchantProxy");
16
+ class TokenRefreshPlugin {
17
+ static getValidToken() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const token = yield (0, tokenStorage_1.getStoredToken)();
20
+ if (!token) {
21
+ return null;
22
+ }
23
+ // Check if token is expired (simplified - in production use JWT decode)
24
+ const isExpired = this.isTokenExpired(token);
25
+ if (!isExpired) {
26
+ return token;
27
+ }
28
+ // Token expired, refresh it
29
+ return this.refreshToken();
30
+ });
31
+ }
32
+ static refreshToken() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ // If already refreshing, return the existing promise
35
+ if (this.refreshPromise) {
36
+ return this.refreshPromise;
37
+ }
38
+ this.refreshPromise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ const response = yield (0, merchantProxy_1.refreshMerchantTokenInternal)();
41
+ if (response === null || response === void 0 ? void 0 : response.token) {
42
+ yield (0, tokenStorage_1.setStoredToken)(response.token);
43
+ this.processQueue(null, response.token);
44
+ resolve(response.token);
45
+ }
46
+ else {
47
+ throw new Error('No token in refresh response');
48
+ }
49
+ }
50
+ catch (error) {
51
+ yield (0, tokenStorage_1.clearStoredToken)();
52
+ this.processQueue(error, null);
53
+ reject(error);
54
+ }
55
+ finally {
56
+ this.isRefreshing = false;
57
+ this.refreshPromise = null;
58
+ }
59
+ }));
60
+ return this.refreshPromise;
61
+ });
62
+ }
63
+ static processQueue(error, token = null) {
64
+ this.failedQueue.forEach(promise => {
65
+ if (error) {
66
+ promise.reject(error);
67
+ }
68
+ else {
69
+ promise.resolve(token);
70
+ }
71
+ });
72
+ this.failedQueue = [];
73
+ }
74
+ static isTokenExpired(token) {
75
+ try {
76
+ const payload = JSON.parse(atob(token.split('.')[1]));
77
+ const exp = payload.exp * 1000; // Convert to milliseconds
78
+ return Date.now() >= exp - 60000; // Consider expired 1 minute before actual expiry
79
+ }
80
+ catch (_a) {
81
+ return true; // If can't decode, consider expired
82
+ }
83
+ }
84
+ static addToQueue(resolve, reject) {
85
+ this.failedQueue.push({ resolve, reject });
86
+ }
87
+ }
88
+ exports.TokenRefreshPlugin = TokenRefreshPlugin;
89
+ TokenRefreshPlugin.isRefreshing = false;
90
+ TokenRefreshPlugin.failedQueue = [];
91
+ TokenRefreshPlugin.refreshPromise = null;
@@ -0,0 +1,9 @@
1
+ import { CreateMerchantPayload } from '../types/merchantTypes';
2
+ export interface ValidationError {
3
+ field: string;
4
+ message: string;
5
+ }
6
+ export declare class PayloadValidator {
7
+ static validateCreateMerchant(payload: CreateMerchantPayload): ValidationError[];
8
+ static validatePublicKey(publicKey: string): ValidationError[];
9
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ // src/schema/validators.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PayloadValidator = void 0;
5
+ class PayloadValidator {
6
+ static validateCreateMerchant(payload) {
7
+ var _a, _b, _c;
8
+ const errors = [];
9
+ // Merchant Name validation
10
+ if (!((_a = payload.merchantName) === null || _a === void 0 ? void 0 : _a.trim())) {
11
+ errors.push({ field: 'merchantName', message: 'Merchant name is required' });
12
+ }
13
+ else if (payload.merchantName.length < 2) {
14
+ errors.push({ field: 'merchantName', message: 'Name must be at least 2 characters' });
15
+ }
16
+ else if (payload.merchantName.length > 100) {
17
+ errors.push({ field: 'merchantName', message: 'Name must be less than 100 characters' });
18
+ }
19
+ // Email validation
20
+ if (!((_b = payload.merchantEmail) === null || _b === void 0 ? void 0 : _b.trim())) {
21
+ errors.push({ field: 'merchantEmail', message: 'Email is required' });
22
+ }
23
+ else {
24
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
25
+ if (!emailRegex.test(payload.merchantEmail)) {
26
+ errors.push({ field: 'merchantEmail', message: 'Invalid email format' });
27
+ }
28
+ }
29
+ // Phone validation (optional)
30
+ if (payload.merchantPhone) {
31
+ const phoneRegex = /^\+?[1-9]\d{1,14}$/;
32
+ if (!phoneRegex.test(payload.merchantPhone.replace(/[\s-]/g, ''))) {
33
+ errors.push({ field: 'merchantPhone', message: 'Invalid phone number format' });
34
+ }
35
+ }
36
+ // Business type validation
37
+ if (payload.businessType && !['individual', 'company'].includes(payload.businessType)) {
38
+ errors.push({ field: 'businessType', message: 'Invalid business type' });
39
+ }
40
+ // Business name required for companies
41
+ if (payload.businessType === 'company' && !((_c = payload.businessName) === null || _c === void 0 ? void 0 : _c.trim())) {
42
+ errors.push({ field: 'businessName', message: 'Business name is required for companies' });
43
+ }
44
+ return errors;
45
+ }
46
+ static validatePublicKey(publicKey) {
47
+ const errors = [];
48
+ if (!(publicKey === null || publicKey === void 0 ? void 0 : publicKey.trim())) {
49
+ errors.push({ field: 'publicKey', message: 'Public key is required' });
50
+ }
51
+ else if (publicKey.length < 16) {
52
+ errors.push({ field: 'publicKey', message: 'Invalid public key format' });
53
+ }
54
+ return errors;
55
+ }
56
+ }
57
+ exports.PayloadValidator = PayloadValidator;
@@ -0,0 +1,9 @@
1
+ import { AirXPayConfig } from '../types/type';
2
+ export declare class useIsAirXPayReady {
3
+ private publicKey;
4
+ constructor(config: AirXPayConfig);
5
+ initialize(): Promise<{
6
+ valid: boolean;
7
+ merchantData?: any;
8
+ }>;
9
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useIsAirXPayReady = void 0;
13
+ const merchantProxy_1 = require("../api/merchantProxy");
14
+ class useIsAirXPayReady {
15
+ constructor(config) {
16
+ if (!config.publicKey)
17
+ throw new Error("Public key is required");
18
+ this.publicKey = config.publicKey;
19
+ }
20
+ initialize() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ return yield (0, merchantProxy_1.verifyPublicKey)(this.publicKey);
23
+ });
24
+ }
25
+ }
26
+ exports.useIsAirXPayReady = useIsAirXPayReady;
@@ -0,0 +1,34 @@
1
+ import { CreateMerchantPayload, MerchantCreateResponse, MerchantStatusResponse } from '../types/merchantTypes';
2
+ declare class AirXPayService {
3
+ private initialized;
4
+ /**
5
+ * Initialize the SDK with public key
6
+ */
7
+ initialize(publicKey: string): Promise<void>;
8
+ /**
9
+ * Check if SDK is initialized
10
+ */
11
+ isInitialized(): boolean;
12
+ /**
13
+ * Create merchant (called on final step)
14
+ */
15
+ createMerchant(payload: CreateMerchantPayload): Promise<MerchantCreateResponse>;
16
+ /**
17
+ * Get merchant status (used in onboarding complete screen)
18
+ */
19
+ getMerchantStatus(): Promise<MerchantStatusResponse>;
20
+ /**
21
+ * Refresh merchant token
22
+ */
23
+ refreshToken(): Promise<void>;
24
+ /**
25
+ * Check if SDK is initialized
26
+ */
27
+ private checkInitialized;
28
+ /**
29
+ * Handle and normalize errors
30
+ */
31
+ private handleError;
32
+ }
33
+ export declare const airxpayService: AirXPayService;
34
+ export {};
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.airxpayService = void 0;
16
+ // services/airxpay.service.ts
17
+ const merchantProxy_1 = require("../api/merchantProxy");
18
+ const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
19
+ const PUBLIC_KEY_STORAGE = '@airxpay_public_key';
20
+ class AirXPayService {
21
+ constructor() {
22
+ this.initialized = false;
23
+ }
24
+ /**
25
+ * Initialize the SDK with public key
26
+ */
27
+ initialize(publicKey) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ if (!(publicKey === null || publicKey === void 0 ? void 0 : publicKey.trim())) {
31
+ throw new Error('Public key is required');
32
+ }
33
+ (0, merchantProxy_1.initializeInternalApi)(publicKey);
34
+ yield async_storage_1.default.setItem(PUBLIC_KEY_STORAGE, publicKey);
35
+ this.initialized = true;
36
+ console.log('✅ AirXPay SDK initialized successfully');
37
+ }
38
+ catch (error) {
39
+ console.error('❌ Failed to initialize AirXPay SDK:', error);
40
+ throw error;
41
+ }
42
+ });
43
+ }
44
+ /**
45
+ * Check if SDK is initialized
46
+ */
47
+ isInitialized() {
48
+ return this.initialized;
49
+ }
50
+ /**
51
+ * Create merchant (called on final step)
52
+ */
53
+ createMerchant(payload) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ this.checkInitialized();
56
+ try {
57
+ console.log('📝 Creating merchant with payload:', Object.assign(Object.assign({}, payload), { merchantEmail: payload.merchantEmail }));
58
+ const response = yield (0, merchantProxy_1.createMerchantInternal)(payload);
59
+ // Token is automatically stored by the SDK
60
+ console.log('✅ Merchant created successfully:', response.merchant.merchantId);
61
+ return response;
62
+ }
63
+ catch (error) {
64
+ console.error('❌ Failed to create merchant:', error.message);
65
+ throw this.handleError(error);
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Get merchant status (used in onboarding complete screen)
71
+ */
72
+ getMerchantStatus() {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ this.checkInitialized();
75
+ try {
76
+ console.log('🔍 Fetching merchant status...');
77
+ const response = yield (0, merchantProxy_1.getMerchantStatusInternal)();
78
+ console.log('✅ Merchant status retrieved:', response.status);
79
+ return response;
80
+ }
81
+ catch (error) {
82
+ console.error('❌ Failed to get merchant status:', error.message);
83
+ throw this.handleError(error);
84
+ }
85
+ });
86
+ }
87
+ /**
88
+ * Refresh merchant token
89
+ */
90
+ refreshToken() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ this.checkInitialized();
93
+ try {
94
+ console.log('🔄 Refreshing merchant token...');
95
+ yield (0, merchantProxy_1.refreshMerchantTokenInternal)();
96
+ console.log('✅ Token refreshed successfully');
97
+ }
98
+ catch (error) {
99
+ console.error('❌ Failed to refresh token:', error.message);
100
+ throw this.handleError(error);
101
+ }
102
+ });
103
+ }
104
+ /**
105
+ * Check if SDK is initialized
106
+ */
107
+ checkInitialized() {
108
+ if (!this.initialized) {
109
+ throw new Error('AirXPay SDK not initialized. Call initialize() first.');
110
+ }
111
+ }
112
+ /**
113
+ * Handle and normalize errors
114
+ */
115
+ handleError(error) {
116
+ var _a, _b;
117
+ if (error.response) {
118
+ // Server responded with error
119
+ const message = ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) || ((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.error) || 'Server error';
120
+ return new Error(message);
121
+ }
122
+ else if (error.request) {
123
+ // Request was made but no response
124
+ return new Error('Network error. Please check your connection.');
125
+ }
126
+ else {
127
+ // Something else happened
128
+ return error;
129
+ }
130
+ }
131
+ }
132
+ // Singleton instance
133
+ exports.airxpayService = new AirXPayService();
@@ -0,0 +1 @@
1
+ export declare const __DEV__: boolean;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__DEV__ = void 0;
4
+ exports.__DEV__ = process.env.NODE_ENV !== "production";
@@ -0,0 +1,2 @@
1
+ export const __DEV__ =
2
+ process.env.NODE_ENV !== "production";
@@ -0,0 +1,111 @@
1
+ export type BusinessType = "individual" | "company";
2
+ export type Mode = "test" | "live";
3
+ export type MerchantStatus = "active" | "suspended" | "blocked";
4
+ export type KycStatus = "not_submitted" | "pending" | "verified" | "rejected";
5
+ export interface KYCDetails {
6
+ panNumber?: string;
7
+ aadhaarNumber?: string;
8
+ gstNumber?: string;
9
+ registeredBusinessName?: string;
10
+ panCardUrl?: string;
11
+ aadhaarUrl?: string;
12
+ addressProofUrl?: string;
13
+ selfieUrl?: string;
14
+ }
15
+ export interface BankDetails {
16
+ accountHolderName: string;
17
+ bankName: string;
18
+ accountNumber: string;
19
+ ifscCode: string;
20
+ upiId?: string;
21
+ cancelledChequeUrl?: string;
22
+ }
23
+ export interface Merchant {
24
+ _id?: string;
25
+ merchantId: string;
26
+ status: MerchantStatus;
27
+ kycStatus: KycStatus;
28
+ isKycCompleted: boolean;
29
+ isBankDetailsCompleted: boolean;
30
+ mode: Mode;
31
+ merchantDID?: string;
32
+ walletId?: string;
33
+ merchantName: string;
34
+ merchantEmail: string;
35
+ merchantPhone?: string;
36
+ businessName?: string;
37
+ businessType?: BusinessType;
38
+ businessCategory?: string;
39
+ country?: string;
40
+ nationality?: string;
41
+ dob?: string;
42
+ kycDetails?: KYCDetails;
43
+ bankDetails?: BankDetails;
44
+ createdAt?: string;
45
+ updatedAt?: string;
46
+ }
47
+ export interface CreateMerchantPayload {
48
+ merchantName: string;
49
+ merchantEmail: string;
50
+ merchantPhone?: string;
51
+ businessName?: string;
52
+ businessType?: BusinessType;
53
+ businessCategory?: string;
54
+ country?: string;
55
+ dob?: Date;
56
+ nationality?: string;
57
+ mode?: Mode;
58
+ metadata?: Record<string, unknown>;
59
+ }
60
+ export interface MerchantCreateResponse {
61
+ success: boolean;
62
+ token: string;
63
+ merchant: Merchant;
64
+ }
65
+ export interface MerchantOnboardingProps {
66
+ merchantId?: string;
67
+ mode: Mode;
68
+ initialStep?: number;
69
+ isKycCompleted: boolean;
70
+ isBankDetailsCompleted: boolean;
71
+ kycStatus: KycStatus;
72
+ status: MerchantStatus;
73
+ initialData?: Partial<Merchant>;
74
+ onNext: (stepData: Partial<Merchant>, step: number) => void;
75
+ onBack: (currentStep: number) => void;
76
+ onComplete: (merchantData: Merchant) => void;
77
+ loading?: boolean;
78
+ }
79
+ export interface StepConfig {
80
+ id: number;
81
+ name: string;
82
+ key: "basic" | "kyc" | "bank" | "complete" | "final";
83
+ isRequired: boolean;
84
+ }
85
+ export interface FormErrors {
86
+ [key: string]: string | undefined;
87
+ }
88
+ export interface StepCompletion {
89
+ basic: boolean;
90
+ kyc: boolean;
91
+ bank: boolean;
92
+ }
93
+ export interface AirXPayConfig {
94
+ publicKey: string;
95
+ customNavigation?: {
96
+ buttonText: string;
97
+ screenName: string;
98
+ };
99
+ }
100
+ export interface MerchantStatusResponse {
101
+ merchantId: string;
102
+ merchantName: string;
103
+ merchantEmail: string;
104
+ status: 'active' | 'suspended' | 'blocked' | 'pending';
105
+ kycStatus: 'not_submitted' | 'pending' | 'verified' | 'rejected';
106
+ kycCompleted: boolean;
107
+ bankDetailsCompleted: boolean;
108
+ mode: 'test' | 'live';
109
+ createdAt: string;
110
+ updatedAt: string;
111
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,116 @@
1
+ export type BusinessType = "individual" | "company";
2
+ export type Mode = "test" | "live";
3
+ export type MerchantStatus = "active" | "suspended" | "blocked";
4
+ export type KycStatus = "not_submitted" | "pending" | "verified" | "rejected";
5
+
6
+ export interface KYCDetails {
7
+ panNumber?: string;
8
+ aadhaarNumber?: string;
9
+ gstNumber?: string;
10
+ registeredBusinessName?: string;
11
+ panCardUrl?: string;
12
+ aadhaarUrl?: string;
13
+ addressProofUrl?: string;
14
+ selfieUrl?: string;
15
+ }
16
+ export interface BankDetails {
17
+ accountHolderName: string;
18
+ bankName: string;
19
+ accountNumber: string;
20
+ ifscCode: string;
21
+ upiId?: string;
22
+ cancelledChequeUrl?: string;
23
+ }
24
+
25
+ export interface Merchant {
26
+ _id?: string;
27
+ merchantId: string;
28
+ status: MerchantStatus;
29
+ kycStatus: KycStatus;
30
+ isKycCompleted: boolean;
31
+ isBankDetailsCompleted: boolean;
32
+ mode: Mode;
33
+ merchantDID?: string;
34
+ walletId?: string;
35
+ merchantName: string;
36
+ merchantEmail: string;
37
+ merchantPhone?: string;
38
+ businessName?: string;
39
+ businessType?: BusinessType;
40
+ businessCategory?: string;
41
+ country?: string;
42
+ nationality?: string;
43
+ dob?: string;
44
+ kycDetails?: KYCDetails;
45
+ bankDetails?: BankDetails;
46
+ createdAt?: string; // <— added
47
+ updatedAt?: string; // <— added
48
+ }
49
+
50
+ export interface CreateMerchantPayload {
51
+ merchantName: string;
52
+ merchantEmail: string;
53
+ merchantPhone?: string;
54
+ businessName?: string;
55
+ businessType?: BusinessType;
56
+ businessCategory?: string;
57
+ country?: string;
58
+ dob?: Date;
59
+ nationality?: string;
60
+ mode?: Mode;
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+
64
+ export interface MerchantCreateResponse {
65
+ success: boolean;
66
+ token: string;
67
+ merchant: Merchant;
68
+ }
69
+
70
+ export interface MerchantOnboardingProps {
71
+ merchantId?: string;
72
+ mode: Mode;
73
+ initialStep?: number;
74
+ isKycCompleted: boolean;
75
+ isBankDetailsCompleted: boolean;
76
+ kycStatus: KycStatus;
77
+ status: MerchantStatus;
78
+ initialData?: Partial<Merchant>;
79
+ onNext: (stepData: Partial<Merchant>, step: number) => void;
80
+ onBack: (currentStep: number) => void;
81
+ onComplete: (merchantData: Merchant) => void;
82
+ loading?: boolean;
83
+ }
84
+
85
+ export interface StepConfig {
86
+ id: number;
87
+ name: string;
88
+ key: "basic" | "kyc" | "bank" | "complete" | "final";
89
+ isRequired: boolean;
90
+ }
91
+ export interface FormErrors {
92
+ [key: string]: string | undefined;
93
+ }
94
+ export interface StepCompletion {
95
+ basic: boolean;
96
+ kyc: boolean;
97
+ bank: boolean;
98
+ }
99
+
100
+ export interface AirXPayConfig {
101
+ publicKey: string;
102
+ customNavigation?: { buttonText: string; screenName: string };
103
+ }
104
+
105
+ export interface MerchantStatusResponse {
106
+ merchantId: string;
107
+ merchantName: string;
108
+ merchantEmail: string;
109
+ status: 'active' | 'suspended' | 'blocked' | 'pending';
110
+ kycStatus: 'not_submitted' | 'pending' | 'verified' | 'rejected';
111
+ kycCompleted: boolean;
112
+ bankDetailsCompleted: boolean;
113
+ mode: 'test' | 'live';
114
+ createdAt: string;
115
+ updatedAt: string;
116
+ }
@@ -0,0 +1,8 @@
1
+ export interface AirXPayConfig {
2
+ publicKey: string;
3
+ }
4
+ export interface MerchantData {
5
+ merchantName: string;
6
+ merchantEmail: string;
7
+ merchantPhone?: string;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // types/merchantTypes.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ // types/merchantTypes.ts
2
+
3
+ export interface AirXPayConfig {
4
+ publicKey: string;
5
+ }
6
+
7
+ export interface MerchantData {
8
+ merchantName: string;
9
+ merchantEmail: string;
10
+ merchantPhone?: string;
11
+ }
@@ -0,0 +1,10 @@
1
+ export interface JWTPayload {
2
+ merchantId?: string;
3
+ sub?: string;
4
+ exp?: number;
5
+ iat?: number;
6
+ [key: string]: unknown;
7
+ }
8
+ export declare function decodeJWT(token: string): JWTPayload | null;
9
+ export declare function getMerchantIdFromToken(token: string): string | null;
10
+ export declare function isTokenExpired(token: string): boolean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeJWT = decodeJWT;
4
+ exports.getMerchantIdFromToken = getMerchantIdFromToken;
5
+ exports.isTokenExpired = isTokenExpired;
6
+ function decodeJWT(token) {
7
+ try {
8
+ const parts = token.split('.');
9
+ if (parts.length !== 3)
10
+ throw new Error('Invalid JWT format');
11
+ const jsonPayload = decodeURIComponent(atob(parts[1].replace(/-/g, '+').replace(/_/g, '/'))
12
+ .split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''));
13
+ return JSON.parse(jsonPayload);
14
+ }
15
+ catch (_a) {
16
+ return null;
17
+ }
18
+ }
19
+ function getMerchantIdFromToken(token) {
20
+ const payload = decodeJWT(token);
21
+ return (payload === null || payload === void 0 ? void 0 : payload.merchantId) || (payload === null || payload === void 0 ? void 0 : payload.sub) || null;
22
+ }
23
+ function isTokenExpired(token) {
24
+ const payload = decodeJWT(token);
25
+ if (!(payload === null || payload === void 0 ? void 0 : payload.exp))
26
+ return false;
27
+ return payload.exp < Math.floor(Date.now() / 1000);
28
+ }
@@ -0,0 +1,5 @@
1
+ export declare const getStoredToken: () => Promise<string | null>;
2
+ export declare const setStoredToken: (token: string) => Promise<void>;
3
+ export declare const clearStoredToken: () => Promise<void>;
4
+ export declare const storeMerchantData: (data: any) => Promise<void>;
5
+ export declare const getStoredMerchantData: () => Promise<any | null>;