@crediblemark/buayar 0.6.2 → 0.8.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,4 +1,4 @@
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;
1
+ type CanonicalPaymentMethod = "bca_va" | "mandiri_va" | "bni_va" | "bri_va" | "permata_va" | "cimb_va" | "danamon_va" | "bsi_va" | "seabank_va" | "muamalat_va" | "bag_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
2
 
3
3
  interface CustomerDetails {
4
4
  name: string;
@@ -24,8 +24,34 @@ interface CreateInvoiceParams {
24
24
  * Contoh: 'idr', 'usd', 'sgd'
25
25
  */
26
26
  currency?: string;
27
+ /**
28
+ * Pilihan pembebanan biaya transaksi (didukung iPaymu dll).
29
+ * 'MERCHANT' = biaya transaksi dipotong dari omset merchant (default).
30
+ * 'BUYER' = biaya transaksi ditambahkan ke total tagihan pembeli.
31
+ */
32
+ feeDirection?: "MERCHANT" | "BUYER";
33
+ /**
34
+ * Mengaktifkan sistem Escrow (Rekening Bersama) jika didukung provider.
35
+ */
36
+ escrow?: boolean;
37
+ /**
38
+ * Rincian item produk (opsional, untuk multi-item cart / logistik).
39
+ */
40
+ items?: Array<{
41
+ id?: string;
42
+ name: string;
43
+ price: number;
44
+ quantity: number;
45
+ description?: string;
46
+ weight?: number;
47
+ length?: number;
48
+ width?: number;
49
+ height?: number;
50
+ }>;
27
51
  /** Parameter kustom tambahan untuk provider spesifik (opsional) */
28
52
  providerParams?: any;
53
+ /** Konfigurasi atau data kustom tambahan untuk provider (opsional) */
54
+ extra?: Record<string, any>;
29
55
  }
30
56
  interface MandiriBillInfo {
31
57
  billerCode?: string;
@@ -33,7 +59,7 @@ interface MandiriBillInfo {
33
59
  }
34
60
  interface InvoiceResponse {
35
61
  success: boolean;
36
- /** Provider yang memproses invoice ini ('midtrans' | 'duitku') */
62
+ /** Provider yang memproses invoice ini ('midtrans' | 'duitku' | 'doku' ...) */
37
63
  provider?: string;
38
64
  /** Order ID unik dari merchant */
39
65
  orderId?: string;
@@ -43,6 +69,8 @@ interface InvoiceResponse {
43
69
  paymentUrl?: string;
44
70
  /** Reference number dari Payment Gateway */
45
71
  reference?: string;
72
+ /** Dimensi hasil kanal spesifik (VA / QRIS / e-Wallet / Checkout) untuk typing strict. */
73
+ mode?: PaymentMode;
46
74
  /** Nomor Virtual Account (untuk metode Bank Transfer / VA) */
47
75
  vaNumber?: string;
48
76
  /** Nama Bank dari Virtual Account (misal: "bca", "bni", "bri", "mandiri", "permata") */
@@ -59,11 +87,32 @@ interface InvoiceResponse {
59
87
  billInfo?: MandiriBillInfo;
60
88
  /** Waktu kedaluwarsa tagihan pembayaran */
61
89
  expiresAt?: Date | string;
62
- /** Raw response asli dari API provider */
90
+ /** Raw response asli dari API provider (termasuk saat gagal) */
63
91
  rawResponse: any;
64
92
  /** Pesan error jika gagal */
65
93
  error?: string;
66
94
  }
95
+ /** Kanal pembayaran hasil invoice — membantu typing strict dan rendering UI. */
96
+ type PaymentMode = "checkout" | "va" | "qris" | "ewallet" | "retail" | "other";
97
+ /** Hasil invoice khusus Virtual Account (mode === 'va'). */
98
+ interface VirtualAccountResponse extends InvoiceResponse {
99
+ mode: "va";
100
+ vaNumber: string;
101
+ vaBank?: string;
102
+ }
103
+ /** Hasil invoice khusus QRIS (mode === 'qris'). */
104
+ interface QrisResponse extends InvoiceResponse {
105
+ mode: "qris";
106
+ qrString: string;
107
+ qrCodeUrl?: string;
108
+ }
109
+ /** Hasil invoice khusus e-Wallet (mode === 'ewallet'). */
110
+ interface EWalletResponse extends InvoiceResponse {
111
+ mode: "ewallet";
112
+ checkoutUrl?: string;
113
+ paymentUrl?: string;
114
+ deeplink?: string;
115
+ }
67
116
  interface VerifyCallbackResult {
68
117
  isValid: boolean;
69
118
  provider?: string;
@@ -136,15 +185,16 @@ interface PaymentMethodItem {
136
185
  /** Status ketersediaan channel */
137
186
  isOnline: boolean;
138
187
  /** Kategori grup untuk Accordion UI */
139
- category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
188
+ category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya" | string;
140
189
  }
141
190
  interface PaymentMethod {
142
191
  paymentMethod: string;
143
192
  paymentName: string;
144
193
  paymentImage: string;
145
194
  totalFee: string;
146
- category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
195
+ category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya" | string;
147
196
  code?: string;
197
+ extra?: any;
148
198
  feeDetail?: {
149
199
  flat: number;
150
200
  percent: number;
@@ -605,7 +655,55 @@ declare class IpaymuClient {
605
655
  /**
606
656
  * Cek detail transaksi iPaymu
607
657
  */
608
- checkTransaction(transactionId: string): Promise<any>;
658
+ checkTransaction(transactionId: string | number): Promise<any>;
659
+ /**
660
+ * Ambil daftar channel pembayaran aktif milik merchant
661
+ */
662
+ getPaymentMethods(): Promise<any>;
663
+ /**
664
+ * Ambil riwayat transaksi merchant berpaginasi
665
+ */
666
+ getHistory(params?: {
667
+ page?: number;
668
+ limit?: number;
669
+ status?: number;
670
+ date?: string;
671
+ start_date?: string;
672
+ end_date?: string;
673
+ bulkId?: string[];
674
+ }): Promise<any>;
675
+ /**
676
+ * Ambil daftar seluruh bank di Indonesia
677
+ */
678
+ getBankList(): Promise<any>;
679
+ /**
680
+ * Ambil jangkauan area pengiriman COD
681
+ */
682
+ getCodArea(postalCode?: string): Promise<any>;
683
+ /**
684
+ * Hitung tarif ongkir pengiriman COD
685
+ */
686
+ getCodRate(params: {
687
+ pickupArea: string;
688
+ deliveryArea: string;
689
+ weight: number;
690
+ height?: number;
691
+ length?: number;
692
+ width?: number;
693
+ [key: string]: any;
694
+ }): Promise<any>;
695
+ /**
696
+ * Request pickup kurir COD
697
+ */
698
+ getCodPickup(params: any): Promise<any>;
699
+ /**
700
+ * Ambil nomor resi / AWB pengiriman COD
701
+ */
702
+ getCodAwb(transactionId: string | number): Promise<any>;
703
+ /**
704
+ * Lacak status pengiriman kurir berdasarkan no resi / AWB
705
+ */
706
+ getCodTracking(awb: string): Promise<any>;
609
707
  }
610
708
 
611
709
  interface XenditDisbursementParams {
@@ -1026,10 +1124,52 @@ declare class PaymentManager {
1026
1124
  }
1027
1125
  declare const paymentManager: PaymentManager;
1028
1126
 
1127
+ interface ProviderCapability {
1128
+ /** Metode pembayaran kanonik yang didukung provider ini */
1129
+ methods: string[];
1130
+ /** Operasi lanjutan yang didukung */
1131
+ operations: {
1132
+ refund: boolean;
1133
+ checkBalance: boolean;
1134
+ disburse: boolean;
1135
+ };
1136
+ }
1137
+ interface ProviderDescriptor extends ProviderCapability {
1138
+ name: string;
1139
+ /** Kunci env kredensial yang menandakan provider ini aktif (untuk autodetect) */
1140
+ envKeys: string[];
1141
+ }
1029
1142
  /**
1030
- * Resolver konfigurasi kredensial otomatis dari Environment Variables.
1031
- * Mendukung variabel universal Buayar / PG serta variabel spesifik masing-masing provider.
1032
- */
1143
+ * Pendeteksi / registrar provider dinamis.
1144
+ * Metadata provider terpusat di sini sehingga:
1145
+ * - Daftar provider bisa ditambah tanpa ubah core (register(...)).
1146
+ * - Provider aktif bisa di-autodetect dari kredensial .env.
1147
+ * - Provider pengirim webhook bisa ditebak dari struktur payload.
1148
+ * - Capability (metode + operasi) bisa di-query secara runtime.
1149
+ */
1150
+ declare class ProviderRegistry {
1151
+ private descriptors;
1152
+ constructor(initial?: ProviderDescriptor[]);
1153
+ register(desc: ProviderDescriptor): void;
1154
+ unregister(name: string): boolean;
1155
+ has(name: string): boolean;
1156
+ get(name: string): ProviderDescriptor | undefined;
1157
+ names(): string[];
1158
+ /**
1159
+ * Autodetect provider aktif dari variabel lingkungan.
1160
+ * Mengembalikan nama provider yang kredensial .env-nya terisi penuh,
1161
+ * atau undefined jika tidak ada / ambigu.
1162
+ */
1163
+ detectFromEnv(env: Record<string, string | undefined>): string | undefined;
1164
+ /**
1165
+ * Autodetect provider dari struktur payload webhook.
1166
+ * Mengembalikan nama provider jika dikenali, else undefined.
1167
+ */
1168
+ detectFromWebhook(payload: any): string | undefined;
1169
+ }
1170
+ declare function buildDefaultDescriptors(): ProviderDescriptor[];
1171
+ declare const providerRegistry: ProviderRegistry;
1172
+
1033
1173
  declare function resolveConfigFromEnv(customConfig?: BuayarConfig): BuayarConfig;
1034
1174
 
1035
1175
  /**
@@ -1045,7 +1185,8 @@ declare function resolveConfigFromEnv(customConfig?: BuayarConfig): BuayarConfig
1045
1185
  declare class Buayar {
1046
1186
  private manager;
1047
1187
  private config;
1048
- constructor(config?: BuayarConfig, manager?: PaymentManager);
1188
+ private registry;
1189
+ constructor(config?: BuayarConfig, manager?: PaymentManager, registry?: ProviderRegistry);
1049
1190
  /**
1050
1191
  * Dapatkan salinan konfigurasi aktif saat ini
1051
1192
  */
@@ -1066,6 +1207,40 @@ declare class Buayar {
1066
1207
  * Ambil instance provider kelas dasar
1067
1208
  */
1068
1209
  getProvider(name?: string): BasePaymentProvider;
1210
+ /**
1211
+ * Daftar nama provider yang terdaftar (bawaan + kustom).
1212
+ */
1213
+ listProviders(): string[];
1214
+ /**
1215
+ * Registrasi metadata provider kustom untuk deteksi & capability.
1216
+ * Contoh: buayar.registerProviderDescriptor({ name, envKeys, methods, operations })
1217
+ */
1218
+ registerProviderDescriptor(desc: ProviderDescriptor): void;
1219
+ /**
1220
+ * Cek capability (metode + operasi) provider tertentu — atau provider aktif bila kosong.
1221
+ * Jawab pertanyaan "provider ini dukung apa?" secara runtime, tanpa bongkar dokumen.
1222
+ */
1223
+ getCapabilities(name?: string): ProviderCapability | undefined;
1224
+ /**
1225
+ * Deteksi nama provider dari struktur payload webhook.
1226
+ */
1227
+ detectProviderFromPayload(payload: any): string | undefined;
1228
+ /**
1229
+ * Deteksi nama provider aktif dari variabel lingkungan (kredensial yang terisi).
1230
+ */
1231
+ detectProviderFromEnv(env?: Record<string, string | undefined>): string | undefined;
1232
+ /**
1233
+ * Logika "bisa pakai X dengan provider Y?" — helper untuk portabilitas.
1234
+ */
1235
+ supports(name: string, operation: "refund" | "checkBalance" | "disburse"): boolean;
1236
+ /**
1237
+ * Daftar metode pembayaran yang benar2 tersedia untuk provider aktif.
1238
+ */
1239
+ getSupportedMethods(name?: string): string[];
1240
+ /**
1241
+ * Iterasi CEPAT: apakah provider aktif mendukung method kanonik tertentu?
1242
+ */
1243
+ supportsMethod(method: string, name?: string): boolean;
1069
1244
  /**
1070
1245
  * Buat transaksi pembayaran baru (Mendukung Semi dan Full Integrasi)
1071
1246
  */
@@ -1391,6 +1566,11 @@ declare function snapExternalId(prefix?: string): string;
1391
1566
  * @returns true when the X-SIGNATURE matches.
1392
1567
  */
1393
1568
  declare function verifySnapWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientSecret: string, endpointUrl?: string): boolean;
1569
+ /**
1570
+ * Map a DOKU SNAP error (responseMessage/responseCode) to an actionable hint
1571
+ * for developers, so config gaps (missing BIN / merchantId / keys) are obvious.
1572
+ */
1573
+ declare function snapErrorHint(message: string, code?: string): string | undefined;
1394
1574
 
1395
1575
  /**
1396
1576
  * Generate signature PrismaLink
@@ -1585,6 +1765,21 @@ declare class SnapClient {
1585
1765
  extraHeaders?: Record<string, string>;
1586
1766
  }): Promise<any>;
1587
1767
  }
1768
+ /** DOKU SNAP API error with structured diagnostics (status code + raw response). */
1769
+ declare class SnapApiError extends Error {
1770
+ readonly status: number;
1771
+ readonly responseCode?: string;
1772
+ readonly raw: any;
1773
+ readonly endpoint?: string;
1774
+ readonly method?: string;
1775
+ constructor(message: string, opts: {
1776
+ status: number;
1777
+ code?: string;
1778
+ raw?: any;
1779
+ endpoint?: string;
1780
+ method?: string;
1781
+ });
1782
+ }
1588
1783
 
1589
1784
  /**
1590
1785
  * Generate MD5 hash string (lowercase)
@@ -1615,4 +1810,4 @@ declare function safeCompare(a: string, b: string): boolean;
1615
1810
  */
1616
1811
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
1617
1812
 
1618
- export { AdyenClient, AdyenProvider, BasePaymentProvider, BraintreeClient, BraintreeProvider, 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_STRIPE, CANONICAL_TO_XENDIT, CORE_API_METHODS, type CanonicalPaymentMethod, type CheckBalanceResult, type CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, type CreateInvoiceParams, type CustomerDetails, DUITKU_TO_CANONICAL, type DisburseParams, type DisburseResult, 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, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderConfig, RazorpayClient, RazorpayProvider, type RefundParams, type RefundResult, SnapClient, type SnapClientOptions, SquareClient, SquareProvider, StripeClient, StripeProvider, TwoCheckoutClient, TwoCheckoutProvider, type VerifyCallbackResult, XenditClient, type XenditDisbursementParams, XenditProvider, buayar, buildBraintreeBasicAuth, buildCoreChargePayload, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha256Hex, sha512, snapExternalId, snapTimestamp, snapUtcTimestamp, toCanonicalPaymentMethod, toDokuPaymentMethod, toDuitkuPaymentMethod, toFaspayPaymentMethod, toFinpayPaymentMethod, toIpaymuPaymentMethod, toNicepayPaymentMethod, toOyPaymentMethod, toPrismalinkPaymentMethod, toStripePaymentMethod, toXenditPaymentMethod, verifyAdyenWebhook, verifyBraintreeWebhook, verifyCheckoutComWebhook, verifyDokuWebhookSignature, verifyDuitkuCallbackSignature, verifyFaspaySignature, verifyFinpaySignature, verifyIpaymuCallback, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
1813
+ export { AdyenClient, AdyenProvider, BasePaymentProvider, BraintreeClient, BraintreeProvider, 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_STRIPE, CANONICAL_TO_XENDIT, CORE_API_METHODS, type CanonicalPaymentMethod, type CheckBalanceResult, type CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, type CreateInvoiceParams, type CustomerDetails, DUITKU_TO_CANONICAL, type DisburseParams, type DisburseResult, DokuClient, DokuProvider, DuitkuClient, type DuitkuDisbursementParams, DuitkuProvider, type EWalletResponse, 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, type PaymentMode, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderCapability, type ProviderConfig, type ProviderDescriptor, ProviderRegistry, type QrisResponse, RazorpayClient, RazorpayProvider, type RefundParams, type RefundResult, SnapApiError, SnapClient, type SnapClientOptions, SquareClient, SquareProvider, StripeClient, StripeProvider, TwoCheckoutClient, TwoCheckoutProvider, type VerifyCallbackResult, type VirtualAccountResponse, XenditClient, type XenditDisbursementParams, XenditProvider, buayar, buildBraintreeBasicAuth, buildCoreChargePayload, buildDefaultDescriptors, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, parseCoreChargeResponse, paymentManager, providerRegistry, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha256Hex, sha512, snapErrorHint, snapExternalId, snapTimestamp, snapUtcTimestamp, toCanonicalPaymentMethod, toDokuPaymentMethod, toDuitkuPaymentMethod, toFaspayPaymentMethod, toFinpayPaymentMethod, toIpaymuPaymentMethod, toNicepayPaymentMethod, toOyPaymentMethod, toPrismalinkPaymentMethod, toStripePaymentMethod, toXenditPaymentMethod, verifyAdyenWebhook, verifyBraintreeWebhook, verifyCheckoutComWebhook, verifyDokuWebhookSignature, verifyDuitkuCallbackSignature, verifyFaspaySignature, verifyFinpaySignature, verifyIpaymuCallback, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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;
1
+ type CanonicalPaymentMethod = "bca_va" | "mandiri_va" | "bni_va" | "bri_va" | "permata_va" | "cimb_va" | "danamon_va" | "bsi_va" | "seabank_va" | "muamalat_va" | "bag_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
2
 
3
3
  interface CustomerDetails {
4
4
  name: string;
@@ -24,8 +24,34 @@ interface CreateInvoiceParams {
24
24
  * Contoh: 'idr', 'usd', 'sgd'
25
25
  */
26
26
  currency?: string;
27
+ /**
28
+ * Pilihan pembebanan biaya transaksi (didukung iPaymu dll).
29
+ * 'MERCHANT' = biaya transaksi dipotong dari omset merchant (default).
30
+ * 'BUYER' = biaya transaksi ditambahkan ke total tagihan pembeli.
31
+ */
32
+ feeDirection?: "MERCHANT" | "BUYER";
33
+ /**
34
+ * Mengaktifkan sistem Escrow (Rekening Bersama) jika didukung provider.
35
+ */
36
+ escrow?: boolean;
37
+ /**
38
+ * Rincian item produk (opsional, untuk multi-item cart / logistik).
39
+ */
40
+ items?: Array<{
41
+ id?: string;
42
+ name: string;
43
+ price: number;
44
+ quantity: number;
45
+ description?: string;
46
+ weight?: number;
47
+ length?: number;
48
+ width?: number;
49
+ height?: number;
50
+ }>;
27
51
  /** Parameter kustom tambahan untuk provider spesifik (opsional) */
28
52
  providerParams?: any;
53
+ /** Konfigurasi atau data kustom tambahan untuk provider (opsional) */
54
+ extra?: Record<string, any>;
29
55
  }
30
56
  interface MandiriBillInfo {
31
57
  billerCode?: string;
@@ -33,7 +59,7 @@ interface MandiriBillInfo {
33
59
  }
34
60
  interface InvoiceResponse {
35
61
  success: boolean;
36
- /** Provider yang memproses invoice ini ('midtrans' | 'duitku') */
62
+ /** Provider yang memproses invoice ini ('midtrans' | 'duitku' | 'doku' ...) */
37
63
  provider?: string;
38
64
  /** Order ID unik dari merchant */
39
65
  orderId?: string;
@@ -43,6 +69,8 @@ interface InvoiceResponse {
43
69
  paymentUrl?: string;
44
70
  /** Reference number dari Payment Gateway */
45
71
  reference?: string;
72
+ /** Dimensi hasil kanal spesifik (VA / QRIS / e-Wallet / Checkout) untuk typing strict. */
73
+ mode?: PaymentMode;
46
74
  /** Nomor Virtual Account (untuk metode Bank Transfer / VA) */
47
75
  vaNumber?: string;
48
76
  /** Nama Bank dari Virtual Account (misal: "bca", "bni", "bri", "mandiri", "permata") */
@@ -59,11 +87,32 @@ interface InvoiceResponse {
59
87
  billInfo?: MandiriBillInfo;
60
88
  /** Waktu kedaluwarsa tagihan pembayaran */
61
89
  expiresAt?: Date | string;
62
- /** Raw response asli dari API provider */
90
+ /** Raw response asli dari API provider (termasuk saat gagal) */
63
91
  rawResponse: any;
64
92
  /** Pesan error jika gagal */
65
93
  error?: string;
66
94
  }
95
+ /** Kanal pembayaran hasil invoice — membantu typing strict dan rendering UI. */
96
+ type PaymentMode = "checkout" | "va" | "qris" | "ewallet" | "retail" | "other";
97
+ /** Hasil invoice khusus Virtual Account (mode === 'va'). */
98
+ interface VirtualAccountResponse extends InvoiceResponse {
99
+ mode: "va";
100
+ vaNumber: string;
101
+ vaBank?: string;
102
+ }
103
+ /** Hasil invoice khusus QRIS (mode === 'qris'). */
104
+ interface QrisResponse extends InvoiceResponse {
105
+ mode: "qris";
106
+ qrString: string;
107
+ qrCodeUrl?: string;
108
+ }
109
+ /** Hasil invoice khusus e-Wallet (mode === 'ewallet'). */
110
+ interface EWalletResponse extends InvoiceResponse {
111
+ mode: "ewallet";
112
+ checkoutUrl?: string;
113
+ paymentUrl?: string;
114
+ deeplink?: string;
115
+ }
67
116
  interface VerifyCallbackResult {
68
117
  isValid: boolean;
69
118
  provider?: string;
@@ -136,15 +185,16 @@ interface PaymentMethodItem {
136
185
  /** Status ketersediaan channel */
137
186
  isOnline: boolean;
138
187
  /** Kategori grup untuk Accordion UI */
139
- category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
188
+ category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya" | string;
140
189
  }
141
190
  interface PaymentMethod {
142
191
  paymentMethod: string;
143
192
  paymentName: string;
144
193
  paymentImage: string;
145
194
  totalFee: string;
146
- category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
195
+ category: "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya" | string;
147
196
  code?: string;
197
+ extra?: any;
148
198
  feeDetail?: {
149
199
  flat: number;
150
200
  percent: number;
@@ -605,7 +655,55 @@ declare class IpaymuClient {
605
655
  /**
606
656
  * Cek detail transaksi iPaymu
607
657
  */
608
- checkTransaction(transactionId: string): Promise<any>;
658
+ checkTransaction(transactionId: string | number): Promise<any>;
659
+ /**
660
+ * Ambil daftar channel pembayaran aktif milik merchant
661
+ */
662
+ getPaymentMethods(): Promise<any>;
663
+ /**
664
+ * Ambil riwayat transaksi merchant berpaginasi
665
+ */
666
+ getHistory(params?: {
667
+ page?: number;
668
+ limit?: number;
669
+ status?: number;
670
+ date?: string;
671
+ start_date?: string;
672
+ end_date?: string;
673
+ bulkId?: string[];
674
+ }): Promise<any>;
675
+ /**
676
+ * Ambil daftar seluruh bank di Indonesia
677
+ */
678
+ getBankList(): Promise<any>;
679
+ /**
680
+ * Ambil jangkauan area pengiriman COD
681
+ */
682
+ getCodArea(postalCode?: string): Promise<any>;
683
+ /**
684
+ * Hitung tarif ongkir pengiriman COD
685
+ */
686
+ getCodRate(params: {
687
+ pickupArea: string;
688
+ deliveryArea: string;
689
+ weight: number;
690
+ height?: number;
691
+ length?: number;
692
+ width?: number;
693
+ [key: string]: any;
694
+ }): Promise<any>;
695
+ /**
696
+ * Request pickup kurir COD
697
+ */
698
+ getCodPickup(params: any): Promise<any>;
699
+ /**
700
+ * Ambil nomor resi / AWB pengiriman COD
701
+ */
702
+ getCodAwb(transactionId: string | number): Promise<any>;
703
+ /**
704
+ * Lacak status pengiriman kurir berdasarkan no resi / AWB
705
+ */
706
+ getCodTracking(awb: string): Promise<any>;
609
707
  }
610
708
 
611
709
  interface XenditDisbursementParams {
@@ -1026,10 +1124,52 @@ declare class PaymentManager {
1026
1124
  }
1027
1125
  declare const paymentManager: PaymentManager;
1028
1126
 
1127
+ interface ProviderCapability {
1128
+ /** Metode pembayaran kanonik yang didukung provider ini */
1129
+ methods: string[];
1130
+ /** Operasi lanjutan yang didukung */
1131
+ operations: {
1132
+ refund: boolean;
1133
+ checkBalance: boolean;
1134
+ disburse: boolean;
1135
+ };
1136
+ }
1137
+ interface ProviderDescriptor extends ProviderCapability {
1138
+ name: string;
1139
+ /** Kunci env kredensial yang menandakan provider ini aktif (untuk autodetect) */
1140
+ envKeys: string[];
1141
+ }
1029
1142
  /**
1030
- * Resolver konfigurasi kredensial otomatis dari Environment Variables.
1031
- * Mendukung variabel universal Buayar / PG serta variabel spesifik masing-masing provider.
1032
- */
1143
+ * Pendeteksi / registrar provider dinamis.
1144
+ * Metadata provider terpusat di sini sehingga:
1145
+ * - Daftar provider bisa ditambah tanpa ubah core (register(...)).
1146
+ * - Provider aktif bisa di-autodetect dari kredensial .env.
1147
+ * - Provider pengirim webhook bisa ditebak dari struktur payload.
1148
+ * - Capability (metode + operasi) bisa di-query secara runtime.
1149
+ */
1150
+ declare class ProviderRegistry {
1151
+ private descriptors;
1152
+ constructor(initial?: ProviderDescriptor[]);
1153
+ register(desc: ProviderDescriptor): void;
1154
+ unregister(name: string): boolean;
1155
+ has(name: string): boolean;
1156
+ get(name: string): ProviderDescriptor | undefined;
1157
+ names(): string[];
1158
+ /**
1159
+ * Autodetect provider aktif dari variabel lingkungan.
1160
+ * Mengembalikan nama provider yang kredensial .env-nya terisi penuh,
1161
+ * atau undefined jika tidak ada / ambigu.
1162
+ */
1163
+ detectFromEnv(env: Record<string, string | undefined>): string | undefined;
1164
+ /**
1165
+ * Autodetect provider dari struktur payload webhook.
1166
+ * Mengembalikan nama provider jika dikenali, else undefined.
1167
+ */
1168
+ detectFromWebhook(payload: any): string | undefined;
1169
+ }
1170
+ declare function buildDefaultDescriptors(): ProviderDescriptor[];
1171
+ declare const providerRegistry: ProviderRegistry;
1172
+
1033
1173
  declare function resolveConfigFromEnv(customConfig?: BuayarConfig): BuayarConfig;
1034
1174
 
1035
1175
  /**
@@ -1045,7 +1185,8 @@ declare function resolveConfigFromEnv(customConfig?: BuayarConfig): BuayarConfig
1045
1185
  declare class Buayar {
1046
1186
  private manager;
1047
1187
  private config;
1048
- constructor(config?: BuayarConfig, manager?: PaymentManager);
1188
+ private registry;
1189
+ constructor(config?: BuayarConfig, manager?: PaymentManager, registry?: ProviderRegistry);
1049
1190
  /**
1050
1191
  * Dapatkan salinan konfigurasi aktif saat ini
1051
1192
  */
@@ -1066,6 +1207,40 @@ declare class Buayar {
1066
1207
  * Ambil instance provider kelas dasar
1067
1208
  */
1068
1209
  getProvider(name?: string): BasePaymentProvider;
1210
+ /**
1211
+ * Daftar nama provider yang terdaftar (bawaan + kustom).
1212
+ */
1213
+ listProviders(): string[];
1214
+ /**
1215
+ * Registrasi metadata provider kustom untuk deteksi & capability.
1216
+ * Contoh: buayar.registerProviderDescriptor({ name, envKeys, methods, operations })
1217
+ */
1218
+ registerProviderDescriptor(desc: ProviderDescriptor): void;
1219
+ /**
1220
+ * Cek capability (metode + operasi) provider tertentu — atau provider aktif bila kosong.
1221
+ * Jawab pertanyaan "provider ini dukung apa?" secara runtime, tanpa bongkar dokumen.
1222
+ */
1223
+ getCapabilities(name?: string): ProviderCapability | undefined;
1224
+ /**
1225
+ * Deteksi nama provider dari struktur payload webhook.
1226
+ */
1227
+ detectProviderFromPayload(payload: any): string | undefined;
1228
+ /**
1229
+ * Deteksi nama provider aktif dari variabel lingkungan (kredensial yang terisi).
1230
+ */
1231
+ detectProviderFromEnv(env?: Record<string, string | undefined>): string | undefined;
1232
+ /**
1233
+ * Logika "bisa pakai X dengan provider Y?" — helper untuk portabilitas.
1234
+ */
1235
+ supports(name: string, operation: "refund" | "checkBalance" | "disburse"): boolean;
1236
+ /**
1237
+ * Daftar metode pembayaran yang benar2 tersedia untuk provider aktif.
1238
+ */
1239
+ getSupportedMethods(name?: string): string[];
1240
+ /**
1241
+ * Iterasi CEPAT: apakah provider aktif mendukung method kanonik tertentu?
1242
+ */
1243
+ supportsMethod(method: string, name?: string): boolean;
1069
1244
  /**
1070
1245
  * Buat transaksi pembayaran baru (Mendukung Semi dan Full Integrasi)
1071
1246
  */
@@ -1391,6 +1566,11 @@ declare function snapExternalId(prefix?: string): string;
1391
1566
  * @returns true when the X-SIGNATURE matches.
1392
1567
  */
1393
1568
  declare function verifySnapWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientSecret: string, endpointUrl?: string): boolean;
1569
+ /**
1570
+ * Map a DOKU SNAP error (responseMessage/responseCode) to an actionable hint
1571
+ * for developers, so config gaps (missing BIN / merchantId / keys) are obvious.
1572
+ */
1573
+ declare function snapErrorHint(message: string, code?: string): string | undefined;
1394
1574
 
1395
1575
  /**
1396
1576
  * Generate signature PrismaLink
@@ -1585,6 +1765,21 @@ declare class SnapClient {
1585
1765
  extraHeaders?: Record<string, string>;
1586
1766
  }): Promise<any>;
1587
1767
  }
1768
+ /** DOKU SNAP API error with structured diagnostics (status code + raw response). */
1769
+ declare class SnapApiError extends Error {
1770
+ readonly status: number;
1771
+ readonly responseCode?: string;
1772
+ readonly raw: any;
1773
+ readonly endpoint?: string;
1774
+ readonly method?: string;
1775
+ constructor(message: string, opts: {
1776
+ status: number;
1777
+ code?: string;
1778
+ raw?: any;
1779
+ endpoint?: string;
1780
+ method?: string;
1781
+ });
1782
+ }
1588
1783
 
1589
1784
  /**
1590
1785
  * Generate MD5 hash string (lowercase)
@@ -1615,4 +1810,4 @@ declare function safeCompare(a: string, b: string): boolean;
1615
1810
  */
1616
1811
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
1617
1812
 
1618
- export { AdyenClient, AdyenProvider, BasePaymentProvider, BraintreeClient, BraintreeProvider, 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_STRIPE, CANONICAL_TO_XENDIT, CORE_API_METHODS, type CanonicalPaymentMethod, type CheckBalanceResult, type CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, type CreateInvoiceParams, type CustomerDetails, DUITKU_TO_CANONICAL, type DisburseParams, type DisburseResult, 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, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderConfig, RazorpayClient, RazorpayProvider, type RefundParams, type RefundResult, SnapClient, type SnapClientOptions, SquareClient, SquareProvider, StripeClient, StripeProvider, TwoCheckoutClient, TwoCheckoutProvider, type VerifyCallbackResult, XenditClient, type XenditDisbursementParams, XenditProvider, buayar, buildBraintreeBasicAuth, buildCoreChargePayload, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha256Hex, sha512, snapExternalId, snapTimestamp, snapUtcTimestamp, toCanonicalPaymentMethod, toDokuPaymentMethod, toDuitkuPaymentMethod, toFaspayPaymentMethod, toFinpayPaymentMethod, toIpaymuPaymentMethod, toNicepayPaymentMethod, toOyPaymentMethod, toPrismalinkPaymentMethod, toStripePaymentMethod, toXenditPaymentMethod, verifyAdyenWebhook, verifyBraintreeWebhook, verifyCheckoutComWebhook, verifyDokuWebhookSignature, verifyDuitkuCallbackSignature, verifyFaspaySignature, verifyFinpaySignature, verifyIpaymuCallback, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
1813
+ export { AdyenClient, AdyenProvider, BasePaymentProvider, BraintreeClient, BraintreeProvider, 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_STRIPE, CANONICAL_TO_XENDIT, CORE_API_METHODS, type CanonicalPaymentMethod, type CheckBalanceResult, type CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, type CreateInvoiceParams, type CustomerDetails, DUITKU_TO_CANONICAL, type DisburseParams, type DisburseResult, DokuClient, DokuProvider, DuitkuClient, type DuitkuDisbursementParams, DuitkuProvider, type EWalletResponse, 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, type PaymentMode, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderCapability, type ProviderConfig, type ProviderDescriptor, ProviderRegistry, type QrisResponse, RazorpayClient, RazorpayProvider, type RefundParams, type RefundResult, SnapApiError, SnapClient, type SnapClientOptions, SquareClient, SquareProvider, StripeClient, StripeProvider, TwoCheckoutClient, TwoCheckoutProvider, type VerifyCallbackResult, type VirtualAccountResponse, XenditClient, type XenditDisbursementParams, XenditProvider, buayar, buildBraintreeBasicAuth, buildCoreChargePayload, buildDefaultDescriptors, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, parseCoreChargeResponse, paymentManager, providerRegistry, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha256Hex, sha512, snapErrorHint, snapExternalId, snapTimestamp, snapUtcTimestamp, toCanonicalPaymentMethod, toDokuPaymentMethod, toDuitkuPaymentMethod, toFaspayPaymentMethod, toFinpayPaymentMethod, toIpaymuPaymentMethod, toNicepayPaymentMethod, toOyPaymentMethod, toPrismalinkPaymentMethod, toStripePaymentMethod, toXenditPaymentMethod, verifyAdyenWebhook, verifyBraintreeWebhook, verifyCheckoutComWebhook, verifyDokuWebhookSignature, verifyDuitkuCallbackSignature, verifyFaspaySignature, verifyFinpaySignature, verifyIpaymuCallback, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };