@crediblemark/buayar 0.1.10 → 0.2.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.
package/dist/index.d.mts CHANGED
@@ -1,81 +1,181 @@
1
+ type CanonicalPaymentMethod = "bca_va" | "mandiri_va" | "bni_va" | "bri_va" | "permata_va" | "cimb_va" | "danamon_va" | "bsi_va" | "seabank_va" | "muamalat_va" | "artajasa_va" | "qris" | "gopay_qris" | "shopeepay_qris" | "nobu_qris" | "gopay" | "shopeepay" | "ovo" | "dana" | "linkaja" | "jenius" | "alfamart" | "indomaret" | "pos" | "credit_card" | "kredivo" | "akulaku" | "indodana" | string;
2
+
3
+ interface CustomerDetails {
4
+ name: string;
5
+ email: string;
6
+ phone?: string;
7
+ }
1
8
  interface CreateInvoiceParams {
2
9
  orderId: string;
3
10
  amount: number;
4
11
  productDetails: string;
5
- customer: {
6
- name: string;
7
- email: string;
8
- phone?: string;
9
- };
10
- returnUrl: string;
11
- callbackUrl: string;
12
- /** Specific Duitku payment method code (e.g. "BCA", "I1", "OV"). If omitted, all methods are available via Duitku's redirect page. */
13
- paymentMethod?: string;
14
- /** Provider-specific parameters (e.g., token_id, billing details, custom headers/fields) */
12
+ customer: CustomerDetails;
13
+ returnUrl?: string;
14
+ callbackUrl?: string;
15
+ /**
16
+ * Payment method code.
17
+ * Mendukung Canonical Code (contoh: "bca_va", "mandiri_va", "qris", "gopay", "shopeepay", "alfamart", "indomaret")
18
+ * atau kode raw spesifik provider (contoh Duitku: "BC", "M2", "SP").
19
+ * Jika dikosongkan, akan beralih ke Mode Semi Integrasi (Redirect Checkout).
20
+ */
21
+ paymentMethod?: CanonicalPaymentMethod | string;
22
+ /** Parameter kustom tambahan untuk provider spesifik (opsional) */
15
23
  providerParams?: any;
16
24
  }
25
+ interface MandiriBillInfo {
26
+ billerCode?: string;
27
+ billKey?: string;
28
+ }
17
29
  interface InvoiceResponse {
18
30
  success: boolean;
31
+ /** Provider yang memproses invoice ini ('midtrans' | 'duitku') */
32
+ provider?: string;
33
+ /** Order ID unik dari merchant */
34
+ orderId?: string;
35
+ /** Nominal transaksi */
36
+ amount?: number;
37
+ /** URL Checkout / Redirect untuk mode Semi-Integrasi */
19
38
  paymentUrl?: string;
39
+ /** Reference number dari Payment Gateway */
20
40
  reference?: string;
21
- /** Virtual Account number (for bank VA methods) */
41
+ /** Nomor Virtual Account (untuk metode Bank Transfer / VA) */
22
42
  vaNumber?: string;
23
- /** QRIS string for display in a QR code */
43
+ /** Nama Bank dari Virtual Account (misal: "bca", "bni", "bri", "mandiri", "permata") */
44
+ vaBank?: string;
45
+ /** Raw EMVCo QRIS string standar nasional untuk dirender ke Canvas / SVG QR */
24
46
  qrString?: string;
25
- /** Duitku-hosted QR code image URL */
47
+ /** URL Gambar QR Code langsung */
26
48
  qrCodeUrl?: string;
27
- /** Generic payment code (for retail/minimarket methods like Indomaret) */
49
+ /** Kode pembayaran gerai retail (Indomaret / Alfamart) */
28
50
  paymentCode?: string;
51
+ /** Deep link URL untuk membuka langsung aplikasi e-wallet (GoPay, ShopeePay, DANA) di mobile */
52
+ deeplink?: string;
53
+ /** Informasi biller khusus Mandiri E-Channel */
54
+ billInfo?: MandiriBillInfo;
55
+ /** Waktu kedaluwarsa tagihan pembayaran */
56
+ expiresAt?: Date | string;
57
+ /** Raw response asli dari API provider */
29
58
  rawResponse: any;
59
+ /** Pesan error jika gagal */
30
60
  error?: string;
31
61
  }
32
62
  interface VerifyCallbackResult {
33
63
  isValid: boolean;
64
+ provider?: string;
34
65
  orderId: string;
35
66
  amount: number;
36
- status: "paid" | "pending" | "failed";
67
+ /** Status transaksi terstandarisasi */
68
+ status: "paid" | "pending" | "failed" | "expired";
69
+ /** Boolean helper: bernilai true jika transaksi sukses terbayar */
70
+ isPaid: boolean;
71
+ /** Boolean helper: bernilai true jika transaksi masih menunggu pembayaran */
72
+ isPending: boolean;
73
+ /** Boolean helper: bernilai true jika transaksi gagal/dibatalkan */
74
+ isFailed: boolean;
75
+ /** Boolean helper: bernilai true jika transaksi telah kedaluwarsa */
76
+ isExpired: boolean;
77
+ /** Kode status asli dari provider */
78
+ statusCode?: string;
79
+ /** Waktu transaksi dicatat */
80
+ transactionTime?: Date | string;
81
+ /** Raw payload callback asli dari webhook */
37
82
  rawPayload: any;
38
83
  }
