@crediblemark/buayar 0.5.1 → 0.6.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/index.d.mts +137 -1
- package/dist/index.d.ts +137 -1
- package/dist/index.js +514 -25
- package/dist/index.mjs +488 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -346,10 +346,38 @@ declare class XenditProvider extends BasePaymentProvider {
|
|
|
346
346
|
declare class DokuProvider extends BasePaymentProvider {
|
|
347
347
|
readonly name = "doku";
|
|
348
348
|
private getBaseUrl;
|
|
349
|
+
/**
|
|
350
|
+
* DETEKSI mode integrasi DOKU:
|
|
351
|
+
* - SNAP : kredensial baru (Client ID `doku_...` + Secret Key `SK-...`) + opsional RSA privateKey
|
|
352
|
+
* untuk Get Token B2B. Diaktifkan via extra.snap / extra.dokuMode="snap" / doku_ prefix.
|
|
353
|
+
* - Legacy: Jokul v2 (Client-Id + Signature HMAC-SHA256), default jika bukan SNAP.
|
|
354
|
+
*/
|
|
355
|
+
private isSnap;
|
|
356
|
+
private buildSnap;
|
|
357
|
+
/** Helper: jumlah integer → format SNAP 2-desimal (".00"). */
|
|
358
|
+
private snapAmount;
|
|
349
359
|
createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
|
|
360
|
+
/**
|
|
361
|
+
* DOKU SNAP: buat transaksi (Create VA / Generate QRIS / e-Wallet Payment).
|
|
362
|
+
* Autentikasi via B2B token + symmetric HMAC-SHA512 signature.
|
|
363
|
+
*/
|
|
364
|
+
private createSnapInvoice;
|
|
365
|
+
/** Create Virtual Account (SNAP) — DOKU Generate Payment Code. */
|
|
366
|
+
private snapCreateVA;
|
|
367
|
+
/** Generate QRIS (SNAP) — dynamic QRIS MPM. */
|
|
368
|
+
private snapGenerateQRIS;
|
|
369
|
+
/** e-Wallet payment (SNAP) — DANA / OVO / ShopeePay via payment-host-to-host. */
|
|
370
|
+
private snapEWalletPayment;
|
|
350
371
|
verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
|
|
372
|
+
/**
|
|
373
|
+
* Verifikasi webhook / notifikasi DOKU SNAP.
|
|
374
|
+
* Signature dibangun dengan symmetric HMAC-SHA512 (AccessToken kosong).
|
|
375
|
+
*/
|
|
376
|
+
private verifySnapCallback;
|
|
351
377
|
getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
|
|
352
378
|
checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
|
|
379
|
+
/** Cek status transaksi SNAP (menggunakan Query QRIS bila ref berasal dari QRIS). */
|
|
380
|
+
private snapCheckTransaction;
|
|
353
381
|
}
|
|
354
382
|
|
|
355
383
|
declare class PrismalinkProvider extends BasePaymentProvider {
|
|
@@ -1297,6 +1325,73 @@ declare function generateDokuHeaders(clientId: string, secretKey: string, reques
|
|
|
1297
1325
|
*/
|
|
1298
1326
|
declare function verifyDokuWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientId: string, secretKey: string, requestTarget?: string): boolean;
|
|
1299
1327
|
|
|
1328
|
+
/**
|
|
1329
|
+
* DOKU SNAP (Standard Open API Pembayaran) helpers.
|
|
1330
|
+
*
|
|
1331
|
+
* SNAP is the Bank Indonesia standardized API that DOKU implements.
|
|
1332
|
+
* It differs from the legacy Jokul v2 HMAC flow:
|
|
1333
|
+
*
|
|
1334
|
+
* 1. Get B2B Access Token (ASYMETRIC):
|
|
1335
|
+
* POST /authorization/v1/access-token/b2b
|
|
1336
|
+
* X-SIGNATURE = Base64( SHA256withRSA( privateKey, clientId + "|" + X-TIMESTAMP ) )
|
|
1337
|
+
* → accessToken (Bearer), expiresIn ~900s
|
|
1338
|
+
*
|
|
1339
|
+
* 2. Transaction (e.g. Create VA / Generate QRIS / e-Wallet) (SYMETRIC):
|
|
1340
|
+
* stringToSign =
|
|
1341
|
+
* HTTPMethod + ":" + EndpointUrl + ":" + AccessToken + ":" +
|
|
1342
|
+
* Lowercase(HexEncode( SHA-256( minify(requestBody) ) )) + ":" + X-TIMESTAMP
|
|
1343
|
+
* X-SIGNATURE = HMAC-SHA512( clientSecret, stringToSign )
|
|
1344
|
+
* Headers: X-PARTNER-ID, X-EXTERNAL-ID, X-TIMESTAMP, CHANNEL-ID, Authorization: Bearer
|
|
1345
|
+
*
|
|
1346
|
+
* 3. Notification / webhook verification (SYMETRIC, same formula as #2 with
|
|
1347
|
+
* AccessToken = "" and EndpointUrl = merchant notification path).
|
|
1348
|
+
*/
|
|
1349
|
+
/** YYYY-MM-DDTHH:mm:ss+07:00 (DOKU accepts +07:00 offset) */
|
|
1350
|
+
declare function snapTimestamp(date?: Date): string;
|
|
1351
|
+
/**
|
|
1352
|
+
* UTC ISO8601 timestamp (UTC+0, `Z` suffix) required by the SNAP
|
|
1353
|
+
* Get Token B2B/B2B2C (asymmetric signature) calls. The `stringToSign`
|
|
1354
|
+
* for get-token uses this exact UTC value: `clientId + "|" + X-TIMESTAMP`.
|
|
1355
|
+
*/
|
|
1356
|
+
declare function snapUtcTimestamp(date?: Date): string;
|
|
1357
|
+
/** Compact (minified) JSON — whitespace removed, used as signature input. */
|
|
1358
|
+
declare function minifyJson(obj: any): string;
|
|
1359
|
+
/** Lowercase hex SHA-256 of a minified JSON body. */
|
|
1360
|
+
declare function sha256Hex(body: any): string;
|
|
1361
|
+
/**
|
|
1362
|
+
* Symmetric signature (HMAC-SHA512) used for all SNAP transaction requests
|
|
1363
|
+
* and for verifying incoming DOKU notifications.
|
|
1364
|
+
*
|
|
1365
|
+
* @param clientSecret The DOKU Secret Key (`SK-...`).
|
|
1366
|
+
* @param method HTTP method, e.g. "POST".
|
|
1367
|
+
* @param endpointUrl Request-target path (no host), e.g. "/virtual-accounts/..."
|
|
1368
|
+
* @param accessToken B2B access token WITHOUT the "Bearer " prefix.
|
|
1369
|
+
* @param body request body object or raw string.
|
|
1370
|
+
* @param timestamp X-TIMESTAMP value (must match).
|
|
1371
|
+
*/
|
|
1372
|
+
declare function generateSnapSymmetricSignature(clientSecret: string, method: string, endpointUrl: string, accessToken: string, body: any, timestamp: string): string;
|
|
1373
|
+
/**
|
|
1374
|
+
* Asymmetric signature (SHA256withRSA) used to obtain the B2B access token.
|
|
1375
|
+
*
|
|
1376
|
+
* @param privateKey RSA private key (PEM or base64 raw).
|
|
1377
|
+
* @param clientId Client ID (`doku_key_...`).
|
|
1378
|
+
* @param timestamp X-TIMESTAMP value (must match).
|
|
1379
|
+
* @returns Base64 signature.
|
|
1380
|
+
*/
|
|
1381
|
+
declare function generateSnapAsymmetricSignature(privateKey: string, clientId: string, timestamp: string): string;
|
|
1382
|
+
/** Generate a unique X-EXTERNAL-ID (numeric request id, unique per day). */
|
|
1383
|
+
declare function snapExternalId(prefix?: string): string;
|
|
1384
|
+
/**
|
|
1385
|
+
* Verify an incoming DOKU SNAP webhook notification signature.
|
|
1386
|
+
*
|
|
1387
|
+
* @param headers Incoming request headers (canonical keys assumed).
|
|
1388
|
+
* @param body Parsed request body.
|
|
1389
|
+
* @param clientSecret DOKU Secret Key.
|
|
1390
|
+
* @param endpointUrl Your notification URL request-target, e.g. "/payments/notifications".
|
|
1391
|
+
* @returns true when the X-SIGNATURE matches.
|
|
1392
|
+
*/
|
|
1393
|
+
declare function verifySnapWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientSecret: string, endpointUrl?: string): boolean;
|
|
1394
|
+
|
|
1300
1395
|
/**
|
|
1301
1396
|
* Generate signature PrismaLink
|
|
1302
1397
|
*
|
|
@@ -1450,6 +1545,47 @@ declare function buildTwoCheckoutAuth(merchantCode: string, secretKey: string):
|
|
|
1450
1545
|
*/
|
|
1451
1546
|
declare function verifyTwoCheckoutWebhook(secretWord: string, saleId: string, productId: string, invoiceId: string, providedHash: string): boolean;
|
|
1452
1547
|
|
|
1548
|
+
interface SnapClientOptions {
|
|
1549
|
+
clientId: string;
|
|
1550
|
+
clientSecret: string;
|
|
1551
|
+
privateKey?: string;
|
|
1552
|
+
sandbox?: boolean;
|
|
1553
|
+
merchantId?: string;
|
|
1554
|
+
terminalId?: string;
|
|
1555
|
+
partnerServiceId?: string;
|
|
1556
|
+
channelId?: string;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* DOKU SNAP HTTP client: handles B2B token caching + signed requests
|
|
1560
|
+
* (Create VA, Generate QRIS, e-Wallet payment, query/status).
|
|
1561
|
+
*/
|
|
1562
|
+
declare class SnapClient {
|
|
1563
|
+
private options;
|
|
1564
|
+
private token;
|
|
1565
|
+
private tokenExpiry;
|
|
1566
|
+
constructor(options: Partial<ProviderConfig> & SnapClientOptions);
|
|
1567
|
+
get baseUrl(): string;
|
|
1568
|
+
get isConfigured(): boolean;
|
|
1569
|
+
/**
|
|
1570
|
+
* Get (cached) B2B access token. Mints a new one when expired.
|
|
1571
|
+
*/
|
|
1572
|
+
getAccessToken(): Promise<string>;
|
|
1573
|
+
clearToken(): void;
|
|
1574
|
+
/**
|
|
1575
|
+
* Perform a signed SNAP transaction request.
|
|
1576
|
+
* @param method GET/POST
|
|
1577
|
+
* @param endpoint request-target path (e.g. /virtual-accounts/...)
|
|
1578
|
+
* @param body request body (object)
|
|
1579
|
+
* @param opts extra headers (X-DEVICE-ID, X-IP-ADDRESS, etc.)
|
|
1580
|
+
*/
|
|
1581
|
+
request(method: "GET" | "POST", endpoint: string, body?: any, opts?: {
|
|
1582
|
+
externalId?: string;
|
|
1583
|
+
deviceId?: string;
|
|
1584
|
+
ipAddress?: string;
|
|
1585
|
+
extraHeaders?: Record<string, string>;
|
|
1586
|
+
}): Promise<any>;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1453
1589
|
/**
|
|
1454
1590
|
* Generate MD5 hash string (lowercase)
|
|
1455
1591
|
*/
|
|
@@ -1479,4 +1615,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1479
1615
|
*/
|
|
1480
1616
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1481
1617
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -346,10 +346,38 @@ declare class XenditProvider extends BasePaymentProvider {
|
|
|
346
346
|
declare class DokuProvider extends BasePaymentProvider {
|
|
347
347
|
readonly name = "doku";
|
|
348
348
|
private getBaseUrl;
|
|
349
|
+
/**
|
|
350
|
+
* DETEKSI mode integrasi DOKU:
|
|
351
|
+
* - SNAP : kredensial baru (Client ID `doku_...` + Secret Key `SK-...`) + opsional RSA privateKey
|
|
352
|
+
* untuk Get Token B2B. Diaktifkan via extra.snap / extra.dokuMode="snap" / doku_ prefix.
|
|
353
|
+
* - Legacy: Jokul v2 (Client-Id + Signature HMAC-SHA256), default jika bukan SNAP.
|
|
354
|
+
*/
|
|
355
|
+
private isSnap;
|
|
356
|
+
private buildSnap;
|
|
357
|
+
/** Helper: jumlah integer → format SNAP 2-desimal (".00"). */
|
|
358
|
+
private snapAmount;
|
|
349
359
|
createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
|
|
360
|
+
/**
|
|
361
|
+
* DOKU SNAP: buat transaksi (Create VA / Generate QRIS / e-Wallet Payment).
|
|
362
|
+
* Autentikasi via B2B token + symmetric HMAC-SHA512 signature.
|
|
363
|
+
*/
|
|
364
|
+
private createSnapInvoice;
|
|
365
|
+
/** Create Virtual Account (SNAP) — DOKU Generate Payment Code. */
|
|
366
|
+
private snapCreateVA;
|
|
367
|
+
/** Generate QRIS (SNAP) — dynamic QRIS MPM. */
|
|
368
|
+
private snapGenerateQRIS;
|
|
369
|
+
/** e-Wallet payment (SNAP) — DANA / OVO / ShopeePay via payment-host-to-host. */
|
|
370
|
+
private snapEWalletPayment;
|
|
350
371
|
verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
|
|
372
|
+
/**
|
|
373
|
+
* Verifikasi webhook / notifikasi DOKU SNAP.
|
|
374
|
+
* Signature dibangun dengan symmetric HMAC-SHA512 (AccessToken kosong).
|
|
375
|
+
*/
|
|
376
|
+
private verifySnapCallback;
|
|
351
377
|
getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
|
|
352
378
|
checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
|
|
379
|
+
/** Cek status transaksi SNAP (menggunakan Query QRIS bila ref berasal dari QRIS). */
|
|
380
|
+
private snapCheckTransaction;
|
|
353
381
|
}
|
|
354
382
|
|
|
355
383
|
declare class PrismalinkProvider extends BasePaymentProvider {
|
|
@@ -1297,6 +1325,73 @@ declare function generateDokuHeaders(clientId: string, secretKey: string, reques
|
|
|
1297
1325
|
*/
|
|
1298
1326
|
declare function verifyDokuWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientId: string, secretKey: string, requestTarget?: string): boolean;
|
|
1299
1327
|
|
|
1328
|
+
/**
|
|
1329
|
+
* DOKU SNAP (Standard Open API Pembayaran) helpers.
|
|
1330
|
+
*
|
|
1331
|
+
* SNAP is the Bank Indonesia standardized API that DOKU implements.
|
|
1332
|
+
* It differs from the legacy Jokul v2 HMAC flow:
|
|
1333
|
+
*
|
|
1334
|
+
* 1. Get B2B Access Token (ASYMETRIC):
|
|
1335
|
+
* POST /authorization/v1/access-token/b2b
|
|
1336
|
+
* X-SIGNATURE = Base64( SHA256withRSA( privateKey, clientId + "|" + X-TIMESTAMP ) )
|
|
1337
|
+
* → accessToken (Bearer), expiresIn ~900s
|
|
1338
|
+
*
|
|
1339
|
+
* 2. Transaction (e.g. Create VA / Generate QRIS / e-Wallet) (SYMETRIC):
|
|
1340
|
+
* stringToSign =
|
|
1341
|
+
* HTTPMethod + ":" + EndpointUrl + ":" + AccessToken + ":" +
|
|
1342
|
+
* Lowercase(HexEncode( SHA-256( minify(requestBody) ) )) + ":" + X-TIMESTAMP
|
|
1343
|
+
* X-SIGNATURE = HMAC-SHA512( clientSecret, stringToSign )
|
|
1344
|
+
* Headers: X-PARTNER-ID, X-EXTERNAL-ID, X-TIMESTAMP, CHANNEL-ID, Authorization: Bearer
|
|
1345
|
+
*
|
|
1346
|
+
* 3. Notification / webhook verification (SYMETRIC, same formula as #2 with
|
|
1347
|
+
* AccessToken = "" and EndpointUrl = merchant notification path).
|
|
1348
|
+
*/
|
|
1349
|
+
/** YYYY-MM-DDTHH:mm:ss+07:00 (DOKU accepts +07:00 offset) */
|
|
1350
|
+
declare function snapTimestamp(date?: Date): string;
|
|
1351
|
+
/**
|
|
1352
|
+
* UTC ISO8601 timestamp (UTC+0, `Z` suffix) required by the SNAP
|
|
1353
|
+
* Get Token B2B/B2B2C (asymmetric signature) calls. The `stringToSign`
|
|
1354
|
+
* for get-token uses this exact UTC value: `clientId + "|" + X-TIMESTAMP`.
|
|
1355
|
+
*/
|
|
1356
|
+
declare function snapUtcTimestamp(date?: Date): string;
|
|
1357
|
+
/** Compact (minified) JSON — whitespace removed, used as signature input. */
|
|
1358
|
+
declare function minifyJson(obj: any): string;
|
|
1359
|
+
/** Lowercase hex SHA-256 of a minified JSON body. */
|
|
1360
|
+
declare function sha256Hex(body: any): string;
|
|
1361
|
+
/**
|
|
1362
|
+
* Symmetric signature (HMAC-SHA512) used for all SNAP transaction requests
|
|
1363
|
+
* and for verifying incoming DOKU notifications.
|
|
1364
|
+
*
|
|
1365
|
+
* @param clientSecret The DOKU Secret Key (`SK-...`).
|
|
1366
|
+
* @param method HTTP method, e.g. "POST".
|
|
1367
|
+
* @param endpointUrl Request-target path (no host), e.g. "/virtual-accounts/..."
|
|
1368
|
+
* @param accessToken B2B access token WITHOUT the "Bearer " prefix.
|
|
1369
|
+
* @param body request body object or raw string.
|
|
1370
|
+
* @param timestamp X-TIMESTAMP value (must match).
|
|
1371
|
+
*/
|
|
1372
|
+
declare function generateSnapSymmetricSignature(clientSecret: string, method: string, endpointUrl: string, accessToken: string, body: any, timestamp: string): string;
|
|
1373
|
+
/**
|
|
1374
|
+
* Asymmetric signature (SHA256withRSA) used to obtain the B2B access token.
|
|
1375
|
+
*
|
|
1376
|
+
* @param privateKey RSA private key (PEM or base64 raw).
|
|
1377
|
+
* @param clientId Client ID (`doku_key_...`).
|
|
1378
|
+
* @param timestamp X-TIMESTAMP value (must match).
|
|
1379
|
+
* @returns Base64 signature.
|
|
1380
|
+
*/
|
|
1381
|
+
declare function generateSnapAsymmetricSignature(privateKey: string, clientId: string, timestamp: string): string;
|
|
1382
|
+
/** Generate a unique X-EXTERNAL-ID (numeric request id, unique per day). */
|
|
1383
|
+
declare function snapExternalId(prefix?: string): string;
|
|
1384
|
+
/**
|
|
1385
|
+
* Verify an incoming DOKU SNAP webhook notification signature.
|
|
1386
|
+
*
|
|
1387
|
+
* @param headers Incoming request headers (canonical keys assumed).
|
|
1388
|
+
* @param body Parsed request body.
|
|
1389
|
+
* @param clientSecret DOKU Secret Key.
|
|
1390
|
+
* @param endpointUrl Your notification URL request-target, e.g. "/payments/notifications".
|
|
1391
|
+
* @returns true when the X-SIGNATURE matches.
|
|
1392
|
+
*/
|
|
1393
|
+
declare function verifySnapWebhookSignature(headers: Record<string, string | string[] | undefined>, body: any, clientSecret: string, endpointUrl?: string): boolean;
|
|
1394
|
+
|
|
1300
1395
|
/**
|
|
1301
1396
|
* Generate signature PrismaLink
|
|
1302
1397
|
*
|
|
@@ -1450,6 +1545,47 @@ declare function buildTwoCheckoutAuth(merchantCode: string, secretKey: string):
|
|
|
1450
1545
|
*/
|
|
1451
1546
|
declare function verifyTwoCheckoutWebhook(secretWord: string, saleId: string, productId: string, invoiceId: string, providedHash: string): boolean;
|
|
1452
1547
|
|
|
1548
|
+
interface SnapClientOptions {
|
|
1549
|
+
clientId: string;
|
|
1550
|
+
clientSecret: string;
|
|
1551
|
+
privateKey?: string;
|
|
1552
|
+
sandbox?: boolean;
|
|
1553
|
+
merchantId?: string;
|
|
1554
|
+
terminalId?: string;
|
|
1555
|
+
partnerServiceId?: string;
|
|
1556
|
+
channelId?: string;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* DOKU SNAP HTTP client: handles B2B token caching + signed requests
|
|
1560
|
+
* (Create VA, Generate QRIS, e-Wallet payment, query/status).
|
|
1561
|
+
*/
|
|
1562
|
+
declare class SnapClient {
|
|
1563
|
+
private options;
|
|
1564
|
+
private token;
|
|
1565
|
+
private tokenExpiry;
|
|
1566
|
+
constructor(options: Partial<ProviderConfig> & SnapClientOptions);
|
|
1567
|
+
get baseUrl(): string;
|
|
1568
|
+
get isConfigured(): boolean;
|
|
1569
|
+
/**
|
|
1570
|
+
* Get (cached) B2B access token. Mints a new one when expired.
|
|
1571
|
+
*/
|
|
1572
|
+
getAccessToken(): Promise<string>;
|
|
1573
|
+
clearToken(): void;
|
|
1574
|
+
/**
|
|
1575
|
+
* Perform a signed SNAP transaction request.
|
|
1576
|
+
* @param method GET/POST
|
|
1577
|
+
* @param endpoint request-target path (e.g. /virtual-accounts/...)
|
|
1578
|
+
* @param body request body (object)
|
|
1579
|
+
* @param opts extra headers (X-DEVICE-ID, X-IP-ADDRESS, etc.)
|
|
1580
|
+
*/
|
|
1581
|
+
request(method: "GET" | "POST", endpoint: string, body?: any, opts?: {
|
|
1582
|
+
externalId?: string;
|
|
1583
|
+
deviceId?: string;
|
|
1584
|
+
ipAddress?: string;
|
|
1585
|
+
extraHeaders?: Record<string, string>;
|
|
1586
|
+
}): Promise<any>;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1453
1589
|
/**
|
|
1454
1590
|
* Generate MD5 hash string (lowercase)
|
|
1455
1591
|
*/
|
|
@@ -1479,4 +1615,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1479
1615
|
*/
|
|
1480
1616
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1481
1617
|
|
|
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 };
|
|
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 };
|