@crediblemark/buayar 0.3.2 → 0.5.1
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/cli/index.js +643 -0
- package/dist/index.d.mts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +210 -5
- package/dist/index.mjs +210 -5
- package/docs/guide.md +356 -0
- package/package.json +12 -4
- package/docs/adyen.md +0 -60
- package/docs/braintree.md +0 -57
- package/docs/checkoutcom.md +0 -59
- package/docs/doku.md +0 -102
- package/docs/duitku.md +0 -219
- package/docs/faspay.md +0 -109
- package/docs/finpay.md +0 -102
- package/docs/ipaymu.md +0 -106
- package/docs/midtrans.md +0 -207
- package/docs/nicepay.md +0 -106
- package/docs/oy.md +0 -115
- package/docs/paypal.md +0 -73
- package/docs/payu.md +0 -61
- package/docs/prismalink.md +0 -101
- package/docs/razorpay.md +0 -77
- package/docs/square.md +0 -61
- package/docs/stripe.md +0 -103
- package/docs/twocheckout.md +0 -59
- package/docs/xendit.md +0 -112
package/dist/index.d.mts
CHANGED
|
@@ -184,6 +184,63 @@ interface CheckTransactionResult {
|
|
|
184
184
|
error?: string;
|
|
185
185
|
rawResponse: any;
|
|
186
186
|
}
|
|
187
|
+
interface RefundParams {
|
|
188
|
+
/** ID transaksi / capture / payment sebagai target refund (per provider) */
|
|
189
|
+
transactionId: string;
|
|
190
|
+
/** Nominal refund (opsional; default = full refund) */
|
|
191
|
+
amount?: number;
|
|
192
|
+
/** Alasan refund (opsional bila didukung provider) */
|
|
193
|
+
reason?: string;
|
|
194
|
+
/** Kode mata uang (opsional, untuk provider internasional) */
|
|
195
|
+
currency?: string;
|
|
196
|
+
}
|
|
197
|
+
interface RefundResult {
|
|
198
|
+
success: boolean;
|
|
199
|
+
/** Provider yang menyatakan operasi ini tidak tersedia */
|
|
200
|
+
supported: boolean;
|
|
201
|
+
provider?: string;
|
|
202
|
+
/** Reference / ID refund dari provider */
|
|
203
|
+
reference?: string;
|
|
204
|
+
/** Status refund dari provider (raw) */
|
|
205
|
+
status?: string;
|
|
206
|
+
error?: string;
|
|
207
|
+
rawResponse: any;
|
|
208
|
+
}
|
|
209
|
+
interface CheckBalanceResult {
|
|
210
|
+
success: boolean;
|
|
211
|
+
supported: boolean;
|
|
212
|
+
provider?: string;
|
|
213
|
+
/** Saldo merchant dalam satuan terkecil (minor unit) */
|
|
214
|
+
balance?: number;
|
|
215
|
+
/** Kode mata uang saldo (bila tersedia) */
|
|
216
|
+
currency?: string;
|
|
217
|
+
error?: string;
|
|
218
|
+
rawResponse: any;
|
|
219
|
+
}
|
|
220
|
+
interface DisburseParams {
|
|
221
|
+
/** ID unik merchant untuk mengidentifikasi transfer (merchantOrderId / externalId / partnerTrxId) */
|
|
222
|
+
externalId: string;
|
|
223
|
+
/** Kode bank tujuan (mis. 'bca', '014', 'BCA' — ikuti aturan provider) */
|
|
224
|
+
bankCode: string;
|
|
225
|
+
/** Nama pemilik rekening tujuan (wajib untuk beberapa provider) */
|
|
226
|
+
accountHolderName?: string;
|
|
227
|
+
/** Nomor rekening tujuan */
|
|
228
|
+
accountNumber: string;
|
|
229
|
+
/** Nominal transfer */
|
|
230
|
+
amount: number;
|
|
231
|
+
/** Deskripsi / tujuan transfer */
|
|
232
|
+
description?: string;
|
|
233
|
+
}
|
|
234
|
+
interface DisburseResult {
|
|
235
|
+
success: boolean;
|
|
236
|
+
supported: boolean;
|
|
237
|
+
provider?: string;
|
|
238
|
+
/** Reference / status transfer dari provider */
|
|
239
|
+
reference?: string;
|
|
240
|
+
status?: string;
|
|
241
|
+
error?: string;
|
|
242
|
+
rawResponse: any;
|
|
243
|
+
}
|
|
187
244
|
|
|
188
245
|
declare abstract class BasePaymentProvider {
|
|
189
246
|
abstract readonly name: string;
|
|
@@ -934,6 +991,10 @@ declare class PaymentManager {
|
|
|
934
991
|
enabled: string[];
|
|
935
992
|
error?: string;
|
|
936
993
|
}>;
|
|
994
|
+
private unsupported;
|
|
995
|
+
refund(providerName: string, params: RefundParams, config: ProviderConfig): Promise<RefundResult>;
|
|
996
|
+
checkBalance(providerName: string, config: ProviderConfig): Promise<CheckBalanceResult>;
|
|
997
|
+
disburse(providerName: string, params: DisburseParams, config: ProviderConfig): Promise<DisburseResult>;
|
|
937
998
|
}
|
|
938
999
|
declare const paymentManager: PaymentManager;
|
|
939
1000
|
|
|
@@ -996,6 +1057,21 @@ declare class Buayar {
|
|
|
996
1057
|
*/
|
|
997
1058
|
verifyWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
|
|
998
1059
|
handleWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Unified Refund — berlaku untuk semua provider yang mendukung refund.
|
|
1062
|
+
* Provider tanpa fitur refund mengembalikan `{ supported: false }`, bukan error.
|
|
1063
|
+
*/
|
|
1064
|
+
refund(params: RefundParams, configOverride?: Partial<ProviderConfig>): Promise<RefundResult>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Unified Check Balance — ambil saldo merchant dari provider aktif.
|
|
1067
|
+
* Provider tanpa fitur balance mengembalikan `{ supported: false }`.
|
|
1068
|
+
*/
|
|
1069
|
+
checkBalance(configOverride?: Partial<ProviderConfig>): Promise<CheckBalanceResult>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Unified Disburse / Payout — transfer dana ke rekening bank tujuan.
|
|
1072
|
+
* Provider tanpa fitur disbursement mengembalikan `{ supported: false }`.
|
|
1073
|
+
*/
|
|
1074
|
+
disburse(params: DisburseParams, configOverride?: Partial<ProviderConfig>): Promise<DisburseResult>;
|
|
999
1075
|
getMidtransClient(configOverride?: Partial<ProviderConfig>): MidtransClient;
|
|
1000
1076
|
getDuitkuClient(configOverride?: Partial<ProviderConfig>): DuitkuClient;
|
|
1001
1077
|
getIpaymuClient(configOverride?: Partial<ProviderConfig>): IpaymuClient;
|
|
@@ -1403,4 +1479,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1403
1479
|
*/
|
|
1404
1480
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1405
1481
|
|
|
1406
|
-
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 CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, 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, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderConfig, RazorpayClient, RazorpayProvider, 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, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha512, 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, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
|
1482
|
+
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, 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, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha512, 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, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,63 @@ interface CheckTransactionResult {
|
|
|
184
184
|
error?: string;
|
|
185
185
|
rawResponse: any;
|
|
186
186
|
}
|
|
187
|
+
interface RefundParams {
|
|
188
|
+
/** ID transaksi / capture / payment sebagai target refund (per provider) */
|
|
189
|
+
transactionId: string;
|
|
190
|
+
/** Nominal refund (opsional; default = full refund) */
|
|
191
|
+
amount?: number;
|
|
192
|
+
/** Alasan refund (opsional bila didukung provider) */
|
|
193
|
+
reason?: string;
|
|
194
|
+
/** Kode mata uang (opsional, untuk provider internasional) */
|
|
195
|
+
currency?: string;
|
|
196
|
+
}
|
|
197
|
+
interface RefundResult {
|
|
198
|
+
success: boolean;
|
|
199
|
+
/** Provider yang menyatakan operasi ini tidak tersedia */
|
|
200
|
+
supported: boolean;
|
|
201
|
+
provider?: string;
|
|
202
|
+
/** Reference / ID refund dari provider */
|
|
203
|
+
reference?: string;
|
|
204
|
+
/** Status refund dari provider (raw) */
|
|
205
|
+
status?: string;
|
|
206
|
+
error?: string;
|
|
207
|
+
rawResponse: any;
|
|
208
|
+
}
|
|
209
|
+
interface CheckBalanceResult {
|
|
210
|
+
success: boolean;
|
|
211
|
+
supported: boolean;
|
|
212
|
+
provider?: string;
|
|
213
|
+
/** Saldo merchant dalam satuan terkecil (minor unit) */
|
|
214
|
+
balance?: number;
|
|
215
|
+
/** Kode mata uang saldo (bila tersedia) */
|
|
216
|
+
currency?: string;
|
|
217
|
+
error?: string;
|
|
218
|
+
rawResponse: any;
|
|
219
|
+
}
|
|
220
|
+
interface DisburseParams {
|
|
221
|
+
/** ID unik merchant untuk mengidentifikasi transfer (merchantOrderId / externalId / partnerTrxId) */
|
|
222
|
+
externalId: string;
|
|
223
|
+
/** Kode bank tujuan (mis. 'bca', '014', 'BCA' — ikuti aturan provider) */
|
|
224
|
+
bankCode: string;
|
|
225
|
+
/** Nama pemilik rekening tujuan (wajib untuk beberapa provider) */
|
|
226
|
+
accountHolderName?: string;
|
|
227
|
+
/** Nomor rekening tujuan */
|
|
228
|
+
accountNumber: string;
|
|
229
|
+
/** Nominal transfer */
|
|
230
|
+
amount: number;
|
|
231
|
+
/** Deskripsi / tujuan transfer */
|
|
232
|
+
description?: string;
|
|
233
|
+
}
|
|
234
|
+
interface DisburseResult {
|
|
235
|
+
success: boolean;
|
|
236
|
+
supported: boolean;
|
|
237
|
+
provider?: string;
|
|
238
|
+
/** Reference / status transfer dari provider */
|
|
239
|
+
reference?: string;
|
|
240
|
+
status?: string;
|
|
241
|
+
error?: string;
|
|
242
|
+
rawResponse: any;
|
|
243
|
+
}
|
|
187
244
|
|
|
188
245
|
declare abstract class BasePaymentProvider {
|
|
189
246
|
abstract readonly name: string;
|
|
@@ -934,6 +991,10 @@ declare class PaymentManager {
|
|
|
934
991
|
enabled: string[];
|
|
935
992
|
error?: string;
|
|
936
993
|
}>;
|
|
994
|
+
private unsupported;
|
|
995
|
+
refund(providerName: string, params: RefundParams, config: ProviderConfig): Promise<RefundResult>;
|
|
996
|
+
checkBalance(providerName: string, config: ProviderConfig): Promise<CheckBalanceResult>;
|
|
997
|
+
disburse(providerName: string, params: DisburseParams, config: ProviderConfig): Promise<DisburseResult>;
|
|
937
998
|
}
|
|
938
999
|
declare const paymentManager: PaymentManager;
|
|
939
1000
|
|
|
@@ -996,6 +1057,21 @@ declare class Buayar {
|
|
|
996
1057
|
*/
|
|
997
1058
|
verifyWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
|
|
998
1059
|
handleWebhook(payload: any, headers?: Record<string, string | string[] | undefined>, configOverride?: Partial<ProviderConfig>): Promise<VerifyCallbackResult>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Unified Refund — berlaku untuk semua provider yang mendukung refund.
|
|
1062
|
+
* Provider tanpa fitur refund mengembalikan `{ supported: false }`, bukan error.
|
|
1063
|
+
*/
|
|
1064
|
+
refund(params: RefundParams, configOverride?: Partial<ProviderConfig>): Promise<RefundResult>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Unified Check Balance — ambil saldo merchant dari provider aktif.
|
|
1067
|
+
* Provider tanpa fitur balance mengembalikan `{ supported: false }`.
|
|
1068
|
+
*/
|
|
1069
|
+
checkBalance(configOverride?: Partial<ProviderConfig>): Promise<CheckBalanceResult>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Unified Disburse / Payout — transfer dana ke rekening bank tujuan.
|
|
1072
|
+
* Provider tanpa fitur disbursement mengembalikan `{ supported: false }`.
|
|
1073
|
+
*/
|
|
1074
|
+
disburse(params: DisburseParams, configOverride?: Partial<ProviderConfig>): Promise<DisburseResult>;
|
|
999
1075
|
getMidtransClient(configOverride?: Partial<ProviderConfig>): MidtransClient;
|
|
1000
1076
|
getDuitkuClient(configOverride?: Partial<ProviderConfig>): DuitkuClient;
|
|
1001
1077
|
getIpaymuClient(configOverride?: Partial<ProviderConfig>): IpaymuClient;
|
|
@@ -1403,4 +1479,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1403
1479
|
*/
|
|
1404
1480
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1405
1481
|
|
|
1406
|
-
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 CheckTransactionParams, type CheckTransactionResult, CheckoutComClient, CheckoutComProvider, 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, PaypalClient, PaypalProvider, PayuClient, PayuProvider, PrismalinkClient, PrismalinkProvider, type ProviderConfig, RazorpayClient, RazorpayProvider, 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, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha512, 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, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
|
1482
|
+
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, 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, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, parseCoreChargeResponse, paymentManager, resolveConfigFromEnv, safeCompare, serializePaypalParams, serializeStripeParams, sha256, sha512, 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, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
package/dist/index.js
CHANGED
|
@@ -2130,11 +2130,11 @@ var XenditProvider = class extends BasePaymentProvider {
|
|
|
2130
2130
|
amount: integerAmount,
|
|
2131
2131
|
reference_id: orderId,
|
|
2132
2132
|
description: productDetails,
|
|
2133
|
-
customer
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
},
|
|
2133
|
+
// Xendit Payment Requests API rejects the inline `customer` object
|
|
2134
|
+
// with API_VALIDATION_ERROR. Attribution is only supported via a
|
|
2135
|
+
// pre-created `customer_id` (Customer API), so we forward that when
|
|
2136
|
+
// provided through providerParams and otherwise omit customer data.
|
|
2137
|
+
...params.providerParams?.customer_id ? { customer_id: params.providerParams.customer_id } : {},
|
|
2138
2138
|
payment_method: paymentMethodPayload,
|
|
2139
2139
|
...params.providerParams
|
|
2140
2140
|
};
|
|
@@ -8914,6 +8914,184 @@ var PaymentManager = class {
|
|
|
8914
8914
|
}
|
|
8915
8915
|
return { success: false, enabled: [], error: `Provider '${providerName}' does not support payment methods probing` };
|
|
8916
8916
|
}
|
|
8917
|
+
// ─── Unified Advanced Operations (Refund / Balance / Disburse) ─────────────
|
|
8918
|
+
// "Mata tertutup": satu API untuk semua provider yang mendukung fitur.
|
|
8919
|
+
// Provider yang tidak mendukung mengembalikan `supported: false` (bukan throw).
|
|
8920
|
+
unsupported(supported, provider, operation, rawResponse = null) {
|
|
8921
|
+
return { success: false, supported, provider, rawResponse, error: `Provider '${provider}' does not support ${operation}` };
|
|
8922
|
+
}
|
|
8923
|
+
async refund(providerName, params, config) {
|
|
8924
|
+
const name = providerName.toLowerCase();
|
|
8925
|
+
try {
|
|
8926
|
+
switch (name) {
|
|
8927
|
+
case "midtrans": {
|
|
8928
|
+
const data = await this.getMidtransClient(config).refundTransaction(params.transactionId, {
|
|
8929
|
+
amount: params.amount,
|
|
8930
|
+
reason: params.reason
|
|
8931
|
+
});
|
|
8932
|
+
return { success: true, supported: true, provider: "midtrans", reference: data.transaction_id || data.order_id, status: data.status_message, rawResponse: data };
|
|
8933
|
+
}
|
|
8934
|
+
case "stripe": {
|
|
8935
|
+
const data = await this.getStripeClient(config).createRefund(params.transactionId, params.amount);
|
|
8936
|
+
return { success: true, supported: true, provider: "stripe", reference: data.id, status: data.status, rawResponse: data };
|
|
8937
|
+
}
|
|
8938
|
+
case "paypal": {
|
|
8939
|
+
const data = await this.getPaypalClient(config).refundCapture(params.transactionId, params.amount, params.currency);
|
|
8940
|
+
return { success: true, supported: true, provider: "paypal", reference: data.id, status: data.status, rawResponse: data };
|
|
8941
|
+
}
|
|
8942
|
+
case "adyen": {
|
|
8943
|
+
const client = this.getAdyenClient(config);
|
|
8944
|
+
const merchantAccount = config.extra?.merchantAccount || config.merchantCode || config.merchantId || "";
|
|
8945
|
+
const data = await client.refundPayment(params.transactionId, params.amount || 0, params.currency || "IDR", merchantAccount);
|
|
8946
|
+
return { success: true, supported: true, provider: "adyen", reference: data.pspReference, status: data.response, rawResponse: data };
|
|
8947
|
+
}
|
|
8948
|
+
case "checkoutcom": {
|
|
8949
|
+
const data = await this.getCheckoutComClient(config).refundPayment(params.transactionId, params.amount);
|
|
8950
|
+
return { success: true, supported: true, provider: "checkoutcom", reference: data.reference, status: data.status, rawResponse: data };
|
|
8951
|
+
}
|
|
8952
|
+
case "razorpay": {
|
|
8953
|
+
const data = await this.getRazorpayClient(config).createRefund(params.transactionId, params.amount);
|
|
8954
|
+
return { success: true, supported: true, provider: "razorpay", reference: data.id, status: data.status, rawResponse: data };
|
|
8955
|
+
}
|
|
8956
|
+
case "square": {
|
|
8957
|
+
const client = this.getSquareClient(config);
|
|
8958
|
+
const currency = (params.currency || "IDR").toUpperCase();
|
|
8959
|
+
const idempotencyKey = config.extra?.idempotencyKey || `refund-${params.transactionId}-${Date.now()}`;
|
|
8960
|
+
const data = await client.refundPayment(params.transactionId, Math.round(params.amount || 0), currency, idempotencyKey, params.reason);
|
|
8961
|
+
const refund = data.refund;
|
|
8962
|
+
return { success: !data.errors, supported: true, provider: "square", reference: refund?.id, status: refund?.status, rawResponse: data };
|
|
8963
|
+
}
|
|
8964
|
+
case "payu": {
|
|
8965
|
+
const data = await this.getPayuClient(config).refundOrder(params.transactionId, params.amount, params.reason);
|
|
8966
|
+
return { success: true, supported: true, provider: "payu", reference: data.orderId, status: data.status, rawResponse: data };
|
|
8967
|
+
}
|
|
8968
|
+
case "braintree": {
|
|
8969
|
+
const data = await this.getBraintreeClient(config).refundTransaction(params.transactionId, params.amount);
|
|
8970
|
+
return { success: true, supported: true, provider: "braintree", reference: data?.transaction?.id, status: data?.transaction?.status, rawResponse: data };
|
|
8971
|
+
}
|
|
8972
|
+
case "twocheckout": {
|
|
8973
|
+
const data = await this.getTwoCheckoutClient(config).refundOrder(params.transactionId, params.amount || 0, params.reason);
|
|
8974
|
+
return { success: true, supported: true, provider: "twocheckout", reference: data.refno, status: data.response_code, rawResponse: data };
|
|
8975
|
+
}
|
|
8976
|
+
default:
|
|
8977
|
+
return this.unsupported(false, name, "refund");
|
|
8978
|
+
}
|
|
8979
|
+
} catch (e) {
|
|
8980
|
+
return { success: false, supported: true, provider: name, rawResponse: null, error: e.message || "Refund failed" };
|
|
8981
|
+
}
|
|
8982
|
+
}
|
|
8983
|
+
async checkBalance(providerName, config) {
|
|
8984
|
+
const name = providerName.toLowerCase();
|
|
8985
|
+
try {
|
|
8986
|
+
let balance;
|
|
8987
|
+
let currency;
|
|
8988
|
+
let raw;
|
|
8989
|
+
switch (name) {
|
|
8990
|
+
case "midtrans": {
|
|
8991
|
+
raw = await this.getMidtransClient(config).getBalance();
|
|
8992
|
+
balance = raw?.balance ?? raw?.balance_amount ?? raw?.amount;
|
|
8993
|
+
break;
|
|
8994
|
+
}
|
|
8995
|
+
case "duitku": {
|
|
8996
|
+
const result = await this.getDuitkuClient(config).checkBalance();
|
|
8997
|
+
return { success: result.success, supported: true, provider: "duitku", balance: result.balance, rawResponse: result.rawResponse, error: result.error };
|
|
8998
|
+
}
|
|
8999
|
+
case "ipaymu": {
|
|
9000
|
+
const result = await this.getIpaymuClient(config).checkBalance();
|
|
9001
|
+
return { success: result.success, supported: true, provider: "ipaymu", balance: result.balance, rawResponse: result.rawResponse, error: result.error };
|
|
9002
|
+
}
|
|
9003
|
+
case "xendit": {
|
|
9004
|
+
const result = await this.getXenditClient(config).checkBalance("CASH");
|
|
9005
|
+
return { success: result.success, supported: true, provider: "xendit", balance: result.balance, rawResponse: result.rawResponse, error: result.error };
|
|
9006
|
+
}
|
|
9007
|
+
case "oy": {
|
|
9008
|
+
raw = await this.getOyClient(config).checkBalance();
|
|
9009
|
+
balance = raw?.balance ?? raw?.data?.balance;
|
|
9010
|
+
break;
|
|
9011
|
+
}
|
|
9012
|
+
case "stripe": {
|
|
9013
|
+
raw = await this.getStripeClient(config).checkBalance();
|
|
9014
|
+
const available = raw?.available?.[0];
|
|
9015
|
+
balance = available?.amount;
|
|
9016
|
+
currency = available?.currency;
|
|
9017
|
+
break;
|
|
9018
|
+
}
|
|
9019
|
+
case "paypal": {
|
|
9020
|
+
raw = await this.getPaypalClient(config).checkBalance();
|
|
9021
|
+
const first = raw?.balances?.[0];
|
|
9022
|
+
balance = first?.total_balance?.value !== void 0 ? Number(first.total_balance.value) * 100 : void 0;
|
|
9023
|
+
currency = first?.currency_code;
|
|
9024
|
+
break;
|
|
9025
|
+
}
|
|
9026
|
+
case "checkoutcom": {
|
|
9027
|
+
raw = await this.getCheckoutComClient(config).checkBalance();
|
|
9028
|
+
const first = raw?.data?.[0]?.available;
|
|
9029
|
+
balance = first?.[0]?.value;
|
|
9030
|
+
currency = first?.[0]?.currency;
|
|
9031
|
+
break;
|
|
9032
|
+
}
|
|
9033
|
+
case "razorpay": {
|
|
9034
|
+
raw = await this.getRazorpayClient(config).checkBalance();
|
|
9035
|
+
balance = raw?.balance ?? raw?.amount;
|
|
9036
|
+
currency = raw?.currency;
|
|
9037
|
+
break;
|
|
9038
|
+
}
|
|
9039
|
+
case "square": {
|
|
9040
|
+
raw = await this.getSquareClient(config).retrieveBalance();
|
|
9041
|
+
balance = raw?.balance_money?.amount;
|
|
9042
|
+
currency = raw?.balance_money?.currency;
|
|
9043
|
+
break;
|
|
9044
|
+
}
|
|
9045
|
+
default:
|
|
9046
|
+
return this.unsupported(false, name, "checkBalance");
|
|
9047
|
+
}
|
|
9048
|
+
return { success: true, supported: true, provider: name, balance, currency, rawResponse: raw };
|
|
9049
|
+
} catch (e) {
|
|
9050
|
+
return { success: false, supported: true, provider: name, rawResponse: null, error: e.message || "Balance check failed" };
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9053
|
+
async disburse(providerName, params, config) {
|
|
9054
|
+
const name = providerName.toLowerCase();
|
|
9055
|
+
try {
|
|
9056
|
+
switch (name) {
|
|
9057
|
+
case "duitku": {
|
|
9058
|
+
const data = await this.getDuitkuClient(config).disburse({
|
|
9059
|
+
bankCode: params.bankCode,
|
|
9060
|
+
bankAccount: params.accountNumber,
|
|
9061
|
+
amount: params.amount,
|
|
9062
|
+
purpose: params.description || "Disbursement",
|
|
9063
|
+
merchantOrderId: params.externalId
|
|
9064
|
+
});
|
|
9065
|
+
return { success: data?.statusCode === "00", supported: true, provider: "duitku", reference: params.externalId, status: data?.statusMessage, rawResponse: data };
|
|
9066
|
+
}
|
|
9067
|
+
case "xendit": {
|
|
9068
|
+
const data = await this.getXenditClient(config).createDisbursement({
|
|
9069
|
+
externalId: params.externalId,
|
|
9070
|
+
bankCode: params.bankCode,
|
|
9071
|
+
accountHolderName: params.accountHolderName || "",
|
|
9072
|
+
accountNumber: params.accountNumber,
|
|
9073
|
+
description: params.description || "Disbursement",
|
|
9074
|
+
amount: params.amount
|
|
9075
|
+
});
|
|
9076
|
+
return { success: true, supported: true, provider: "xendit", reference: data.id, status: data.status, rawResponse: data };
|
|
9077
|
+
}
|
|
9078
|
+
case "oy": {
|
|
9079
|
+
const data = await this.getOyClient(config).remit({
|
|
9080
|
+
recipientBank: params.bankCode,
|
|
9081
|
+
recipientAccount: params.accountNumber,
|
|
9082
|
+
amount: params.amount,
|
|
9083
|
+
note: params.description,
|
|
9084
|
+
partnerTrxId: params.externalId
|
|
9085
|
+
});
|
|
9086
|
+
return { success: true, supported: true, provider: "oy", reference: params.externalId, status: data?.status, rawResponse: data };
|
|
9087
|
+
}
|
|
9088
|
+
default:
|
|
9089
|
+
return this.unsupported(false, name, "disburse");
|
|
9090
|
+
}
|
|
9091
|
+
} catch (e) {
|
|
9092
|
+
return { success: false, supported: true, provider: name, rawResponse: null, error: e.message || "Disbursement failed" };
|
|
9093
|
+
}
|
|
9094
|
+
}
|
|
8917
9095
|
};
|
|
8918
9096
|
var paymentManager = new PaymentManager();
|
|
8919
9097
|
|
|
@@ -9277,6 +9455,33 @@ var Buayar = class {
|
|
|
9277
9455
|
async handleWebhook(payload, headers, configOverride) {
|
|
9278
9456
|
return this.verifyWebhook(payload, headers, configOverride);
|
|
9279
9457
|
}
|
|
9458
|
+
/**
|
|
9459
|
+
* Unified Refund — berlaku untuk semua provider yang mendukung refund.
|
|
9460
|
+
* Provider tanpa fitur refund mengembalikan `{ supported: false }`, bukan error.
|
|
9461
|
+
*/
|
|
9462
|
+
async refund(params, configOverride) {
|
|
9463
|
+
const mergedConfig = { ...this.config, ...configOverride };
|
|
9464
|
+
const providerName = configOverride?.provider || this.provider;
|
|
9465
|
+
return this.manager.refund(providerName, params, mergedConfig);
|
|
9466
|
+
}
|
|
9467
|
+
/**
|
|
9468
|
+
* Unified Check Balance — ambil saldo merchant dari provider aktif.
|
|
9469
|
+
* Provider tanpa fitur balance mengembalikan `{ supported: false }`.
|
|
9470
|
+
*/
|
|
9471
|
+
async checkBalance(configOverride) {
|
|
9472
|
+
const mergedConfig = { ...this.config, ...configOverride };
|
|
9473
|
+
const providerName = configOverride?.provider || this.provider;
|
|
9474
|
+
return this.manager.checkBalance(providerName, mergedConfig);
|
|
9475
|
+
}
|
|
9476
|
+
/**
|
|
9477
|
+
* Unified Disburse / Payout — transfer dana ke rekening bank tujuan.
|
|
9478
|
+
* Provider tanpa fitur disbursement mengembalikan `{ supported: false }`.
|
|
9479
|
+
*/
|
|
9480
|
+
async disburse(params, configOverride) {
|
|
9481
|
+
const mergedConfig = { ...this.config, ...configOverride };
|
|
9482
|
+
const providerName = configOverride?.provider || this.provider;
|
|
9483
|
+
return this.manager.disburse(providerName, params, mergedConfig);
|
|
9484
|
+
}
|
|
9280
9485
|
// ─── Indonesian Provider Client Getters ───────────────────────────────────
|
|
9281
9486
|
getMidtransClient(configOverride) {
|
|
9282
9487
|
return new MidtransClient({ ...this.config, ...configOverride });
|