39
84
  interface ProviderConfig {
40
- merchantCode: string;
41
- apiKey: string;
42
- sandbox: boolean;
85
+ merchantCode?: string;
86
+ apiKey?: string;
87
+ sandbox?: boolean;
88
+ clientKey?: string;
89
+ serverKey?: string;
90
+ merchantId?: string;
91
+ projectId?: string;
92
+ publicKey?: string;
93
+ privateKey?: string;
94
+ secretKey?: string;
95
+ customBaseUrl?: string;
96
+ callbackUrl?: string;
97
+ returnUrl?: string;
98
+ /** Wadah konfigurasi ekstra fleksibel untuk custom provider */
99
+ extra?: Record<string, any>;
100
+ }
101
+ interface BuayarConfig extends ProviderConfig {
102
+ /**
103
+ * Nama provider aktif.
104
+ * Contoh: "midtrans" | "duitku"
105
+ * Jika tidak diisi, otomatis membaca process.env.PAYMENT_PROVIDER atau process.env.BUAYAR_PROVIDER
106
+ */
107
+ provider?: string;
43
108
  }
44
109
  interface GetPaymentMethodsParams {
45
- /** Transaction amount (integer, no decimal) */
46
- amount: number;
110
+ /** Nominal transaksi (integer) untuk menghitung fee admin dinamis */
111
+ amount?: number;
112
+ }
113
+ interface PaymentMethodItem {
114
+ /** Kode canonical Buayar, contoh: "bca_va", "qris", "gopay" */
115
+ code: string;
116
+ /** Kode asli bawaan provider, contoh: "BC", "SP", "bank_transfer" */
117
+ providerCode: string;
118
+ /** Nama metode pembayaran yang ramah pengguna, contoh: "BCA Virtual Account" */
119
+ name: string;
120
+ /** URL logo icon metode pembayaran */
121
+ image: string;
122
+ /** Biaya admin transaksi */
123
+ fee: {
124
+ flat: number;
125
+ percent: number;
126
+ totalFee: number;
127
+ };
128
+ /** Minimum & Maksimum transaksi yang diperbolehkan */
129
+ minAmount?: number;
130
+ maxAmount?: number;
131
+ /** Status ketersediaan channel */
132
+ isOnline: boolean;
133
+ /** Kategori grup untuk Accordion UI */
134
+ category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
47
135
  }
48
136
  interface PaymentMethod {
49
- /** Provider-specific method code, e.g. "BT", "I1", "OL" */
50
137
  paymentMethod: string;
51
- /** Human-readable name, e.g. "BCA Virtual Account" */
52
138
  paymentName: string;
53
- /** URL to payment method logo/image */
54
139
  paymentImage: string;
55
- /** Total transaction fee in IDR (string from API) */
56
140
  totalFee: string;
57
- /** Categorized payment channel (Virtual Account, QRIS, E-Wallet, Retail / Gerai, Kartu Kredit, Paylater / Cicilan, Lainnya) */
58
141
  category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
142
+ code?: string;
143
+ feeDetail?: {
144
+ flat: number;
145
+ percent: number;
146
+ totalFee: number;
147
+ };
59
148
  }
60
149
  interface GetPaymentMethodsResult {
61
150
  success: boolean;
151
+ provider?: string;
152
+ /** Daftar seluruh channel metode pembayaran */
62
153
  methods: PaymentMethod[];
154
+ /** Pengelompokan channel per kategori yang sudah siap dirender sebagai Accordion UI */
155
+ categories?: Record<string, PaymentMethod[]>;
63
156
  error?: string;
64
157
  rawResponse: any;
65
158
  }
66
159
  interface CheckTransactionParams {
67
- /** The merchant order ID used when creating the invoice */
160
+ /** Merchant order ID saat pembuatan transaksi */
68
161
  merchantOrderId: string;
69
162
  }
70
163
  interface CheckTransactionResult {
71
164
  success: boolean;
165
+ provider?: string;
72
166
  orderId: string;
73
167
  reference: string;
74
168
  amount: number;
75
169
  /** "00" = success/paid, "01" = pending, "02" = failed/expired */
76
170
  statusCode: string;
77
- status: "paid" | "pending" | "failed";
171
+ status: "paid" | "pending" | "failed" | "expired";
172
+ isPaid: boolean;
173
+ isPending: boolean;
174
+ isFailed: boolean;
175
+ isExpired: boolean;
78
176
  statusMessage: string;
177
+ paymentType?: string;
178
+ transactionTime?: Date | string;
79
179
  error?: string;
80
180
  rawResponse: any;
81
181
  }
@@ -94,13 +194,28 @@ declare abstract class BasePaymentProvider {
94
194
  }>;
95
195
  }
96
196
 
197
+ declare class DuitkuProvider extends BasePaymentProvider {
198
+ readonly name = "duitku";
199
+ private getBaseUrl;
200
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
201
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
202
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
203
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
204
+ probePaymentMethods(config: ProviderConfig): Promise<{
205
+ success: boolean;
206
+ enabled: string[];
207
+ error?: string;
208
+ }>;
209
+ }
210
+
97
211
  declare class MidtransClient {
98
212
  private apiKey;
99
213
  private sandbox;
100
- constructor(config: {
101
- apiKey: string;
102
- sandbox: boolean;
103
- } | ProviderConfig);
214
+ constructor(config: ProviderConfig | {
215
+ apiKey?: string;
216
+ serverKey?: string;
217
+ sandbox?: boolean;
218
+ });
104
219
  private getApiBaseUrl;
105
220
  request(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body: any): Promise<any>;
106
221
  cancelTransaction(orderId: string): Promise<any>;
@@ -140,9 +255,6 @@ declare class MidtransProvider extends BasePaymentProvider {
140
255
  verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
141
256
  getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
142
257
  checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
143
- /**
144
- * Get an instance of MidtransClient to perform transaction actions, subscriptions, invoicing, etc.
145
- */
146
258
  getClient(config: ProviderConfig): MidtransClient;
147
259
  probePaymentMethods(config: ProviderConfig): Promise<{
148
260
  success: boolean;
@@ -151,21 +263,370 @@ declare class MidtransProvider extends BasePaymentProvider {
151
263
  }>;
152
264
  }
153
265
 
154
- declare class DuitkuProvider extends BasePaymentProvider {
155
- readonly name = "duitku";
266
+ declare class IpaymuProvider extends BasePaymentProvider {
267
+ readonly name = "ipaymu";
156
268
  private getBaseUrl;
157
269
  createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
158
270
  verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
159
271
  getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
160
272
  checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
161
- probePaymentMethods(config: ProviderConfig): Promise<{
273
+ }
274
+
275
+ declare class XenditProvider extends BasePaymentProvider {
276
+ readonly name = "xendit";
277
+ private getBaseUrl;
278
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
279
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
280
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
281
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
282
+ }
283
+
284
+ declare class DokuProvider extends BasePaymentProvider {
285
+ readonly name = "doku";
286
+ private getBaseUrl;
287
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
288
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
289
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
290
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
291
+ }
292
+
293
+ declare class PrismalinkProvider extends BasePaymentProvider {
294
+ readonly name = "prismalink";
295
+ private getBaseUrl;
296
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
297
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
298
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
299
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
300
+ }
301
+
302
+ declare class FaspayProvider extends BasePaymentProvider {
303
+ readonly name = "faspay";
304
+ private getBaseUrl;
305
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
306
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
307
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
308
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
309
+ }
310
+
311
+ declare class FinpayProvider extends BasePaymentProvider {
312
+ readonly name = "finpay";
313
+ private getBaseUrl;
314
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
315
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
316
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
317
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
318
+ }
319
+
320
+ declare class NicepayProvider extends BasePaymentProvider {
321
+ readonly name = "nicepay";
322
+ private getBaseUrl;
323
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
324
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
325
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
326
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
327
+ }
328
+
329
+ declare class OyProvider extends BasePaymentProvider {
330
+ readonly name = "oy";
331
+ private getBaseUrl;
332
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
333
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
334
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
335
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
336
+ }
337
+
338
+ interface DuitkuDisbursementParams {
339
+ bankCode: string;
340
+ bankAccount: string;
341
+ amount: number;
342
+ purpose: string;
343
+ merchantOrderId: string;
344
+ senderName?: string;
345
+ senderPhone?: string;
346
+ callbackUrl?: string;
347
+ }
348
+ declare class DuitkuClient {
349
+ private merchantCode;
350
+ private apiKey;
351
+ private sandbox;
352
+ constructor(config: ProviderConfig | {
353
+ merchantCode?: string;
354
+ apiKey?: string;
355
+ sandbox?: boolean;
356
+ });
357
+ private getPassportBaseUrl;
358
+ private getApiBaseUrl;
359
+ /**
360
+ * Request helper generic dengan kalkulasi signature Duitku otomatis
361
+ */
362
+ request(method: "GET" | "POST", endpoint: string, body?: any, options?: {
363
+ baseUrl?: "passport" | "api";
364
+ customHeaders?: Record<string, string>;
365
+ }): Promise<any>;
366
+ /**
367
+ * Cek status transaksi pembayaran berdasarkan merchant order ID
368
+ */
369
+ checkTransaction(merchantOrderId: string): Promise<any>;
370
+ /**
371
+ * Ambil daftar channel pembayaran aktif dan kalkulasi fee dinamis
372
+ */
373
+ getPaymentMethods(amount?: number): Promise<any>;
374
+ /**
375
+ * Cek saldo merchant (Balance Inquiry)
376
+ */
377
+ checkBalance(): Promise<{
162
378
  success: boolean;
163
- enabled: string[];
379
+ balance?: number;
380
+ rawResponse: any;
164
381
  error?: string;
165
382
  }>;
383
+ /**
384
+ * Mengambil daftar bank yang didukung untuk transfer / penarikan dana
385
+ */
386
+ listBanks(): Promise<any>;
387
+ /**
388
+ * Validasi nama pemilik rekening bank sebelum eksekusi transfer (Bank Account Inquiry)
389
+ */
390
+ inquiryBankAccount(bankCode: string, bankAccount: string): Promise<any>;
391
+ /**
392
+ * Eksekusi transfer dana / payout (Disbursement Transfer)
393
+ */
394
+ disburse(params: DuitkuDisbursementParams): Promise<any>;
395
+ /**
396
+ * Cek status disbursement berdasarkan merchant order ID
397
+ */
398
+ checkDisbursementStatus(merchantOrderId: string): Promise<any>;
166
399
  }
167
400
 
168
- declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
401
+ declare class IpaymuClient {
402
+ private va;
403
+ private apiKey;
404
+ private sandbox;
405
+ constructor(config: ProviderConfig | {
406
+ merchantCode?: string;
407
+ merchantId?: string;
408
+ apiKey?: string;
409
+ sandbox?: boolean;
410
+ });
411
+ private getBaseUrl;
412
+ /**
413
+ * Helper request bertanda tangan iPaymu v2
414
+ */
415
+ request(method: "GET" | "POST", endpoint: string, body?: any): Promise<any>;
416
+ /**
417
+ * Cek saldo merchant iPaymu
418
+ */
419
+ checkBalance(): Promise<{
420
+ success: boolean;
421
+ balance?: number;
422
+ rawResponse: any;
423
+ error?: string;
424
+ }>;
425
+ /**
426
+ * Cek detail transaksi iPaymu
427
+ */
428
+ checkTransaction(transactionId: string): Promise<any>;
429
+ }
430
+
431
+ interface XenditDisbursementParams {
432
+ externalId: string;
433
+ bankCode: string;
434
+ accountHolderName: string;
435
+ accountNumber: string;
436
+ description: string;
437
+ amount: number;
438
+ }
439
+ declare class XenditClient {
440
+ private apiKey;
441
+ constructor(config: ProviderConfig | {
442
+ apiKey?: string;
443
+ secretKey?: string;
444
+ });
445
+ private getBaseUrl;
446
+ /**
447
+ * HTTP Request helper bertanda tangan Basic Auth Xendit
448
+ */
449
+ request(method: "GET" | "POST" | "PATCH", endpoint: string, body?: any): Promise<any>;
450
+ /**
451
+ * Cek Saldo Merchant Xendit
452
+ */
453
+ checkBalance(accountType?: "CASH" | "HOLDING" | "TAX"): Promise<{
454
+ success: boolean;
455
+ balance?: number;
456
+ rawResponse: any;
457
+ error?: string;
458
+ }>;
459
+ /**
460
+ * Memaksa sebuah invoice kadaluwarsa (Expire Invoice)
461
+ */
462
+ expireInvoice(invoiceId: string): Promise<any>;
463
+ /**
464
+ * Eksekusi transfer dana / disbursement
465
+ */
466
+ createDisbursement(params: XenditDisbursementParams): Promise<any>;
467
+ }
468
+
469
+ declare class DokuClient {
470
+ private clientId;
471
+ private secretKey;
472
+ private sandbox;
473
+ constructor(config: ProviderConfig | {
474
+ merchantCode?: string;
475
+ clientId?: string;
476
+ apiKey?: string;
477
+ secretKey?: string;
478
+ sandbox?: boolean;
479
+ });
480
+ private getBaseUrl;
481
+ /**
482
+ * Helper request bertanda tangan DOKU Jokul v2
483
+ */
484
+ request(method: "GET" | "POST", endpoint: string, body?: any): Promise<any>;
485
+ /**
486
+ * Cek status transaksi pesanan di DOKU
487
+ */
488
+ checkTransaction(invoiceNumber: string): Promise<any>;
489
+ }
490
+
491
+ declare class PrismalinkClient {
492
+ private merchantId;
493
+ private secretKey;
494
+ private sandbox;
495
+ constructor(config: ProviderConfig | {
496
+ merchantCode?: string;
497
+ merchantId?: string;
498
+ apiKey?: string;
499
+ secretKey?: string;
500
+ sandbox?: boolean;
501
+ });
502
+ private getBaseUrl;
503
+ /**
504
+ * Helper HTTP Request ke API PrismaLink
505
+ */
506
+ request(method: "GET" | "POST", endpoint: string, body?: any): Promise<any>;
507
+ /**
508
+ * Cek status transaksi pesanan di PrismaLink
509
+ */
510
+ checkTransaction(orderId: string): Promise<any>;
511
+ }
512
+
513
+ declare class FaspayClient {
514
+ private merchantId;
515
+ private userId;
516
+ private password;
517
+ private sandbox;
518
+ constructor(config: ProviderConfig | {
519
+ merchantCode?: string;
520
+ merchantId?: string;
521
+ userId?: string;
522
+ clientKey?: string;
523
+ apiKey?: string;
524
+ password?: string;
525
+ sandbox?: boolean;
526
+ });
527
+ private getBaseUrl;
528
+ /**
529
+ * Helper HTTP Request ke endpoint Faspay
530
+ */
531
+ request(endpoint: string, payload: any): Promise<any>;
532
+ /**
533
+ * Cek status pembayaran tagihan Faspay
534
+ */
535
+ checkTransaction(billNo: string): Promise<any>;
536
+ /**
537
+ * Batalkan tagihan pembayaran Faspay
538
+ */
539
+ cancelTransaction(billNo: string, paymentChannel: string): Promise<any>;
540
+ }
541
+
542
+ declare class FinpayClient {
543
+ private merchantId;
544
+ private merchantKey;
545
+ private sandbox;
546
+ constructor(config: ProviderConfig | {
547
+ merchantCode?: string;
548
+ merchantId?: string;
549
+ apiKey?: string;
550
+ serverKey?: string;
551
+ secretKey?: string;
552
+ sandbox?: boolean;
553
+ });
554
+ private getBaseUrl;
555
+ /**
556
+ * Helper HTTP Request ke Finpay API
557
+ */
558
+ request(endpoint: string, payload: any): Promise<any>;
559
+ /**
560
+ * Cek status transaksi pembayaran Finpay
561
+ */
562
+ checkTransaction(orderId: string): Promise<any>;
563
+ }
564
+
565
+ declare class NicepayClient {
566
+ private iMid;
567
+ private merchantKey;
568
+ private sandbox;
569
+ constructor(config: ProviderConfig | {
570
+ merchantCode?: string;
571
+ merchantId?: string;
572
+ iMid?: string;
573
+ apiKey?: string;
574
+ serverKey?: string;
575
+ secretKey?: string;
576
+ sandbox?: boolean;
577
+ });
578
+ private getBaseUrl;
579
+ /**
580
+ * Helper HTTP Request ke Nicepay API
581
+ */
582
+ request(endpoint: string, payload: any): Promise<any>;
583
+ /**
584
+ * Cek status transaksi pembayaran di Nicepay
585
+ */
586
+ checkTransaction(referenceNo: string, amount?: number): Promise<any>;
587
+ /**
588
+ * Batalkan transaksi di Nicepay
589
+ */
590
+ cancelTransaction(tXid: string, payMethod: string, cancelMsg?: string): Promise<any>;
591
+ }
592
+
593
+ declare class OyClient {
594
+ private username;
595
+ private apiKey;
596
+ private sandbox;
597
+ constructor(config: ProviderConfig | {
598
+ merchantCode?: string;
599
+ username?: string;
600
+ clientKey?: string;
601
+ apiKey?: string;
602
+ serverKey?: string;
603
+ secretKey?: string;
604
+ sandbox?: boolean;
605
+ });
606
+ private getBaseUrl;
607
+ /**
608
+ * Helper HTTP Request ke OY! Bisnis API
609
+ */
610
+ request(method: "GET" | "POST", endpoint: string, body?: any): Promise<any>;
611
+ /**
612
+ * Cek status transaksi pembayaran
613
+ */
614
+ checkTransaction(partnerTxId: string): Promise<any>;
615
+ /**
616
+ * Cek saldo akun OY! Bisnis
617
+ */
618
+ checkBalance(): Promise<any>;
619
+ /**
620
+ * Kirim dana / Transfer uang (Disbursement / Remittance)
621
+ */
622
+ remit(params: {
623
+ recipientBank: string;
624
+ recipientAccount: string;
625
+ amount: number;
626
+ note?: string;
627
+ partnerTrxId: string;
628
+ }): Promise<any>;
629
+ }
169
630
 
170
631
  declare class PaymentManager {
171
632
  private providers;
@@ -174,6 +635,24 @@ declare class PaymentManager {
174
635
  getProvider(name: string): BasePaymentProvider;
175
636
  getMidtransProvider(): MidtransProvider;
176
637
  getMidtransClient(config: ProviderConfig): MidtransClient;
638
+ getDuitkuProvider(): DuitkuProvider;
639
+ getDuitkuClient(config: ProviderConfig): DuitkuClient;
640
+ getIpaymuProvider(): IpaymuProvider;
641
+ getIpaymuClient(config: ProviderConfig): IpaymuClient;
642
+ getXenditProvider(): XenditProvider;
643
+ getXenditClient(config: ProviderConfig): XenditClient;
644
+ getDokuProvider(): DokuProvider;
645
+ getDokuClient(config: ProviderConfig): DokuClient;
646
+ getPrismalinkProvider(): PrismalinkProvider;
647
+ getPrismalinkClient(config: ProviderConfig): PrismalinkClient;
648
+ getFaspayProvider(): FaspayProvider;
649
+ getFaspayClient(config: ProviderConfig): FaspayClient;
650
+ getFinpayProvider(): FinpayProvider;
651
+ getFinpayClient(config: ProviderConfig): FinpayClient;
652
+ getNicepayProvider(): NicepayProvider;
653
+ getNicepayClient(config: ProviderConfig): NicepayClient;
654
+ getOyProvider(): OyProvider;
655
+ getOyClient(config: ProviderConfig): OyClient;
177
656
  createInvoice(providerName: string, params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
178
657
  verifyCallback(providerName: string, body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
179
658
  getPaymentMethods(providerName: string, params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
@@ -186,4 +665,344 @@ declare class PaymentManager {
186
665
  }
187
666
  declare const paymentManager: PaymentManager;
188
667
 
189
- export { BasePaymentProvider, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, DuitkuProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, MidtransClient, MidtransProvider, PaymentManager, type PaymentMethod, type ProviderConfig, type VerifyCallbackResult, getPaymentMethodCategory, paymentManager };
668
+ /**
669
+ * Resolver konfigurasi kredensial otomatis dari Environment Variables.
670
+ * Mendukung variabel universal Buayar / PG serta variabel spesifik masing-masing provider.
671
+ */
672
+ declare function resolveConfigFromEnv(customConfig?: BuayarConfig): BuayarConfig;
673
+
674
+ /**
675
+ * Buayar - Unified Payment Gateway Client
676
+ *
677
+ * Antarmuka tingkat tinggi untuk membuat transaksi, query channel pembayaran,
678
+ * pengecekan status, dan verifikasi webhook universal tanpa perlu rombak kode.
679
+ */
680
+ declare class Buayar {
681
+ private manager;
682
+ private config;
683
+ constructor(config?: BuayarConfig, manager?: PaymentManager);
684
+ /**
685
+ * Dapatkan salinan konfigurasi aktif saat ini
686
+ */
687
+ getConfig(): BuayarConfig;
688
+ /**
689
+ * Perbarui konfigurasi saat runtime
690
+ */
691
+ setConfig(config: Partial<BuayarConfig>): void;
692
+ /**
693
+ * Dapatkan nama provider aktif ('midtrans' | 'duitku' | 'ipaymu' | 'xendit' | 'doku' | 'prismalink' | 'faspay' | 'finpay' | 'nicepay' | 'oy' | ...)
694
+ */
695
+ get provider(): string;
696
+ /**
697
+ * Registrasi provider custom ke dalam PaymentManager
698
+ */
699
+ registerProvider(provider: BasePaymentProvider): void;
700
+ /**
701
+ * Ambil instance provider kelas dasar
702
+ */
703
+ getProvider(name?: string): BasePaymentProvider;
704
+ /**
705
+ * Buat transaksi pembayaran baru (Mendukung Semi dan Full Integrasi)
706
+ */
707
+ createInvoice(params: CreateInvoiceParams, configOverride?: Partial<ProviderConfig>): Promise<InvoiceResponse>;
708
+ /**
709
+ * Ambil daftar channel pembayaran aktif (Accordion-Ready)
710
+ */
711
+ getPaymentMethods(params?: GetPaymentMethodsParams, configOverride?: Partial<ProviderConfig>): Promise<GetPaymentMethodsResult>;
712
+ /**
713
+ * Cek status transaksi pembayaran berdasarkan Order ID
714
+ */
715
+ checkTransaction(params: CheckTransactionParams, configOverride?: Partial<ProviderConfig>): Promise<CheckTransactionResult>;
716
+ /**
717
+ * Universal Webhook Handler
718
+ *
719
+ * Memverifikasi keabsahan signature notifikasi pembayaran masuk dan menormalisasi payload menjadi format seragam.
720
+ */
721
+ verifyWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
722
+ handleWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
723
+ getMidtransClient(configOverride?: Partial<ProviderConfig>): MidtransClient;
724
+ getDuitkuClient(configOverride?: Partial<ProviderConfig>): DuitkuClient;
725
+ getIpaymuClient(configOverride?: Partial<ProviderConfig>): IpaymuClient;
726
+ getXenditClient(configOverride?: Partial<ProviderConfig>): XenditClient;
727
+ getDokuClient(configOverride?: Partial<ProviderConfig>): DokuClient;
728
+ getPrismalinkClient(configOverride?: Partial<ProviderConfig>): PrismalinkClient;
729
+ getFaspayClient(configOverride?: Partial<ProviderConfig>): FaspayClient;
730
+ getFinpayClient(configOverride?: Partial<ProviderConfig>): FinpayClient;
731
+ getNicepayClient(configOverride?: Partial<ProviderConfig>): NicepayClient;
732
+ getOyClient(configOverride?: Partial<ProviderConfig>): OyClient;
733
+ }
734
+ declare const buayar: Buayar;
735
+
736
+ /**
737
+ * Mapping dari Canonical Payment Method ke kode internal Duitku
738
+ */
739
+ declare const CANONICAL_TO_DUITKU: Record<string, string>;
740
+ /**
741
+ * Mapping dari kode internal Duitku ke Canonical Payment Method
742
+ */
743
+ declare const DUITKU_TO_CANONICAL: Record<string, string>;
744
+ /**
745
+ * Mapping dari Canonical Payment Method ke parameter charge Midtrans Core API
746
+ */
747
+ declare const CANONICAL_TO_MIDTRANS: Record<string, {
748
+ payment_type: string;
749
+ bank?: string;
750
+ }>;
751
+ /**
752
+ * Mapping dari Canonical Payment Method ke parameter direct iPaymu
753
+ */
754
+ declare const CANONICAL_TO_IPAYMU: Record<string, {
755
+ paymentMethod: string;
756
+ paymentChannel: string;
757
+ }>;
758
+ /**
759
+ * Mapping dari Canonical Payment Method ke parameter Payment Requests API Xendit
760
+ */
761
+ declare const CANONICAL_TO_XENDIT: Record<string, {
762
+ type: string;
763
+ channel_code?: string;
764
+ }>;
765
+ /**
766
+ * Mapping dari Canonical Payment Method ke endpoint Direct DOKU Jokul
767
+ */
768
+ declare const CANONICAL_TO_DOKU: Record<string, {
769
+ endpoint: string;
770
+ type: "va" | "qris" | "cstore" | "ewallet";
771
+ bank?: string;
772
+ }>;
773
+ /**
774
+ * Mapping dari Canonical Payment Method ke kode channel PrismaLink
775
+ */
776
+ declare const CANONICAL_TO_PRISMALINK: Record<string, string>;
777
+ /**
778
+ * Mapping dari Canonical Payment Method ke kode channel Faspay
779
+ */
780
+ declare const CANONICAL_TO_FASPAY: Record<string, string>;
781
+ /**
782
+ * Mapping dari Canonical Payment Method ke kode channel Finpay
783
+ */
784
+ declare const CANONICAL_TO_FINPAY: Record<string, string>;
785
+ /**
786
+ * Mapping dari Canonical Payment Method ke konfigurasi Nicepay
787
+ */
788
+ declare const CANONICAL_TO_NICEPAY: Record<string, {
789
+ payMethod: string;
790
+ bankCd?: string;
791
+ mitraCd?: string;
792
+ }>;
793
+ /**
794
+ * Mapping dari Canonical Payment Method ke konfigurasi OY! Bisnis
795
+ */
796
+ declare const CANONICAL_TO_OY: Record<string, {
797
+ type: "va" | "qris" | "ewallet" | "cstore";
798
+ bank_code?: string;
799
+ channel?: string;
800
+ }>;
801
+ /**
802
+ * Ubah method code apapun (baik canonical maupun kode raw provider) ke kode Duitku yang valid
803
+ */
804
+ declare function toDuitkuPaymentMethod(code?: string): string | undefined;
805
+ /**
806
+ * Ubah method code apapun ke format iPaymu direct channel
807
+ */
808
+ declare function toIpaymuPaymentMethod(code?: string): {
809
+ paymentMethod: string;
810
+ paymentChannel?: string;
811
+ } | undefined;
812
+ /**
813
+ * Ubah method code apapun ke format Payment Request Xendit
814
+ */
815
+ declare function toXenditPaymentMethod(code?: string): {
816
+ type: string;
817
+ channel_code?: string;
818
+ } | undefined;
819
+ /**
820
+ * Ubah method code apapun ke format Direct API DOKU Jokul
821
+ */
822
+ declare function toDokuPaymentMethod(code?: string): {
823
+ endpoint: string;
824
+ type: "va" | "qris" | "cstore" | "ewallet";
825
+ bank?: string;
826
+ } | undefined;
827
+ /**
828
+ * Ubah method code apapun ke format channel PrismaLink
829
+ */
830
+ declare function toPrismalinkPaymentMethod(code?: string): string | undefined;
831
+ /**
832
+ * Ubah method code apapun ke format payment channel Faspay
833
+ */
834
+ declare function toFaspayPaymentMethod(code?: string): string | undefined;
835
+ /**
836
+ * Ubah method code apapun ke format channel Finpay
837
+ */
838
+ declare function toFinpayPaymentMethod(code?: string): string | undefined;
839
+ /**
840
+ * Ubah method code apapun ke format Nicepay
841
+ */
842
+ declare function toNicepayPaymentMethod(code?: string): {
843
+ payMethod: string;
844
+ bankCd?: string;
845
+ mitraCd?: string;
846
+ } | undefined;
847
+ /**
848
+ * Ubah method code apapun ke format OY! Bisnis
849
+ */
850
+ declare function toOyPaymentMethod(code?: string): {
851
+ type: "va" | "qris" | "ewallet" | "cstore";
852
+ bank_code?: string;
853
+ channel?: string;
854
+ } | undefined;
855
+ /**
856
+ * Ubah method code apapun ke format canonical standar Buayar
857
+ */
858
+ declare function toCanonicalPaymentMethod(provider: string, code?: string): string;
859
+
860
+ declare function getDuitkuInquirySignatures(merchantCode: string, orderId: string, amount: number, apiKey: string): {
861
+ payloadSignature: string;
862
+ timestamp: string;
863
+ headerSignature: string;
864
+ };
865
+ declare function verifyDuitkuCallbackSignature(body: any, apiKey: string): boolean;
866
+ declare function getDuitkuPaymentMethodsSignature(merchantCode: string, amount: number, datetime: string, apiKey: string): string;
867
+ declare function getDuitkuStatusSignatures(merchantCode: string, orderId: string, apiKey: string): {
868
+ timestamp: string;
869
+ headerSignature: string;
870
+ bodySignature: string;
871
+ };
872
+
873
+ declare const CORE_API_METHODS: string[];
874
+ declare function buildCoreChargePayload(method: string, params: CreateInvoiceParams, config: ProviderConfig, integerAmount: number): {
875
+ payload?: any;
876
+ error?: string;
877
+ };
878
+ declare function parseCoreChargeResponse(method: string, data: any, orderId: string, integerAmount: number): InvoiceResponse;
879
+
880
+ declare const MIDTRANS_STATIC_METHODS: PaymentMethod[];
881
+ declare const MIDTRANS_PROBE_PAYLOADS: Record<string, any>;
882
+
883
+ /**
884
+ * Generate signature for iPaymu API v2 requests
885
+ *
886
+ * Signature formula:
887
+ * stringToSign = HTTP_METHOD + ":" + VA + ":" + SHA256(RAW_BODY).toLowerCase() + ":" + API_KEY
888
+ * signature = HMAC_SHA256(stringToSign, API_KEY)
889
+ */
890
+ declare function generateIpaymuSignature(method: "GET" | "POST", va: string, apiKey: string, body?: any): {
891
+ signature: string;
892
+ timestamp: string;
893
+ };
894
+ /**
895
+ * Verifikasi callback webhook dari iPaymu
896
+ */
897
+ declare function verifyIpaymuCallback(payload: any): {
898
+ isPaid: boolean;
899
+ isPending: boolean;
900
+ isFailed: boolean;
901
+ };
902
+
903
+ /**
904
+ * Buat Basic Auth Header untuk API Xendit (Secret API Key + ":")
905
+ */
906
+ declare function getXenditAuthHeader(secretKey: string): string;
907
+ /**
908
+ * Verifikasi webhook callback token dari header x-callback-token Xendit
909
+ */
910
+ declare function verifyXenditWebhookToken(headerToken?: string, expectedToken?: string): boolean;
911
+
912
+ /**
913
+ * Generate DOKU Jokul v2 Request Headers & Signature
914
+ *
915
+ * Digest = Base64(SHA256(RAW_BODY))
916
+ * ComponentSignature = Client-Id:{clientId}\nRequest-Id:{requestId}\nRequest-Timestamp:{timestamp}\nRequest-Target:{requestTarget}\nDigest:{digest}
917
+ * Signature = "HMACSHA256=" + Base64(HMAC_SHA256(ComponentSignature, secretKey))
918
+ */
919
+ declare function generateDokuHeaders(clientId: string, secretKey: string, requestTarget: string, body?: any, customRequestId?: string): {
920
+ "Client-Id": string;
921
+ "Request-Id": string;
922
+ "Request-Timestamp": string;
923
+ "Signature": string;
924
+ "Digest"?: string;
925
+ };
926
+ /**
927
+ * Verifikasi webhook signature DOKU Jokul
928
+ */
929
+ declare function verifyDokuWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientId: string, secretKey: string, requestTarget?: string): boolean;
930
+
931
+ /**
932
+ * Generate signature PrismaLink
933
+ *
934
+ * Signature formula: SHA256(merchantId + orderId + amount + secretKey)
935
+ */
936
+ declare function generatePrismalinkSignature(merchantId: string, orderId: string, amount: number, secretKey: string): string;
937
+ /**
938
+ * Verifikasi webhook signature dari callback PrismaLink
939
+ */
940
+ declare function verifyPrismalinkSignature(merchantId: string, orderId: string, amount: number, secretKey: string, incomingSignature: string): boolean;
941
+
942
+ /**
943
+ * Generate signature Faspay (SHA1(MD5(username + password + bill_no)))
944
+ */
945
+ declare function generateFaspaySignature(userId: string, password: string, billNo: string): string;
946
+ /**
947
+ * Verifikasi callback webhook notification Faspay
948
+ */
949
+ declare function verifyFaspaySignature(userId: string, password: string, billNo: string, paymentStatusCode: string, incomingSignature: string): boolean;
950
+
951
+ /**
952
+ * Generate signature Finpay HMAC-SHA512
953
+ */
954
+ declare function generateFinpaySignature(merchantId: string, orderId: string, amount: number, merchantKey: string): string;
955
+ /**
956
+ * Verifikasi webhook signature notifikasi Finpay
957
+ */
958
+ declare function verifyFinpaySignature(merchantId: string, orderId: string, amount: number, merchantKey: string, incomingSignature: string): boolean;
959
+
960
+ /**
961
+ * Format date ke format Nicepay: YYYYMMDDHHmmss (14 karakter)
962
+ */
963
+ declare function formatNicepayTimestamp(date?: Date): string;
964
+ /**
965
+ * Generate merchantToken Nicepay: SHA256(timeStamp + iMid + referenceNo + amt + merchantKey)
966
+ */
967
+ declare function generateNicepayToken(timeStamp: string, iMid: string, referenceNo: string, amt: number | string, merchantKey: string): string;
968
+ /**
969
+ * Verifikasi webhook callback signature dari dbProcessUrl Nicepay
970
+ */
971
+ declare function verifyNicepayWebhook(timeStamp: string, iMid: string, referenceNo: string, amt: number | string, merchantKey: string, incomingToken: string): boolean;
972
+
973
+ /**
974
+ * Generate header autentikasi OY! Bisnis
975
+ */
976
+ declare function generateOyHeaders(username: string, apiKey: string): Record<string, string>;
977
+ /**
978
+ * Verifikasi webhook callback OY! Bisnis
979
+ */
980
+ declare function verifyOyWebhook(headers: Record<string, string | string[] | undefined>, expectedUsername: string): boolean;
981
+
982
+ /**
983
+ * Generate MD5 hash string (lowercase)
984
+ */
985
+ declare function md5(data: string): string;
986
+ /**
987
+ * Generate SHA-256 hash string (lowercase)
988
+ */
989
+ declare function sha256(data: string): string;
990
+ /**
991
+ * Generate SHA-512 hash string (lowercase)
992
+ */
993
+ declare function sha512(data: string): string;
994
+ /**
995
+ * Generate HMAC-SHA256 hash string (lowercase)
996
+ */
997
+ declare function hmacSha256(data: string, secret: string): string;
998
+ /**
999
+ * Timing-safe string comparison to prevent timing attacks on signatures
1000
+ */
1001
+ declare function safeCompare(a: string, b: string): boolean;
1002
+
1003
+ /**
1004
+ * Helper to categorize raw payment method code & name into unified accordion ready groups
1005
+ */
1006
+ declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
1007
+
1008
+ export { BasePaymentProvider, Buayar, type BuayarConfig, CANONICAL_TO_DOKU, CANONICAL_TO_DUITKU, CANONICAL_TO_FASPAY, CANONICAL_TO_FINPAY, CANONICAL_TO_IPAYMU, CANONICAL_TO_MIDTRANS, CANONICAL_TO_NICEPAY, CANONICAL_TO_OY, CANONICAL_TO_PRISMALINK, CANONICAL_TO_XENDIT, CORE_API_METHODS, type CanonicalPaymentMethod, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, type CustomerDetails, DUITKU_TO_CANONICAL, DokuClient, DokuProvider, DuitkuClient, type DuitkuDisbursementParams, DuitkuProvider, FaspayClient, FaspayProvider, FinpayClient, FinpayProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, IpaymuClient, IpaymuProvider, MIDTRANS_PROBE_PAYLOADS, MIDTRANS_STATIC_METHODS, type MandiriBillInfo, MidtransClient, MidtransProvider, NicepayClient, NicepayProvider, OyClient, OyProvider, PaymentManager, type PaymentMethod, type PaymentMethodItem, PrismalinkClient, PrismalinkProvider, type ProviderConfig, type VerifyCallbackResult, XenditClient, type XenditDisbursementParams, XenditProvider, buayar, buildCoreChargePayload, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, sha256, sha512, toCanonicalPaymentMethod, toDokuPaymentMethod, toDuitkuPaymentMethod, toFaspayPaymentMethod, toFinpayPaymentMethod, toIpaymuPaymentMethod, toNicepayPaymentMethod, toOyPaymentMethod, toPrismalinkPaymentMethod, toXenditPaymentMethod, verifyDokuWebhookSignature, verifyDuitkuCallbackSignature, verifyFaspaySignature, verifyFinpaySignature, verifyIpaymuCallback, verifyNicepayWebhook, verifyOyWebhook, verifyPrismalinkSignature, verifyXenditWebhookToken };