spaark-payapi-sdk 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.
@@ -0,0 +1,505 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { D as DepositRequest, a as DepositResponse, P as PayoutRequest, b as PayoutResponse, c as PaymentPageRequest, d as PaymentPageResponse, R as RefundRequest, e as RefundResponse, T as TransactionStatusResponse, f as PollOptions, g as TransactionFilters, A as ActionResponse, C as Currency, h as Correspondent, i as TransactionLimits, j as CorrespondentInfo, F as FailureReason } from './react-pjDvSSJA.js';
3
+ export { k as CORRESPONDENTS, l as CORRESPONDENT_INFO, m as CorrespondentFeature, n as DEFAULT_LIMITS, o as DepositFailureCode, p as FinancialAddress, M as MMOAccount, q as PawapayTestDashboard, r as PawapayTestDashboardProps, s as PayoutFailureCode, t as TransactionStatus } from './react-pjDvSSJA.js';
4
+ import 'react/jsx-runtime';
5
+
6
+ type Environment = 'sandbox' | 'production';
7
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
8
+ interface SpaarkPayApiSdkConfig {
9
+ apiKey: string;
10
+ environment: Environment;
11
+ baseUrl?: string;
12
+ callbackUrl?: string;
13
+ timeout?: number;
14
+ retries?: number;
15
+ retryDelay?: number;
16
+ logLevel?: LogLevel;
17
+ }
18
+ interface ResolvedConfig {
19
+ apiKey: string;
20
+ environment: Environment;
21
+ baseUrl: string;
22
+ callbackUrl?: string;
23
+ timeout: number;
24
+ retries: number;
25
+ retryDelay: number;
26
+ logLevel: LogLevel;
27
+ }
28
+
29
+ declare class Logger {
30
+ private readonly prefix;
31
+ private level;
32
+ constructor(prefix: string, level?: LogLevel);
33
+ setLevel(level: LogLevel): void;
34
+ private shouldLog;
35
+ private formatMessage;
36
+ private sanitize;
37
+ debug(message: string, data?: unknown): void;
38
+ info(message: string, data?: unknown): void;
39
+ warn(message: string, data?: unknown): void;
40
+ error(message: string, error?: Error | unknown): void;
41
+ }
42
+
43
+ interface HttpClientConfig {
44
+ baseUrl: string;
45
+ apiKey: string;
46
+ timeout: number;
47
+ retries: number;
48
+ retryDelay: number;
49
+ logger: Logger;
50
+ }
51
+ declare class HttpClient {
52
+ private readonly client;
53
+ private readonly logger;
54
+ private readonly retries;
55
+ private readonly retryDelay;
56
+ constructor(config: HttpClientConfig);
57
+ private setupInterceptors;
58
+ private handleError;
59
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
60
+ post<T, D = unknown>(url: string, data?: D, config?: AxiosRequestConfig): Promise<T>;
61
+ put<T, D = unknown>(url: string, data?: D, config?: AxiosRequestConfig): Promise<T>;
62
+ delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
63
+ static fromConfig(config: ResolvedConfig, logger: Logger): HttpClient;
64
+ }
65
+
66
+ declare class TransactionsModule {
67
+ private readonly httpClient;
68
+ private readonly logger;
69
+ constructor(httpClient: HttpClient, logger: Logger);
70
+ /**
71
+ * Initiate a deposit (collect payment from mobile money user) - V2 API
72
+ */
73
+ initiateDeposit(request: DepositRequest): Promise<DepositResponse>;
74
+ /**
75
+ * Initiate a payout (send money to mobile money user) - V2 API
76
+ */
77
+ initiatePayout(request: PayoutRequest): Promise<PayoutResponse>;
78
+ /**
79
+ * Create a hosted payment page - V2 API
80
+ */
81
+ createPaymentPage(request: PaymentPageRequest): Promise<PaymentPageResponse>;
82
+ /**
83
+ * Refund a deposit
84
+ */
85
+ refund(request: RefundRequest): Promise<RefundResponse>;
86
+ /**
87
+ * Check deposit status - V2 API
88
+ */
89
+ checkDepositStatus(depositId: string): Promise<TransactionStatusResponse>;
90
+ /**
91
+ * Check payout status - V2 API
92
+ */
93
+ checkPayoutStatus(payoutId: string): Promise<TransactionStatusResponse>;
94
+ /**
95
+ * Check transaction status (tries deposit first, then payout) - V2 API
96
+ */
97
+ checkStatus(transactionId: string): Promise<TransactionStatusResponse>;
98
+ /**
99
+ * Poll until transaction reaches final status
100
+ */
101
+ pollUntilComplete(transactionId: string, options?: PollOptions): Promise<TransactionStatusResponse>;
102
+ /**
103
+ * List deposits with filters
104
+ */
105
+ listDeposits(filters?: TransactionFilters): Promise<DepositResponse[]>;
106
+ /**
107
+ * List payouts with filters
108
+ */
109
+ listPayouts(filters?: TransactionFilters): Promise<PayoutResponse[]>;
110
+ /**
111
+ * Resend deposit callback - V2 API
112
+ * Triggers a new callback for a deposit transaction
113
+ */
114
+ resendDepositCallback(depositId: string): Promise<ActionResponse>;
115
+ /**
116
+ * Resend payout callback - V2 API
117
+ * Triggers a new callback for a payout transaction
118
+ */
119
+ resendPayoutCallback(payoutId: string): Promise<ActionResponse>;
120
+ /**
121
+ * Cancel enqueued payout - V2 API
122
+ * Cancels a payout that is still in ENQUEUED status
123
+ */
124
+ cancelEnqueuedPayout(payoutId: string): Promise<ActionResponse>;
125
+ }
126
+
127
+ interface ProductCreateRequest {
128
+ name: string;
129
+ description?: string;
130
+ price: number;
131
+ currency: Currency;
132
+ metadata?: Record<string, unknown>;
133
+ }
134
+ interface Product {
135
+ id: string;
136
+ name: string;
137
+ description?: string;
138
+ price: number;
139
+ currency: string;
140
+ domains: string[];
141
+ created: string;
142
+ updated: string;
143
+ }
144
+ interface DomainAddRequest {
145
+ productId: string;
146
+ domain: string;
147
+ }
148
+
149
+ declare class ProductsModule {
150
+ private readonly logger;
151
+ private products;
152
+ constructor(logger: Logger);
153
+ create(request: ProductCreateRequest): Promise<Product>;
154
+ get(productId: string): Promise<Product>;
155
+ list(): Promise<Product[]>;
156
+ update(productId: string, updates: Partial<ProductCreateRequest>): Promise<Product>;
157
+ delete(productId: string): Promise<void>;
158
+ addDomain(request: DomainAddRequest): Promise<Product>;
159
+ removeDomain(productId: string, domain: string): Promise<Product>;
160
+ private toProduct;
161
+ }
162
+
163
+ type WebhookEventType = 'deposit.accepted' | 'deposit.completed' | 'deposit.failed' | 'payout.accepted' | 'payout.completed' | 'payout.failed' | 'refund.completed' | 'refund.failed';
164
+ interface PawapayWebhookEvent<T = unknown> {
165
+ eventId: string;
166
+ eventType: WebhookEventType;
167
+ timestamp: string;
168
+ data: T;
169
+ }
170
+ interface DepositCallbackData {
171
+ depositId: string;
172
+ status: 'COMPLETED' | 'FAILED';
173
+ amount: string;
174
+ currency: string;
175
+ correspondent: string;
176
+ payer: {
177
+ type: string;
178
+ address: {
179
+ value: string;
180
+ };
181
+ };
182
+ customerTimestamp: string;
183
+ created: string;
184
+ receivedByPayer?: string;
185
+ failureReason?: {
186
+ failureCode: string;
187
+ failureMessage: string;
188
+ };
189
+ metadata?: Record<string, unknown>;
190
+ }
191
+ interface PayoutCallbackData {
192
+ payoutId: string;
193
+ status: 'COMPLETED' | 'FAILED';
194
+ amount: string;
195
+ currency: string;
196
+ correspondent: string;
197
+ recipient: {
198
+ type: string;
199
+ address: {
200
+ value: string;
201
+ };
202
+ };
203
+ customerTimestamp: string;
204
+ created: string;
205
+ receivedByRecipient?: string;
206
+ failureReason?: {
207
+ failureCode: string;
208
+ failureMessage: string;
209
+ };
210
+ metadata?: Record<string, unknown>;
211
+ }
212
+
213
+ interface WebhooksConfig {
214
+ webhookSecret?: string;
215
+ }
216
+ declare class WebhooksModule {
217
+ private readonly httpClient;
218
+ private readonly logger;
219
+ private webhookSecret?;
220
+ constructor(httpClient: HttpClient, logger: Logger, config?: WebhooksConfig);
221
+ setWebhookSecret(secret: string): void;
222
+ verifySignature(payload: string, signature: string): boolean;
223
+ parseEvent<T = unknown>(payload: string): PawapayWebhookEvent<T>;
224
+ constructEvent<T = unknown>(payload: string, signature: string): PawapayWebhookEvent<T>;
225
+ registerCallback(url: string): Promise<void>;
226
+ unregisterCallback(): Promise<void>;
227
+ isDepositEvent(eventType: WebhookEventType): boolean;
228
+ isPayoutEvent(eventType: WebhookEventType): boolean;
229
+ isRefundEvent(eventType: WebhookEventType): boolean;
230
+ isSuccessEvent(eventType: WebhookEventType): boolean;
231
+ isFailureEvent(eventType: WebhookEventType): boolean;
232
+ }
233
+
234
+ type OperationType = 'DEPOSIT' | 'PAYOUT' | 'REFUND' | 'REMITTANCE';
235
+ type OperationStatus = 'OPERATIONAL' | 'DELAYED' | 'CLOSED';
236
+ interface ProviderOperationStatus {
237
+ operationType: OperationType;
238
+ status: OperationStatus;
239
+ }
240
+ interface ProviderAvailability {
241
+ provider: string;
242
+ operationTypes: ProviderOperationStatus[];
243
+ }
244
+ interface CountryAvailability {
245
+ country: string;
246
+ providers: ProviderAvailability[];
247
+ }
248
+ interface PredictProviderRequest {
249
+ phoneNumber: string;
250
+ }
251
+ interface PredictProviderResponse {
252
+ country: string;
253
+ provider: string;
254
+ phoneNumber: string;
255
+ }
256
+ interface ActiveConfigResponse {
257
+ companyName: string;
258
+ signatureConfiguration: {
259
+ signedRequestsOnly?: boolean;
260
+ signedCallbacks?: boolean;
261
+ };
262
+ countries: CountryConfig[];
263
+ }
264
+ interface CountryConfig {
265
+ country: string;
266
+ displayName: Record<string, string>;
267
+ prefix: string;
268
+ flag: string;
269
+ providers: ProviderConfig[];
270
+ }
271
+ interface ProviderConfig {
272
+ provider: string;
273
+ displayName: string;
274
+ nameDisplayedToCustomer: string;
275
+ currencies: CurrencyConfig[];
276
+ }
277
+ interface CurrencyConfig {
278
+ currency: string;
279
+ displayName: string;
280
+ operationTypes: {
281
+ DEPOSIT?: OperationTypeConfig;
282
+ PAYOUT?: OperationTypeConfig;
283
+ REFUND?: OperationTypeConfig;
284
+ REMITTANCE?: OperationTypeConfig;
285
+ USSD_DEPOSIT?: {
286
+ callbackUrl?: string;
287
+ };
288
+ };
289
+ }
290
+ interface OperationTypeConfig {
291
+ minAmount?: string;
292
+ maxAmount?: string;
293
+ decimalsInAmount?: 'TWO_PLACES' | 'NONE';
294
+ status?: OperationStatus;
295
+ callbackUrl?: string;
296
+ authorisationType?: string;
297
+ authorisationInstructions?: Record<string, string>;
298
+ }
299
+ interface PublicKeyResponse {
300
+ id: string;
301
+ key: string;
302
+ }
303
+
304
+ interface MMOAvailability {
305
+ correspondent: Correspondent;
306
+ available: boolean;
307
+ degraded: boolean;
308
+ estimatedRecovery?: string;
309
+ message?: string;
310
+ }
311
+ declare class UtilsModule {
312
+ private readonly httpClient;
313
+ private readonly logger;
314
+ constructor(httpClient: HttpClient, logger: Logger);
315
+ generateTransactionId(): string;
316
+ validateTransactionId(id: string): boolean;
317
+ /**
318
+ * Get active configuration - V2 API
319
+ * Returns your account configuration including countries, providers, and limits
320
+ */
321
+ getActiveConfiguration(options?: {
322
+ country?: string;
323
+ operationType?: OperationType;
324
+ }): Promise<ActiveConfigResponse>;
325
+ /**
326
+ * Get provider availability - V2 API
327
+ * Returns current processing status for all providers
328
+ */
329
+ getProviderAvailability(options?: {
330
+ country?: string;
331
+ operationType?: OperationType;
332
+ }): Promise<CountryAvailability[]>;
333
+ /**
334
+ * Predict provider from phone number - V2 API
335
+ * Returns the predicted provider and sanitized phone number
336
+ */
337
+ predictProvider(phoneNumber: string): Promise<PredictProviderResponse>;
338
+ /**
339
+ * Get public keys for callback verification - V2 API
340
+ */
341
+ getPublicKeys(): Promise<PublicKeyResponse[]>;
342
+ getTransactionLimits(correspondent: Correspondent): Promise<TransactionLimits>;
343
+ checkMMOAvailability(correspondent: Correspondent): Promise<MMOAvailability>;
344
+ formatPhoneNumber(phone: string, countryCode: string): string;
345
+ validatePhoneNumber(phone: string, correspondent: Correspondent): boolean;
346
+ getSupportedCorrespondents(): readonly Correspondent[];
347
+ getCorrespondentInfo(correspondent: Correspondent): CorrespondentInfo;
348
+ getAllCorrespondentsInfo(): CorrespondentInfo[];
349
+ detectCorrespondent(phone: string): Correspondent | null;
350
+ }
351
+
352
+ interface WalletBalance {
353
+ country: string;
354
+ balance: string;
355
+ currency: string;
356
+ provider?: string;
357
+ }
358
+ interface WalletBalancesResponse {
359
+ balances: WalletBalance[];
360
+ }
361
+ interface StatementWallet {
362
+ country: string;
363
+ currency: string;
364
+ provider?: string;
365
+ }
366
+ interface StatementRequest {
367
+ wallet: StatementWallet;
368
+ callbackUrl: string;
369
+ startDate: string;
370
+ endDate: string;
371
+ compressed?: boolean;
372
+ }
373
+ type StatementStatus = 'PROCESSING' | 'COMPLETED' | 'FAILED';
374
+ interface StatementResponse {
375
+ status: 'ACCEPTED' | 'REJECTED';
376
+ statementId?: string;
377
+ created?: string;
378
+ failureReason?: {
379
+ failureCode: StatementFailureCode;
380
+ failureMessage?: string;
381
+ };
382
+ }
383
+ type StatementFailureCode = 'NO_AUTHENTICATION' | 'AUTHENTICATION_ERROR' | 'AUTHORISATION_ERROR' | 'INVALID_INPUT' | 'MISSING_PARAMETER' | 'UNSUPPORTED_PARAMETER' | 'INVALID_PARAMETER' | 'INVALID_CALLBACK_URL' | 'INVALID_DATE_RANGE' | 'WALLET_NOT_FOUND' | 'UNKNOWN_ERROR';
384
+ interface StatementStatusResponse {
385
+ status: 'FOUND' | 'NOT_FOUND';
386
+ data?: StatementData;
387
+ }
388
+ interface StatementData {
389
+ statementId: string;
390
+ status: StatementStatus;
391
+ wallet: StatementWallet;
392
+ created: string;
393
+ startDate: string;
394
+ endDate: string;
395
+ fileSize?: number;
396
+ downloadUrl?: string;
397
+ downloadUrlExpiresAt?: string;
398
+ completedAt?: string;
399
+ failedAt?: string;
400
+ failureReason?: {
401
+ failureCode: 'UNKNOWN_ERROR';
402
+ failureMessage?: string;
403
+ };
404
+ }
405
+ interface StatementCallbackData {
406
+ statementId: string;
407
+ status: StatementStatus;
408
+ wallet: StatementWallet;
409
+ created: string;
410
+ startDate: string;
411
+ endDate: string;
412
+ fileSize?: number;
413
+ downloadUrl?: string;
414
+ downloadUrlExpiresAt?: string;
415
+ completedAt?: string;
416
+ failedAt?: string;
417
+ failureReason?: {
418
+ failureCode: 'UNKNOWN_ERROR';
419
+ failureMessage?: string;
420
+ };
421
+ }
422
+
423
+ declare class FinancesModule {
424
+ private readonly httpClient;
425
+ private readonly logger;
426
+ constructor(httpClient: HttpClient, logger: Logger);
427
+ /**
428
+ * Get wallet balances - V2 API
429
+ * Returns balances for all wallets configured on your account
430
+ */
431
+ getWalletBalances(): Promise<WalletBalance[]>;
432
+ /**
433
+ * Generate a statement for a wallet - V2 API
434
+ * The statement can be downloaded from the callback URL or checked via status endpoint
435
+ */
436
+ generateStatement(request: StatementRequest): Promise<StatementResponse>;
437
+ /**
438
+ * Check statement status - V2 API
439
+ */
440
+ checkStatementStatus(statementId: string): Promise<StatementData>;
441
+ /**
442
+ * Poll until statement is ready
443
+ */
444
+ pollStatementUntilComplete(statementId: string, options?: {
445
+ interval?: number;
446
+ maxAttempts?: number;
447
+ }): Promise<StatementData>;
448
+ }
449
+
450
+ declare class SpaarkPayApiSdk {
451
+ private readonly config;
452
+ private readonly logger;
453
+ private readonly httpClient;
454
+ readonly transactions: TransactionsModule;
455
+ readonly products: ProductsModule;
456
+ readonly webhooks: WebhooksModule;
457
+ readonly utils: UtilsModule;
458
+ readonly finances: FinancesModule;
459
+ constructor(config: SpaarkPayApiSdkConfig);
460
+ private getWebhookSecretFromEnv;
461
+ getConfig(): Readonly<ResolvedConfig>;
462
+ setLogLevel(level: LogLevel): void;
463
+ setWebhookSecret(secret: string): void;
464
+ }
465
+
466
+ declare const ERROR_CODES: {
467
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
468
+ readonly INVALID_PHONE: "INVALID_PHONE";
469
+ readonly INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS";
470
+ readonly AMOUNT_TOO_LOW: "AMOUNT_TOO_LOW";
471
+ readonly AMOUNT_TOO_HIGH: "AMOUNT_TOO_HIGH";
472
+ readonly LIMIT_EXCEEDED: "LIMIT_EXCEEDED";
473
+ readonly DUPLICATE: "DUPLICATE";
474
+ readonly MMO_UNAVAILABLE: "MMO_UNAVAILABLE";
475
+ readonly TIMEOUT: "TIMEOUT";
476
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
477
+ readonly RATE_LIMITED: "RATE_LIMITED";
478
+ readonly SERVER_ERROR: "SERVER_ERROR";
479
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
480
+ readonly NOT_FOUND: "NOT_FOUND";
481
+ readonly REFUND_NOT_ALLOWED: "REFUND_NOT_ALLOWED";
482
+ };
483
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
484
+
485
+ declare class PawapayError extends Error {
486
+ readonly code: ErrorCode;
487
+ readonly statusCode: number;
488
+ readonly failureReason?: FailureReason;
489
+ readonly retryable: boolean;
490
+ readonly originalError?: Error;
491
+ constructor(message: string, code: ErrorCode, statusCode: number, options?: {
492
+ failureReason?: FailureReason;
493
+ retryable?: boolean;
494
+ originalError?: Error;
495
+ });
496
+ static fromPawapayResponse(pawapayCode: string, message?: string, originalError?: Error): PawapayError;
497
+ static validation(message: string): PawapayError;
498
+ static network(message: string, originalError?: Error): PawapayError;
499
+ static timeout(message?: string): PawapayError;
500
+ static unauthorized(message?: string): PawapayError;
501
+ static notFound(message?: string): PawapayError;
502
+ toJSON(): Record<string, unknown>;
503
+ }
504
+
505
+ export { ActionResponse, type ActiveConfigResponse, Correspondent, CorrespondentInfo, type CountryAvailability, type CountryConfig, Currency, type CurrencyConfig, type DepositCallbackData, DepositRequest, DepositResponse, type DomainAddRequest, ERROR_CODES, type Environment, type ErrorCode, FailureReason, type LogLevel, Logger, type MMOAvailability, type OperationStatus, type OperationType, type OperationTypeConfig, PawapayError, type PawapayWebhookEvent, PaymentPageRequest, PaymentPageResponse, type PayoutCallbackData, PayoutRequest, PayoutResponse, PollOptions, type PredictProviderRequest, type PredictProviderResponse, type Product, type ProductCreateRequest, type ProviderAvailability, type ProviderConfig, type ProviderOperationStatus, type PublicKeyResponse, RefundRequest, RefundResponse, type ResolvedConfig, SpaarkPayApiSdk, type SpaarkPayApiSdkConfig, type StatementCallbackData, type StatementData, type StatementFailureCode, type StatementRequest, type StatementResponse, type StatementStatus, type StatementStatusResponse, type StatementWallet, TransactionFilters, TransactionLimits, TransactionStatusResponse, type WalletBalance, type WalletBalancesResponse, type WebhookEventType };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';var zod=require('zod'),te=require('axios'),crypto$1=require('crypto'),uuid=require('uuid'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var te__default=/*#__PURE__*/_interopDefault(te);var D={timeout:3e4,retries:3,retryDelay:1e3,logLevel:"info",sandboxUrl:"https://api.sandbox.pawapay.io",productionUrl:"https://api.pawapay.io"};var x={VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PHONE:"INVALID_PHONE",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",AMOUNT_TOO_LOW:"AMOUNT_TOO_LOW",AMOUNT_TOO_HIGH:"AMOUNT_TOO_HIGH",LIMIT_EXCEEDED:"LIMIT_EXCEEDED",DUPLICATE:"DUPLICATE",MMO_UNAVAILABLE:"MMO_UNAVAILABLE",TIMEOUT:"TIMEOUT",UNAUTHORIZED:"UNAUTHORIZED",RATE_LIMITED:"RATE_LIMITED",SERVER_ERROR:"SERVER_ERROR",NETWORK_ERROR:"NETWORK_ERROR",NOT_FOUND:"NOT_FOUND",REFUND_NOT_ALLOWED:"REFUND_NOT_ALLOWED"},_e=[{pawapayCode:"INVALID_PHONE_NUMBER",sdkCode:x.INVALID_PHONE,httpStatus:400,retryable:false,message:"Invalid phone number format"},{pawapayCode:"INSUFFICIENT_FUNDS",sdkCode:x.INSUFFICIENT_FUNDS,httpStatus:402,retryable:false,message:"Insufficient funds in account"},{pawapayCode:"AMOUNT_TOO_LOW",sdkCode:x.AMOUNT_TOO_LOW,httpStatus:400,retryable:false,message:"Amount below minimum"},{pawapayCode:"AMOUNT_TOO_HIGH",sdkCode:x.AMOUNT_TOO_HIGH,httpStatus:400,retryable:false,message:"Amount exceeds maximum"},{pawapayCode:"TRANSACTION_LIMIT_EXCEEDED",sdkCode:x.LIMIT_EXCEEDED,httpStatus:400,retryable:false,message:"Daily or monthly limit exceeded"},{pawapayCode:"DUPLICATE_TRANSACTION",sdkCode:x.DUPLICATE,httpStatus:409,retryable:false,message:"Transaction ID already used"},{pawapayCode:"CORRESPONDENT_UNAVAILABLE",sdkCode:x.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"CORRESPONDENT_TEMPORARILY_UNAVAILABLE",sdkCode:x.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"TIMEOUT",sdkCode:x.TIMEOUT,httpStatus:408,retryable:true,message:"Transaction timed out"},{pawapayCode:"INVALID_API_KEY",sdkCode:x.UNAUTHORIZED,httpStatus:401,retryable:false,message:"Invalid or expired API key"},{pawapayCode:"RATE_LIMIT_EXCEEDED",sdkCode:x.RATE_LIMITED,httpStatus:429,retryable:true,message:"Too many requests"},{pawapayCode:"INTERNAL_ERROR",sdkCode:x.SERVER_ERROR,httpStatus:500,retryable:true,message:"Pawapay internal error"},{pawapayCode:"REFUND_NOT_ALLOWED",sdkCode:x.REFUND_NOT_ALLOWED,httpStatus:400,retryable:false,message:"Refund not allowed for this transaction"}];function pe(i){return _e.find(e=>e.pawapayCode===i)}var l=class i extends Error{constructor(e,t,r,o){super(e),this.name="PawapayError",this.code=t,this.statusCode=r,this.failureReason=o?.failureReason,this.retryable=o?.retryable??false,this.originalError=o?.originalError,Error.captureStackTrace&&Error.captureStackTrace(this,i);}static fromPawapayResponse(e,t,r){let o=pe(e);return o?new i(t??o.message,o.sdkCode,o.httpStatus,{retryable:o.retryable,originalError:r}):new i(t??"Unknown error occurred",x.SERVER_ERROR,500,{retryable:false,originalError:r})}static validation(e){return new i(e,x.VALIDATION_ERROR,400,{retryable:false})}static network(e,t){return new i(e,x.NETWORK_ERROR,0,{retryable:true,originalError:t})}static timeout(e="Request timed out"){return new i(e,x.TIMEOUT,408,{retryable:true})}static unauthorized(e="Invalid or expired API key"){return new i(e,x.UNAUTHORIZED,401,{retryable:false})}static notFound(e="Resource not found"){return new i(e,x.NOT_FOUND,404,{retryable:false})}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,failureReason:this.failureReason,retryable:this.retryable}}};var Ue=zod.z.object({apiKey:zod.z.string().min(1,"API key is required"),environment:zod.z.enum(["sandbox","production"]),baseUrl:zod.z.string().url().optional(),callbackUrl:zod.z.string().url().optional(),timeout:zod.z.number().positive().max(6e5).optional(),retries:zod.z.number().int().min(0).max(10).optional(),retryDelay:zod.z.number().positive().max(6e4).optional(),logLevel:zod.z.enum(["debug","info","warn","error","none"]).optional()});function me(i){let e=Ue.safeParse(i);if(!e.success){let o=e.error.errors.map(u=>`${u.path.join(".")}: ${u.message}`);throw l.validation(`Invalid SDK configuration: ${o.join(", ")}`)}let t=e.data,r=t.baseUrl??(t.environment==="production"?D.productionUrl:D.sandboxUrl);return {apiKey:t.apiKey,environment:t.environment,baseUrl:r,callbackUrl:t.callbackUrl,timeout:t.timeout??D.timeout,retries:t.retries??D.retries,retryDelay:t.retryDelay??D.retryDelay,logLevel:t.logLevel??D.logLevel}}function ge(){let i=typeof process<"u"?process.env:{},e={};if(i.PAWAPAY_API_KEY&&(e.apiKey=i.PAWAPAY_API_KEY),i.PAWAPAY_ENVIRONMENT){let t=i.PAWAPAY_ENVIRONMENT.toLowerCase();(t==="production"||t==="sandbox")&&(e.environment=t);}if(i.PAWAPAY_BASE_URL&&(e.baseUrl=i.PAWAPAY_BASE_URL),i.PAWAPAY_CALLBACK_URL&&(e.callbackUrl=i.PAWAPAY_CALLBACK_URL),i.PAWAPAY_TIMEOUT){let t=parseInt(i.PAWAPAY_TIMEOUT,10);isNaN(t)||(e.timeout=t);}if(i.PAWAPAY_RETRIES){let t=parseInt(i.PAWAPAY_RETRIES,10);isNaN(t)||(e.retries=t);}if(i.PAWAPAY_LOG_LEVEL){let t=i.PAWAPAY_LOG_LEVEL.toLowerCase();["debug","info","warn","error","none"].includes(t)&&(e.logLevel=t);}return e}var Fe={maxAttempts:3,initialDelay:1e3,maxDelay:3e4,backoffMultiplier:2};function je(i){return new Promise(e=>setTimeout(e,i))}function $e(i,e){let t=e.initialDelay*Math.pow(e.backoffMultiplier,i-1),r=Math.random()*.3*t;return Math.min(t+r,e.maxDelay)}async function $(i,e={},t){let r={...Fe,...e},o;for(let u=1;u<=r.maxAttempts;u++)try{return await i()}catch(g){if(o=g instanceof Error?g:new Error(String(g)),!(g instanceof l?g.retryable:We(g))||u===r.maxAttempts)throw g;let p=$e(u,r);t?.warn(`Attempt ${u}/${r.maxAttempts} failed, retrying in ${Math.round(p)}ms`,{error:o.message}),await je(p);}throw o??new Error("Retry failed without error")}function We(i){return i instanceof l?i.retryable:i instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","Network Error","timeout","socket hang up"].some(t=>i.message.includes(t)||i.code===t):false}var q=class i{constructor(e){this.logger=e.logger,this.retries=e.retries,this.retryDelay=e.retryDelay,this.client=te__default.default.create({baseURL:e.baseUrl,timeout:e.timeout,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`}}),this.setupInterceptors();}setupInterceptors(){this.client.interceptors.request.use(e=>(this.logger.debug(`${e.method?.toUpperCase()} ${e.url}`,{params:e.params}),e),e=>(this.logger.error("Request error",e),Promise.reject(e))),this.client.interceptors.response.use(e=>(this.logger.debug(`${e.config.method?.toUpperCase()} ${e.config.url} -> ${e.status}`,{data:e.data}),e),e=>(te__default.default.isAxiosError(e)&&this.logger.error(`Request failed: ${e.config?.method?.toUpperCase()} ${e.config?.url}`,{status:e.response?.status,data:e.response?.data}),Promise.reject(e)));}handleError(e){if(te__default.default.isAxiosError(e)){if(e.code==="ECONNABORTED"||e.message.includes("timeout"))throw l.timeout();if(!e.response)throw l.network(e.message||"Network error",e);let{status:t,data:r}=e.response,o=r;if(t===401)throw l.unauthorized();if(t===404)throw l.notFound();let u=o?.errorCode??o?.rejectionReason?.rejectionCode;throw u?l.fromPawapayResponse(u,o?.errorMessage??o?.rejectionReason?.rejectionMessage,e):new l(o?.errorMessage??`HTTP error ${t}`,"SERVER_ERROR",t,{retryable:t>=500,originalError:e})}throw e instanceof l?e:l.network(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}async get(e,t){return $(async()=>{try{return (await this.client.get(e,t)).data}catch(r){this.handleError(r);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async post(e,t,r){return $(async()=>{try{return (await this.client.post(e,t,r)).data}catch(o){this.handleError(o);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async put(e,t,r){return $(async()=>{try{return (await this.client.put(e,t,r)).data}catch(o){this.handleError(o);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async delete(e,t){return $(async()=>{try{return (await this.client.delete(e,t)).data}catch(r){this.handleError(r);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}static fromConfig(e,t){return new i({baseUrl:e.baseUrl,apiKey:e.apiKey,timeout:e.timeout,retries:e.retries,retryDelay:e.retryDelay,logger:t})}};var ye={debug:0,info:1,warn:2,error:3,none:4},W=class{constructor(e,t="info"){this.prefix=e,this.level=t;}setLevel(e){this.level=e;}shouldLog(e){return ye[e]>=ye[this.level]}formatMessage(e,t){return `[${new Date().toISOString()}] ${e.toUpperCase().padEnd(5)} [${this.prefix}] ${t}`}sanitize(e){if(e==null||typeof e=="string"||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>this.sanitize(o));let t={},r=["apiKey","api_key","authorization","password","secret","token"];for(let[o,u]of Object.entries(e))r.some(g=>o.toLowerCase().includes(g))?t[o]="[REDACTED]":typeof u=="object"&&u!==null?t[o]=this.sanitize(u):t[o]=u;return t}debug(e,t){if(this.shouldLog("debug")){let r=this.formatMessage("debug",e);t!==void 0?console.debug(r,this.sanitize(t)):console.debug(r);}}info(e,t){if(this.shouldLog("info")){let r=this.formatMessage("info",e);t!==void 0?console.info(r,this.sanitize(t)):console.info(r);}}warn(e,t){if(this.shouldLog("warn")){let r=this.formatMessage("warn",e);t!==void 0?console.warn(r,this.sanitize(t)):console.warn(r);}}error(e,t){if(this.shouldLog("error")){let r=this.formatMessage("error",e);t!==void 0?console.error(r,this.sanitize(t)):console.error(r);}}};var U=["MTN_MOMO_CMR","ORANGE_CMR","MTN_MOMO_COG","AIRTEL_COG","MTN_MOMO_GAB","AIRTEL_GAB"],F={MTN_MOMO_CMR:{correspondent:"MTN_MOMO_CMR",name:"MTN Mobile Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(67|68|65[0-4])\d{6}$/},ORANGE_CMR:{correspondent:"ORANGE_CMR",name:"Orange Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(69|65[5-9])\d{6}$/},MTN_MOMO_COG:{correspondent:"MTN_MOMO_COG",name:"MTN Mobile Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^242(04|05|06)\d{7}$/},AIRTEL_COG:{correspondent:"AIRTEL_COG",name:"Airtel Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout"],phoneRegex:/^242(01|02|03)\d{7}$/},MTN_MOMO_GAB:{correspondent:"MTN_MOMO_GAB",name:"MTN Mobile Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^241(06|07)\d{6}$/},AIRTEL_GAB:{correspondent:"AIRTEL_GAB",name:"Airtel Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout"],phoneRegex:/^241(04|05)\d{6}$/}},V={MTN_MOMO_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},ORANGE_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},MTN_MOMO_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},MTN_MOMO_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6}};var Ge=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum(U),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),preAuthorisationCode:zod.z.string().optional(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),qe=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum(U),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),Ve=zod.z.object({depositId:zod.z.string().uuid(),returnUrl:zod.z.string().url(),phoneNumber:zod.z.string().optional(),amountDetails:zod.z.object({amount:zod.z.number().positive(),currency:zod.z.string().length(3)}).optional(),language:zod.z.enum(["EN","FR"]).optional(),country:zod.z.string().length(3).optional(),reason:zod.z.string().max(50).optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),Be=zod.z.object({depositId:zod.z.string().uuid(),amount:zod.z.number().positive("Amount must be positive"),transactionId:zod.z.string().uuid()});function Ke(i){return new Promise(e=>setTimeout(e,i))}var B=class{constructor(e,t){this.httpClient=e;this.logger=t;}async initiateDeposit(e){let t=Ge.parse(e),r={depositId:t.transactionId,amount:t.amount.toString(),currency:t.currency,payer:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},preAuthorisationCode:t.preAuthorisationCode,clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 deposit ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let o=await this.httpClient.post("/v2/deposits",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Deposit ${o.depositId} status: ${o.status}`),{depositId:o.depositId,status:o.status,created:o.created??new Date().toISOString(),nextStep:o.nextStep,redirectUrl:o.redirectUrl}}async initiatePayout(e){let t=qe.parse(e),r={payoutId:t.transactionId,amount:t.amount.toString(),currency:t.currency,recipient:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 payout ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let o=await this.httpClient.post("/v2/payouts",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Payout ${o.payoutId} status: ${o.status}`),{payoutId:o.payoutId,status:o.status,created:o.created??new Date().toISOString()}}async createPaymentPage(e){let t=Ve.parse(e),r={depositId:t.depositId,returnUrl:t.returnUrl,phoneNumber:t.phoneNumber,amountDetails:t.amountDetails?{amount:t.amountDetails.amount.toString(),currency:t.amountDetails.currency}:void 0,language:t.language,country:t.country,reason:t.reason,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Creating payment page for deposit ${t.depositId}`);let o=await this.httpClient.post("/v2/paymentpage",r);return this.logger.info(`Payment page created: ${o.redirectUrl}`),{redirectUrl:o.redirectUrl}}async refund(e){let t=Be.parse(e),r={refundId:t.transactionId,depositId:t.depositId,amount:t.amount.toString()};this.logger.info(`Initiating refund ${t.transactionId}`,{depositId:t.depositId,amount:t.amount});let o=await this.httpClient.post("/refunds",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Refund ${o.refundId} status: ${o.status}`),{refundId:o.refundId,depositId:t.depositId,status:o.status,amount:t.amount,created:o.created??new Date().toISOString()}}async checkDepositStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid deposit ID format");let t=await this.httpClient.get(`/v2/deposits/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Deposit ${e} not found`);let r=t.data;return {depositId:r.depositId,status:r.status,amount:r.amount,currency:r.currency,country:r.country,payer:r.payer,created:r.created,customerMessage:r.customerMessage,clientReferenceId:r.clientReferenceId,providerTransactionId:r.providerTransactionId,failureReason:r.failureReason,metadata:r.metadata}}async checkPayoutStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");let t=await this.httpClient.get(`/v2/payouts/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Payout ${e} not found`);let r=t.data;return {payoutId:r.payoutId,status:r.status,amount:r.amount,currency:r.currency,country:r.country,recipient:r.recipient,created:r.created,customerMessage:r.customerMessage,clientReferenceId:r.clientReferenceId,providerTransactionId:r.providerTransactionId,failureReason:r.failureReason,metadata:r.metadata}}async checkStatus(e){try{return await this.checkDepositStatus(e)}catch(t){if(t instanceof l&&t.code==="NOT_FOUND")return await this.checkPayoutStatus(e);throw t}}async pollUntilComplete(e,t={}){let{interval:r=5e3,maxAttempts:o=12,onStatusChange:u}=t,g;for(let p=1;p<=o;p++){let P=await this.checkStatus(e);if(P.status!==g&&(g=P.status,u?.(P.status)),P.status==="COMPLETED"||P.status==="FAILED")return P;p<o&&await Ke(r);}return await this.checkStatus(e)}async listDeposits(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/deposits",{params:t})).map(o=>({depositId:o.depositId??"",status:o.status,created:o.created}))}async listPayouts(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/payouts",{params:t})).map(o=>({payoutId:o.payoutId??"",status:o.status,created:o.created}))}async resendDepositCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid deposit ID format");this.logger.info(`Resending callback for deposit ${e}`);let t=await this.httpClient.post(`/v2/deposits/${e}/resend-callback`,{});return this.logger.info(`Resend callback for deposit ${e}: ${t.status}`),t}async resendPayoutCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");this.logger.info(`Resending callback for payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/resend-callback`,{});return this.logger.info(`Resend callback for payout ${e}: ${t.status}`),t}async cancelEnqueuedPayout(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");this.logger.info(`Cancelling enqueued payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/cancel`,{});return this.logger.info(`Cancel payout ${e}: ${t.status}`),t}};var fe=zod.z.object({name:zod.z.string().min(1).max(100),description:zod.z.string().max(500).optional(),price:zod.z.number().positive(),currency:zod.z.enum(["XAF","XOF","USD"]),metadata:zod.z.record(zod.z.unknown()).optional()}),He=zod.z.object({productId:zod.z.string().uuid(),domain:zod.z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\.[a-zA-Z]{2,}$/)}),K=class{constructor(e){this.logger=e;this.products=new Map;}async create(e){let t=fe.parse(e),r=crypto.randomUUID(),o=new Date().toISOString(),u={id:r,name:t.name,description:t.description,price:t.price,currency:t.currency,domains:[],created:o,updated:o,metadata:t.metadata};return this.products.set(r,u),this.logger.info(`Created product ${r}`,{name:t.name}),this.toProduct(u)}async get(e){let t=this.products.get(e);if(!t)throw l.notFound(`Product ${e} not found`);return this.toProduct(t)}async list(){return Array.from(this.products.values()).map(e=>this.toProduct(e))}async update(e,t){let r=this.products.get(e);if(!r)throw l.notFound(`Product ${e} not found`);let o=fe.partial().parse(t),u={...r,...o,updated:new Date().toISOString()};return this.products.set(e,u),this.logger.info(`Updated product ${e}`),this.toProduct(u)}async delete(e){if(!this.products.get(e))throw l.notFound(`Product ${e} not found`);this.products.delete(e),this.logger.info(`Deleted product ${e}`);}async addDomain(e){let t=He.parse(e),r=this.products.get(t.productId);if(!r)throw l.notFound(`Product ${t.productId} not found`);if(r.domains.includes(t.domain))throw l.validation(`Domain ${t.domain} already added to product`);return r.domains.push(t.domain),r.updated=new Date().toISOString(),this.logger.info(`Added domain ${t.domain} to product ${t.productId}`),this.toProduct(r)}async removeDomain(e,t){let r=this.products.get(e);if(!r)throw l.notFound(`Product ${e} not found`);let o=r.domains.indexOf(t);if(o===-1)throw l.notFound(`Domain ${t} not found in product`);return r.domains.splice(o,1),r.updated=new Date().toISOString(),this.logger.info(`Removed domain ${t} from product ${e}`),this.toProduct(r)}toProduct(e){return {id:e.id,name:e.name,description:e.description,price:e.price,currency:e.currency,domains:[...e.domains],created:e.created,updated:e.updated}}};var H=class{constructor(e,t,r){this.httpClient=e;this.logger=t;this.webhookSecret=r?.webhookSecret;}setWebhookSecret(e){this.webhookSecret=e;}verifySignature(e,t){if(!this.webhookSecret)return this.logger.warn("Webhook secret not configured, skipping signature verification"),true;if(!t)return this.logger.warn("No signature provided in webhook request"),false;try{let r=crypto$1.createHmac("sha256",this.webhookSecret).update(e,"utf8").digest("hex"),o=Buffer.from(t,"hex"),u=Buffer.from(r,"hex");return o.length!==u.length?!1:crypto$1.timingSafeEqual(o,u)}catch(r){return this.logger.error("Error verifying webhook signature",r),false}}parseEvent(e){try{let t=JSON.parse(e);if(!t.eventId||!t.eventType||!t.timestamp)throw new Error("Invalid webhook event structure");return t}catch(t){throw l.validation(`Failed to parse webhook event: ${t instanceof Error?t.message:"Unknown error"}`)}}constructEvent(e,t){if(!this.verifySignature(e,t))throw l.unauthorized("Invalid webhook signature");return this.parseEvent(e)}async registerCallback(e){this.logger.info(`Registering callback URL: ${e}`),await this.httpClient.post("/webhooks",{url:e}),this.logger.info("Callback URL registered successfully");}async unregisterCallback(){this.logger.info("Unregistering callback URL"),await this.httpClient.delete("/webhooks"),this.logger.info("Callback URL unregistered successfully");}isDepositEvent(e){return e.startsWith("deposit.")}isPayoutEvent(e){return e.startsWith("payout.")}isRefundEvent(e){return e.startsWith("refund.")}isSuccessEvent(e){return e.endsWith(".completed")}isFailureEvent(e){return e.endsWith(".failed")}};var z=class{constructor(e,t){this.httpClient=e;this.logger=t;}generateTransactionId(){return uuid.v4()}validateTransactionId(e){return uuid.validate(e)&&uuid.version(e)===4}async getActiveConfiguration(e){let t={};e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching active configuration",e);let r=await this.httpClient.get("/v2/active-conf",{params:Object.keys(t).length>0?t:void 0});return this.logger.info(`Retrieved configuration for ${r.countries.length} countries`),r}async getProviderAvailability(e){let t={};return e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching provider availability",e),await this.httpClient.get("/v2/availability",{params:Object.keys(t).length>0?t:void 0})}async predictProvider(e){this.logger.info("Predicting provider for phone number");let t=await this.httpClient.post("/v2/predict-provider",{phoneNumber:e});return this.logger.info(`Predicted provider: ${t.provider} (${t.country})`),t}async getPublicKeys(){this.logger.info("Fetching public keys");let e=await this.httpClient.get("/v2/public-key/http");return this.logger.info(`Retrieved ${e.length} public keys`),e}async getTransactionLimits(e){try{let t=await this.getActiveConfiguration();for(let r of t.countries)for(let o of r.providers)if(o.provider===e){let u=o.currencies[0];if(u?.operationTypes){let g=u.operationTypes.DEPOSIT,y=u.operationTypes.PAYOUT,p=V[e];return {minDeposit:g?.minAmount?parseFloat(g.minAmount):p.minDeposit,maxDeposit:g?.maxAmount?parseFloat(g.maxAmount):p.maxDeposit,minPayout:y?.minAmount?parseFloat(y.minAmount):p.minPayout,maxPayout:y?.maxAmount?parseFloat(y.maxAmount):p.maxPayout,currency:u.currency,dailyLimit:p.dailyLimit}}}}catch(t){this.logger.warn(`Failed to fetch live limits for ${e}, using defaults`,t);}return V[e]}async checkMMOAvailability(e){try{let t=await this.getProviderAvailability();for(let r of t){let o=r.providers.find(u=>u.provider===e);if(o){let u=o.operationTypes.find(h=>h.operationType==="DEPOSIT"),g=o.operationTypes.find(h=>h.operationType==="PAYOUT"),y=u?.status==="OPERATIONAL"||g?.status==="OPERATIONAL",p=u?.status==="DELAYED"||g?.status==="DELAYED",P=u?.status==="CLOSED"&&g?.status==="CLOSED";return {correspondent:e,available:y||p,degraded:p,message:P?"Provider is currently closed":void 0}}}return {correspondent:e,available:!1,degraded:!1,message:"Correspondent not found in availability list"}}catch(t){return this.logger.warn(`Failed to check MMO availability for ${e}`,t),{correspondent:e,available:false,degraded:true,message:"Unable to verify availability"}}}formatPhoneNumber(e,t){let r=e.replace(/\D/g,"");r.startsWith("00")&&(r=r.slice(2));let u={CMR:"237",COG:"242",GAB:"241",ZMB:"260",GHA:"233",KEN:"254",TZA:"255",UGA:"256",RWA:"250",BEN:"229",CIV:"225",SEN:"221"}[t.toUpperCase()];return u&&!r.startsWith(u)&&(r.startsWith("0")&&(r=r.slice(1)),r=u+r),r}validatePhoneNumber(e,t){let r=F[t];if(!r)return false;let o=e.replace(/\D/g,"");return r.phoneRegex.test(o)}getSupportedCorrespondents(){return U}getCorrespondentInfo(e){return F[e]}getAllCorrespondentsInfo(){return Object.values(F)}detectCorrespondent(e){let t=e.replace(/\D/g,"");for(let[r,o]of Object.entries(F))if(o.phoneRegex.test(t))return r;return null}};var Qe=zod.z.object({wallet:zod.z.object({country:zod.z.string().length(3),currency:zod.z.string().length(3),provider:zod.z.string().optional()}),callbackUrl:zod.z.string().url(),startDate:zod.z.string(),endDate:zod.z.string(),compressed:zod.z.boolean().optional()}),X=class{constructor(e,t){this.httpClient=e;this.logger=t;}async getWalletBalances(){this.logger.info("Fetching wallet balances");let e=await this.httpClient.get("/v2/wallets/balances");return this.logger.info(`Retrieved ${e.balances.length} wallet balances`),e.balances}async generateStatement(e){let t=Qe.parse(e);this.logger.info("Generating statement",{wallet:t.wallet,startDate:t.startDate,endDate:t.endDate});let r=await this.httpClient.post("/v2/statements",t);if(r.status==="REJECTED"&&r.failureReason)throw l.fromPawapayResponse(r.failureReason.failureCode,r.failureReason.failureMessage);return this.logger.info(`Statement ${r.statementId} status: ${r.status}`),r}async checkStatementStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid statement ID format");let t=await this.httpClient.get(`/v2/statements/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Statement ${e} not found`);return this.logger.info(`Statement ${e} status: ${t.data.status}`),t.data}async pollStatementUntilComplete(e,t={}){let{interval:r=5e3,maxAttempts:o=24}=t;for(let u=1;u<=o;u++){let g=await this.checkStatementStatus(e);if(g.status==="COMPLETED"||g.status==="FAILED")return g;u<o&&await new Promise(y=>setTimeout(y,r));}return this.checkStatementStatus(e)}};var re=class{constructor(e){let r={...ge(),...e};this.config=me(r),this.logger=new W("SpaarkPayApiSdk",this.config.logLevel),this.httpClient=q.fromConfig(this.config,this.logger),this.transactions=new B(this.httpClient,this.logger),this.products=new K(this.logger),this.webhooks=new H(this.httpClient,this.logger,{webhookSecret:this.getWebhookSecretFromEnv()}),this.utils=new z(this.httpClient,this.logger),this.finances=new X(this.httpClient,this.logger),this.logger.info("SpaarkPayApiSdk initialized",{environment:this.config.environment,baseUrl:this.config.baseUrl});}getWebhookSecretFromEnv(){if(typeof process<"u"&&process.env)return process.env.PAWAPAY_WEBHOOK_SECRET}getConfig(){return {...this.config}}setLogLevel(e){this.logger.setLevel(e);}setWebhookSecret(e){this.webhooks.setWebhookSecret(e);}};var et=i=>({depositId:i,status:"ACCEPTED",created:new Date().toISOString(),nextStep:"FINAL_STATUS"}),tt=i=>({payoutId:i,status:"ACCEPTED",created:new Date().toISOString()}),rt=i=>({depositId:i,status:["COMPLETED","ACCEPTED","PROCESSING","ENQUEUED"][Math.floor(Math.random()*4)],created:new Date(Date.now()-6e4).toISOString(),amount:"5000",currency:"XAF",country:"CMR",payer:{type:"MMO",accountDetails:{phoneNumber:"237670000000",provider:"MTN_MOMO_CMR"}}}),ot=()=>[{country:"CMR",providers:[{provider:"MTN_MOMO_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"OPERATIONAL"}]},{provider:"ORANGE_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"DELAYED"}]}]}],nt=i=>({country:"CMR",provider:i.startsWith("23767")?"MTN_MOMO_CMR":"ORANGE_CMR",phoneNumber:i.replace(/\D/g,"")}),at=()=>({companyName:"Demo Company",signatureConfiguration:{signedRequestsOnly:false,signedCallbacks:true},countries:[{country:"CMR",displayName:{en:"Cameroon",fr:"Cameroun"},prefix:"237",flag:"https://cdn.pawapay.io/flags/cmr.svg",providers:[{provider:"MTN_MOMO_CMR",displayName:"MTN Mobile Money",nameDisplayedToCustomer:"MTN MoMo",currencies:[{currency:"XAF",displayName:"CFA Franc",operationTypes:{DEPOSIT:{minAmount:"100",maxAmount:"1000000",status:"OPERATIONAL"},PAYOUT:{minAmount:"100",maxAmount:"500000",status:"OPERATIONAL"}}}]}]}]}),st=()=>({balances:[{country:"CMR",currency:"XAF",balance:"1250000.00"},{country:"COG",currency:"XAF",balance:"450000.00"},{country:"GAB",currency:"XAF",balance:"780000.00"}]}),it=()=>[{id:"key-001",key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."}],M=(i=800)=>new Promise(e=>setTimeout(e,i+Math.random()*400)),oe=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)}),he=[{value:"MTN_MOMO_CMR",label:"MTN Mobile Money",country:"Cameroun"},{value:"ORANGE_CMR",label:"Orange Money",country:"Cameroun"},{value:"MTN_MOMO_COG",label:"MTN Mobile Money",country:"Congo"},{value:"AIRTEL_COG",label:"Airtel Money",country:"Congo"},{value:"MTN_MOMO_GAB",label:"MTN Mobile Money",country:"Gabon"},{value:"AIRTEL_GAB",label:"Airtel Money",country:"Gabon"}],be=[{value:"XAF",label:"XAF (CFA Franc BEAC)"},{value:"XOF",label:"XOF (CFA Franc BCEAO)"},{value:"GHS",label:"GHS (Ghana Cedi)"},{value:"KES",label:"KES (Kenyan Shilling)"},{value:"RWF",label:"RWF (Rwandan Franc)"},{value:"TZS",label:"TZS (Tanzanian Shilling)"},{value:"UGX",label:"UGX (Ugandan Shilling)"},{value:"ZMW",label:"ZMW (Zambian Kwacha)"}];function ct({apiKey:i="",environment:e="sandbox",className:t="",demoMode:r=false,apiBasePath:o="/api/pawapay",onDepositComplete:u,onPayoutComplete:g,onError:y}){let[p,P]=react.useState(i),[h,se]=react.useState(e),[Re,Y]=react.useState(!!i||r),[f,ie]=react.useState(r),[E,j]=react.useState("deposit"),[A,Z]=react.useState("237670000000"),[I,ce]=react.useState("5000"),[L,ue]=react.useState("XAF"),[_,de]=react.useState("MTN_MOMO_CMR"),[J,Ce]=react.useState("Test Payment"),[O,Q]=react.useState(""),[ee,le]=react.useState([]),[R,v]=react.useState("idle"),m=react.useCallback((n,c,b,S)=>{let Ie={id:oe(),operation:n,status:c,response:b,error:S,timestamp:new Date().toLocaleTimeString()};le(Le=>[Ie,...Le].slice(0,20));},[]),we=react.useCallback(()=>{if(!p.trim()){m("Configuration","error",void 0,"API Key is required");return}Y(true),ie(false),m("Configuration","success",{environment:h,configured:true,apiBasePath:o});},[p,h,o,m]),Pe=react.useCallback(()=>{ie(true),Y(true),m("Configuration","success",{mode:"demo",message:"Demo mode activated - responses are simulated"});},[m]),Ee=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n=oe();Q(n);let c;if(f)await M(),c=et(n);else {let b=await fetch(`${o}/deposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,amount:parseFloat(I),currency:L,provider:_,phoneNumber:A,customerMessage:J.slice(0,22),transactionId:n})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Deposit failed");c=S;}v("success"),m("Deposit","success",c),u?.(c);}catch(n){v("error");let c=n instanceof Error?n.message:"Deposit failed";m("Deposit","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,I,L,_,A,J,m,u,y]),Ae=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n=oe();Q(n);let c;if(f)await M(),c=tt(n);else {let b=await fetch(`${o}/payout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,amount:parseFloat(I),currency:L,provider:_,phoneNumber:A,transactionId:n})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Payout failed");c=S;}v("success"),m("Payout","success",c),g?.(c);}catch(n){v("error");let c=n instanceof Error?n.message:"Payout failed";m("Payout","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,I,L,_,A,m,g,y]),Ne=react.useCallback(async()=>{if(!p&&!f||!O){m("Check Status","error",void 0,"No transaction ID");return}v("loading");try{let n;if(f)await M(),n=rt(O);else {let c=await fetch(`${o}/status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,transactionId:O})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Status check failed");n=b;}v("success"),m("Check Status","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Status check failed";m("Check Status","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}},[p,o,h,f,O,m,y]),ke=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=ot();else {let c=await fetch(`${o}/availability`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Availability check failed");n=b;}v("success"),m("Provider Availability","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Availability check failed";m("Provider Availability","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Te=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=nt(A);else {let c=await fetch(`${o}/predict-provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,phoneNumber:A})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Prediction failed");n=b;}v("success"),m("Predict Provider","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Prediction failed";m("Predict Provider","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,A,m,y]),Oe=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=at();else {let c=await fetch(`${o}/active-config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get config");n=b;}v("success"),m("Active Configuration","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get config";m("Active Configuration","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Me=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=it();else {let c=await fetch(`${o}/public-keys`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get public keys");n=b;}v("success"),m("Public Keys","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get public keys";m("Public Keys","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Se=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=st();else {let c=await fetch(`${o}/wallet-balances`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get balances");n=b;}v("success"),m("Wallet Balances","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get balances";m("Wallet Balances","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),De=react.useCallback(n=>{navigator.clipboard.writeText(n);},[]);return Re?jsxRuntime.jsxs("div",{className:`space-y-6 ${t}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"SDK Test Console"}),f&&jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200",children:"DEMO"})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:f?"Mode d\xE9mo - Les r\xE9ponses sont simul\xE9es":`Test Pawapay SDK operations in ${h} mode`})]}),jsxRuntime.jsxs("button",{onClick:()=>Y(false),className:"h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Reconfigure"]})]}),jsxRuntime.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[jsxRuntime.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1 bg-muted p-1",children:[jsxRuntime.jsxs("button",{onClick:()=>j("deposit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="deposit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(ve,{}),"Deposit"]}),jsxRuntime.jsxs("button",{onClick:()=>j("payout"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="payout"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(ut,{}),"Payout"]}),jsxRuntime.jsxs("button",{onClick:()=>j("status"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="status"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(xe,{}),"Status"]}),jsxRuntime.jsxs("button",{onClick:()=>j("toolkit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="toolkit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(gt,{}),"Toolkit"]}),jsxRuntime.jsxs("button",{onClick:()=>j("finances"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="finances"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(yt,{}),"Finances"]})]}),E==="deposit"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Deposit"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Collect payment from a Mobile Money user"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:I,onChange:n=>ce(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:L,onChange:n=>ue(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(n=>jsxRuntime.jsx("option",{value:n.value,children:n.label},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:_,onChange:n=>de(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:he.map(n=>jsxRuntime.jsxs("option",{value:n.value,children:[n.label," (",n.country,")"]},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Customer Message (4-22 chars)"}),jsxRuntime.jsx("input",{placeholder:"Payment description",value:J,onChange:n=>Ce(n.target.value),maxLength:22,className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]})]}),jsxRuntime.jsxs("button",{onClick:Ee,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ae,{}),"Execute Deposit"]})]}),E==="payout"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Payout"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Send money to a Mobile Money account"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Recipient Phone"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:I,onChange:n=>ce(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:L,onChange:n=>ue(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(n=>jsxRuntime.jsx("option",{value:n.value,children:n.label},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:_,onChange:n=>de(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:he.map(n=>jsxRuntime.jsxs("option",{value:n.value,children:[n.label," (",n.country,")"]},n.value))})]})]}),jsxRuntime.jsxs("button",{onClick:Ae,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ae,{}),"Execute Payout"]})]}),E==="status"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Check Transaction Status"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Query the status of a transaction"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Transaction ID"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{placeholder:"Enter transaction ID (UUID)",value:O,onChange:n=>Q(n.target.value),className:"flex-1 h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring font-mono"}),O&&jsxRuntime.jsx("button",{onClick:()=>De(O),className:"w-8 h-8 border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center",title:"Copy to clipboard",children:jsxRuntime.jsx(dt,{})})]})]}),jsxRuntime.jsxs("button",{onClick:Ne,disabled:R==="loading"||!O,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(xe,{}),"Check Status"]})]})]}),E==="toolkit"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Predict Provider"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Predict the provider from a phone number"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"+237 670 000 000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("button",{onClick:Te,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ft,{}),"Predict Provider"]})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[jsxRuntime.jsxs("button",{onClick:ke,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ht,{}),"Provider Availability"]}),jsxRuntime.jsxs("button",{onClick:Oe,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Active Config"]}),jsxRuntime.jsxs("button",{onClick:Me,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(bt,{}),"Public Keys"]})]})]}),E==="finances"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Wallet Balances"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"View balances for all your wallets"})]}),jsxRuntime.jsxs("button",{onClick:Se,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ve,{}),"Get Wallet Balances"]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Statements"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate financial statements for your wallets"})]}),jsxRuntime.jsxs("div",{className:"p-4 bg-muted/50 text-xs text-muted-foreground",children:["Statement generation requires callback URL configuration. Use the SDK directly:",jsxRuntime.jsx("pre",{className:"mt-2 p-2 bg-background overflow-x-auto",children:`await sdk.finances.generateStatement({
2
+ wallet: { country: 'CMR', currency: 'XAF' },
3
+ callbackUrl: 'https://your-site.com/callback',
4
+ startDate: '2025-01-01T00:00:00Z',
5
+ endDate: '2025-01-31T23:59:59Z',
6
+ });`})]})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Results"}),ee.length>0&&jsxRuntime.jsx("button",{onClick:()=>le([]),className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]}),jsxRuntime.jsx("div",{className:"border border-border bg-background divide-y divide-border max-h-[600px] overflow-y-auto",children:ee.length===0?jsxRuntime.jsx("div",{className:"p-6 text-center text-muted-foreground text-xs",children:"No results yet. Execute an operation to see results here."}):ee.map(n=>jsxRuntime.jsxs("div",{className:"p-4 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n.status==="success"?jsxRuntime.jsx(lt,{className:"text-green-600"}):jsxRuntime.jsx(pt,{className:"text-red-600"}),jsxRuntime.jsx("span",{className:"font-medium text-sm",children:n.operation})]}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:n.timestamp})]}),n.error?jsxRuntime.jsx("p",{className:"text-xs text-red-600",children:n.error}):jsxRuntime.jsx("pre",{className:"text-xs bg-muted p-2 overflow-x-auto max-h-48",children:JSON.stringify(n.response,null,2)})]},n.id))})]})]})]}):jsxRuntime.jsxs("div",{className:`space-y-8 ${t}`,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"SDK Test Console"}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:"Configure your Pawapay SDK credentials to start testing"})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 max-w-md space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 bg-muted flex items-center justify-center",children:jsxRuntime.jsx(ne,{})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"font-semibold",children:"SDK Configuration"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your API credentials"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"API Key"}),jsxRuntime.jsx("input",{type:"password",placeholder:"pk_sandbox_...",value:p,onChange:n=>P(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Environment"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("button",{onClick:()=>se("sandbox"),className:`h-8 px-3 text-xs font-medium border transition-colors ${h==="sandbox"?"bg-primary text-primary-foreground border-primary":"bg-background border-border hover:bg-muted"}`,children:"Sandbox"}),jsxRuntime.jsx("button",{onClick:()=>se("production"),className:`h-8 px-3 text-xs font-medium border transition-colors ${h==="production"?"bg-primary text-primary-foreground border-primary":"bg-background border-border hover:bg-muted"}`,children:"Production"})]})]}),jsxRuntime.jsxs("button",{onClick:we,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ae,{}),"Initialize SDK"]}),jsxRuntime.jsxs("div",{className:"relative flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"}),jsxRuntime.jsx("span",{className:"flex-shrink mx-3 text-xs text-muted-foreground",children:"ou"}),jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"})]}),jsxRuntime.jsxs("button",{onClick:Pe,className:"w-full h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(mt,{}),"Mode D\xE9mo (sans API key)"]})]})]})]})}var ne=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),ae=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),ve=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"})}),ut=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})}),xe=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),G=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),dt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),lt=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),pt=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),mt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})}),gt=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),yt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),ft=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ht=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})}),bt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})});exports.CORRESPONDENTS=U;exports.CORRESPONDENT_INFO=F;exports.DEFAULT_LIMITS=V;exports.ERROR_CODES=x;exports.Logger=W;exports.PawapayError=l;exports.PawapayTestDashboard=ct;exports.SpaarkPayApiSdk=re;//# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map