@crediblemark/buayar 0.6.0 → 0.6.2

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
@@ -1348,6 +1348,12 @@ declare function verifyDokuWebhookSignature(headers: Record<string, string | str
1348
1348
  */
1349
1349
  /** YYYY-MM-DDTHH:mm:ss+07:00 (DOKU accepts +07:00 offset) */
1350
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;
1351
1357
  /** Compact (minified) JSON — whitespace removed, used as signature input. */
1352
1358
  declare function minifyJson(obj: any): string;
1353
1359
  /** Lowercase hex SHA-256 of a minified JSON body. */
@@ -1609,4 +1615,4 @@ declare function safeCompare(a: string, b: string): boolean;
1609
1615
  */
1610
1616
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
1611
1617
 
1612
- 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, 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 };
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
@@ -1348,6 +1348,12 @@ declare function verifyDokuWebhookSignature(headers: Record<string, string | str
1348
1348
  */
1349
1349
  /** YYYY-MM-DDTHH:mm:ss+07:00 (DOKU accepts +07:00 offset) */
1350
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;
1351
1357
  /** Compact (minified) JSON — whitespace removed, used as signature input. */
1352
1358
  declare function minifyJson(obj: any): string;
1353
1359
  /** Lowercase hex SHA-256 of a minified JSON body. */
@@ -1609,4 +1615,4 @@ declare function safeCompare(a: string, b: string): boolean;
1609
1615
  */
1610
1616
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
1611
1617
 
1612
- 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, 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 };
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.js CHANGED
@@ -123,6 +123,7 @@ __export(index_exports, {
123
123
  sha512: () => sha512,
124
124
  snapExternalId: () => snapExternalId,
125
125
  snapTimestamp: () => snapTimestamp,
126
+ snapUtcTimestamp: () => snapUtcTimestamp,
126
127
  toCanonicalPaymentMethod: () => toCanonicalPaymentMethod,
127
128
  toDokuPaymentMethod: () => toDokuPaymentMethod,
128
129
  toDuitkuPaymentMethod: () => toDuitkuPaymentMethod,
@@ -2577,6 +2578,9 @@ function snapTimestamp(date = /* @__PURE__ */ new Date()) {
2577
2578
  const wib = new Date(date.getTime() + 7 * 60 * 60 * 1e3);
2578
2579
  return wib.toISOString().slice(0, 19) + "+07:00";
2579
2580
  }
2581
+ function snapUtcTimestamp(date = /* @__PURE__ */ new Date()) {
2582
+ return date.toISOString().slice(0, 19) + "Z";
2583
+ }
2580
2584
  function minifyJson(obj) {
2581
2585
  return JSON.stringify(obj);
2582
2586
  }
@@ -2660,7 +2664,7 @@ var SnapClient = class {
2660
2664
  throw new Error("DOKU SNAP: RSA privateKey required to obtain B2B access token");
2661
2665
  }
2662
2666
  const endpoint = "/authorization/v1/access-token/b2b";
2663
- const timestamp = snapTimestamp();
2667
+ const timestamp = snapUtcTimestamp();
2664
2668
  const signature = generateSnapAsymmetricSignature(privateKey, clientId, timestamp);
2665
2669
  const response = await fetch(this.baseUrl + endpoint, {
2666
2670
  method: "POST",
@@ -3033,8 +3037,9 @@ var DokuProvider = class extends BasePaymentProvider {
3033
3037
  const method = String(params.paymentMethod || "").toLowerCase();
3034
3038
  const bankKey = method.replace(/_va$/, "");
3035
3039
  const channel = config.extra?.vaChannel || bankMap[bankKey] || `VIRTUAL_ACCOUNT_${bankKey.toUpperCase()}`;
3036
- const partnerServiceId = (config.extra?.partnerServiceId || "").replace(/\s/g, "");
3037
- const customerNo = (config.extra?.customerNo || "").slice(0, 20) || String(Date.now()).slice(-12);
3040
+ const rawPartnerServiceId = (config.extra?.partnerServiceId || "").replace(/\s/g, "");
3041
+ const partnerServiceId = rawPartnerServiceId.padStart(8, " ").slice(0, 8);
3042
+ const customerNo = (config.extra?.customerNo || "").replace(/\s/g, "").slice(0, 20) || String(Date.now()).slice(-12);
3038
3043
  const virtualAccountNo = (partnerServiceId + customerNo).slice(0, 28);
3039
3044
  const reusable = config.extra?.reusableStatus === true;
3040
3045
  const currency = params.currency || "IDR";
@@ -10114,6 +10119,7 @@ var buayar = new Buayar();
10114
10119
  sha512,
10115
10120
  snapExternalId,
10116
10121
  snapTimestamp,
10122
+ snapUtcTimestamp,
10117
10123
  toCanonicalPaymentMethod,
10118
10124
  toDokuPaymentMethod,
10119
10125
  toDuitkuPaymentMethod,
package/dist/index.mjs CHANGED
@@ -2419,6 +2419,9 @@ function snapTimestamp(date = /* @__PURE__ */ new Date()) {
2419
2419
  const wib = new Date(date.getTime() + 7 * 60 * 60 * 1e3);
2420
2420
  return wib.toISOString().slice(0, 19) + "+07:00";
2421
2421
  }
2422
+ function snapUtcTimestamp(date = /* @__PURE__ */ new Date()) {
2423
+ return date.toISOString().slice(0, 19) + "Z";
2424
+ }
2422
2425
  function minifyJson(obj) {
2423
2426
  return JSON.stringify(obj);
2424
2427
  }
@@ -2502,7 +2505,7 @@ var SnapClient = class {
2502
2505
  throw new Error("DOKU SNAP: RSA privateKey required to obtain B2B access token");
2503
2506
  }
2504
2507
  const endpoint = "/authorization/v1/access-token/b2b";
2505
- const timestamp = snapTimestamp();
2508
+ const timestamp = snapUtcTimestamp();
2506
2509
  const signature = generateSnapAsymmetricSignature(privateKey, clientId, timestamp);
2507
2510
  const response = await fetch(this.baseUrl + endpoint, {
2508
2511
  method: "POST",
@@ -2875,8 +2878,9 @@ var DokuProvider = class extends BasePaymentProvider {
2875
2878
  const method = String(params.paymentMethod || "").toLowerCase();
2876
2879
  const bankKey = method.replace(/_va$/, "");
2877
2880
  const channel = config.extra?.vaChannel || bankMap[bankKey] || `VIRTUAL_ACCOUNT_${bankKey.toUpperCase()}`;
2878
- const partnerServiceId = (config.extra?.partnerServiceId || "").replace(/\s/g, "");
2879
- const customerNo = (config.extra?.customerNo || "").slice(0, 20) || String(Date.now()).slice(-12);
2881
+ const rawPartnerServiceId = (config.extra?.partnerServiceId || "").replace(/\s/g, "");
2882
+ const partnerServiceId = rawPartnerServiceId.padStart(8, " ").slice(0, 8);
2883
+ const customerNo = (config.extra?.customerNo || "").replace(/\s/g, "").slice(0, 20) || String(Date.now()).slice(-12);
2880
2884
  const virtualAccountNo = (partnerServiceId + customerNo).slice(0, 28);
2881
2885
  const reusable = config.extra?.reusableStatus === true;
2882
2886
  const currency = params.currency || "IDR";
@@ -9955,6 +9959,7 @@ export {
9955
9959
  sha512,
9956
9960
  snapExternalId,
9957
9961
  snapTimestamp,
9962
+ snapUtcTimestamp,
9958
9963
  toCanonicalPaymentMethod,
9959
9964
  toDokuPaymentMethod,
9960
9965
  toDuitkuPaymentMethod,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crediblemark/buayar",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Unified Payment Gateway SDK for Node.js & TypeScript — 19 providers (Midtrans, Xendit, Duitku, Stripe, PayPal, Adyen, Razorpay, Square, Checkout.com, PayU, Braintree, 2Checkout, DOKU, iPaymu, PrismaLink, Faspay, Finpay, Nicepay, OY!) with zero-code switching via .env",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",