@crediblemark/buayar 0.8.2 → 0.8.4
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 +1 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +57 -4
- package/dist/index.mjs +54 -4
- package/docs/ipaymu.md +13 -3
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1523,6 +1523,29 @@ declare function generateIpaymuSignature(method: "GET" | "POST", va: string, api
|
|
|
1523
1523
|
signature: string;
|
|
1524
1524
|
timestamp: string;
|
|
1525
1525
|
};
|
|
1526
|
+
/**
|
|
1527
|
+
* Normalisasi payload callback iPaymu agar identik dengan apa yang
|
|
1528
|
+
* ditandatangani iPaymu (merujuk dokumentasi resmi callback):
|
|
1529
|
+
* - trx_id / status_code / transaction_status_code / paid_off → Integer
|
|
1530
|
+
* - is_escrow → Boolean
|
|
1531
|
+
* - additional_info "[]" (string) → [] (array); tambah [] saat field tidak ada
|
|
1532
|
+
* - field lain → String
|
|
1533
|
+
* - field "signature" (bila ikut terkirim di body) dibuang dari perhitungan
|
|
1534
|
+
*/
|
|
1535
|
+
declare function normalizeIpaymuCallback(payload: any): Record<string, any>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Bangun string JSON yang ditandatangani iPaymu untuk verifikasi callback:
|
|
1538
|
+
* - key diurutkan ascending (A-Z) dengan sort case-sensitif
|
|
1539
|
+
* - forward slash di-escape menjadi "\/" sesuai standar PHP json_encode
|
|
1540
|
+
*/
|
|
1541
|
+
declare function buildIpaymuCallbackString(payload: any): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Verifikasi signature callback iPaymu.
|
|
1544
|
+
* Secret key = Nomor VA (Merchant VA) akun iPaymu; dibandingkan dengan
|
|
1545
|
+
* nilai header X-Signature menggunakan perbandingan timing-safe.
|
|
1546
|
+
* Tanpa header signature atau secret → INVALID.
|
|
1547
|
+
*/
|
|
1548
|
+
declare function verifyIpaymuCallbackSignature(payload: any, secretKey: string, xSignature?: string): boolean;
|
|
1526
1549
|
/**
|
|
1527
1550
|
* Verifikasi callback webhook dari iPaymu
|
|
1528
1551
|
*/
|
|
@@ -1870,4 +1893,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1870
1893
|
*/
|
|
1871
1894
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1872
1895
|
|
|
1873
|
-
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 };
|
|
1896
|
+
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, buildIpaymuCallbackString, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, normalizeIpaymuCallback, 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, verifyIpaymuCallbackSignature, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1523,6 +1523,29 @@ declare function generateIpaymuSignature(method: "GET" | "POST", va: string, api
|
|
|
1523
1523
|
signature: string;
|
|
1524
1524
|
timestamp: string;
|
|
1525
1525
|
};
|
|
1526
|
+
/**
|
|
1527
|
+
* Normalisasi payload callback iPaymu agar identik dengan apa yang
|
|
1528
|
+
* ditandatangani iPaymu (merujuk dokumentasi resmi callback):
|
|
1529
|
+
* - trx_id / status_code / transaction_status_code / paid_off → Integer
|
|
1530
|
+
* - is_escrow → Boolean
|
|
1531
|
+
* - additional_info "[]" (string) → [] (array); tambah [] saat field tidak ada
|
|
1532
|
+
* - field lain → String
|
|
1533
|
+
* - field "signature" (bila ikut terkirim di body) dibuang dari perhitungan
|
|
1534
|
+
*/
|
|
1535
|
+
declare function normalizeIpaymuCallback(payload: any): Record<string, any>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Bangun string JSON yang ditandatangani iPaymu untuk verifikasi callback:
|
|
1538
|
+
* - key diurutkan ascending (A-Z) dengan sort case-sensitif
|
|
1539
|
+
* - forward slash di-escape menjadi "\/" sesuai standar PHP json_encode
|
|
1540
|
+
*/
|
|
1541
|
+
declare function buildIpaymuCallbackString(payload: any): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Verifikasi signature callback iPaymu.
|
|
1544
|
+
* Secret key = Nomor VA (Merchant VA) akun iPaymu; dibandingkan dengan
|
|
1545
|
+
* nilai header X-Signature menggunakan perbandingan timing-safe.
|
|
1546
|
+
* Tanpa header signature atau secret → INVALID.
|
|
1547
|
+
*/
|
|
1548
|
+
declare function verifyIpaymuCallbackSignature(payload: any, secretKey: string, xSignature?: string): boolean;
|
|
1526
1549
|
/**
|
|
1527
1550
|
* Verifikasi callback webhook dari iPaymu
|
|
1528
1551
|
*/
|
|
@@ -1870,4 +1893,4 @@ declare function safeCompare(a: string, b: string): boolean;
|
|
|
1870
1893
|
*/
|
|
1871
1894
|
declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
|
|
1872
1895
|
|
|
1873
|
-
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 };
|
|
1896
|
+
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, buildIpaymuCallbackString, buildPaypalBasicAuth, buildPayuBasicAuth, buildRazorpayBasicAuth, buildTwoCheckoutAuth, formatNicepayTimestamp, generateDokuHeaders, generateFaspaySignature, generateFinpaySignature, generateIpaymuSignature, generateNicepayToken, generateOyHeaders, generatePrismalinkSignature, generateSnapAsymmetricSignature, generateSnapSymmetricSignature, getDuitkuInquirySignatures, getDuitkuPaymentMethodsSignature, getDuitkuStatusSignatures, getPaymentMethodCategory, getXenditAuthHeader, hmacSha256, md5, minifyJson, normalizeIpaymuCallback, 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, verifyIpaymuCallbackSignature, verifyNicepayWebhook, verifyOyWebhook, verifyPaypalWebhookSimple, verifyPayuWebhook, verifyPrismalinkSignature, verifyRazorpayWebhook, verifySnapWebhookSignature, verifySquareWebhook, verifyStripeWebhook, verifyTwoCheckoutWebhook, verifyXenditWebhookToken };
|
package/dist/index.js
CHANGED
|
@@ -93,6 +93,7 @@ __export(index_exports, {
|
|
|
93
93
|
buildBraintreeBasicAuth: () => buildBraintreeBasicAuth,
|
|
94
94
|
buildCoreChargePayload: () => buildCoreChargePayload,
|
|
95
95
|
buildDefaultDescriptors: () => buildDefaultDescriptors,
|
|
96
|
+
buildIpaymuCallbackString: () => buildIpaymuCallbackString,
|
|
96
97
|
buildPaypalBasicAuth: () => buildPaypalBasicAuth,
|
|
97
98
|
buildPayuBasicAuth: () => buildPayuBasicAuth,
|
|
98
99
|
buildRazorpayBasicAuth: () => buildRazorpayBasicAuth,
|
|
@@ -115,6 +116,7 @@ __export(index_exports, {
|
|
|
115
116
|
hmacSha256: () => hmacSha256,
|
|
116
117
|
md5: () => md5,
|
|
117
118
|
minifyJson: () => minifyJson,
|
|
119
|
+
normalizeIpaymuCallback: () => normalizeIpaymuCallback,
|
|
118
120
|
parseCoreChargeResponse: () => parseCoreChargeResponse,
|
|
119
121
|
paymentManager: () => paymentManager,
|
|
120
122
|
providerRegistry: () => providerRegistry,
|
|
@@ -148,6 +150,7 @@ __export(index_exports, {
|
|
|
148
150
|
verifyFaspaySignature: () => verifyFaspaySignature,
|
|
149
151
|
verifyFinpaySignature: () => verifyFinpaySignature,
|
|
150
152
|
verifyIpaymuCallback: () => verifyIpaymuCallback,
|
|
153
|
+
verifyIpaymuCallbackSignature: () => verifyIpaymuCallbackSignature,
|
|
151
154
|
verifyNicepayWebhook: () => verifyNicepayWebhook,
|
|
152
155
|
verifyOyWebhook: () => verifyOyWebhook,
|
|
153
156
|
verifyPaypalWebhookSimple: () => verifyPaypalWebhookSimple,
|
|
@@ -1728,6 +1731,44 @@ function generateIpaymuSignature(method, va, apiKey, body) {
|
|
|
1728
1731
|
const signature = hmacSha256(stringToSign, apiKey);
|
|
1729
1732
|
return { signature, timestamp };
|
|
1730
1733
|
}
|
|
1734
|
+
function normalizeIpaymuCallback(payload) {
|
|
1735
|
+
const result = {};
|
|
1736
|
+
for (const key of Object.keys(payload || {})) {
|
|
1737
|
+
const val = payload[key];
|
|
1738
|
+
if (key === "is_escrow") {
|
|
1739
|
+
result[key] = val === "true" || val === "1" || val === 1 || val === true;
|
|
1740
|
+
} else if (["trx_id", "status_code", "transaction_status_code", "paid_off"].includes(key)) {
|
|
1741
|
+
const intVal = parseInt(String(val), 10);
|
|
1742
|
+
result[key] = Number.isNaN(intVal) ? 0 : intVal;
|
|
1743
|
+
} else if (key === "additional_info") {
|
|
1744
|
+
result[key] = val === "[]" || val === "null" ? [] : val;
|
|
1745
|
+
} else if (key === "signature") {
|
|
1746
|
+
continue;
|
|
1747
|
+
} else {
|
|
1748
|
+
result[key] = String(val);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
if (!Object.prototype.hasOwnProperty.call(result, "additional_info")) {
|
|
1752
|
+
result.additional_info = [];
|
|
1753
|
+
}
|
|
1754
|
+
return result;
|
|
1755
|
+
}
|
|
1756
|
+
function buildIpaymuCallbackString(payload) {
|
|
1757
|
+
const normalized = normalizeIpaymuCallback(payload);
|
|
1758
|
+
const sorted = {};
|
|
1759
|
+
for (const key of Object.keys(normalized).sort((a, b) => a.localeCompare(b))) {
|
|
1760
|
+
sorted[key] = normalized[key];
|
|
1761
|
+
}
|
|
1762
|
+
let json = JSON.stringify(sorted);
|
|
1763
|
+
json = json.replace(/\//g, "\\/");
|
|
1764
|
+
return json;
|
|
1765
|
+
}
|
|
1766
|
+
function verifyIpaymuCallbackSignature(payload, secretKey, xSignature) {
|
|
1767
|
+
if (!secretKey || !xSignature) return false;
|
|
1768
|
+
const stringToSign = buildIpaymuCallbackString(payload);
|
|
1769
|
+
const computed = hmacSha256(stringToSign, secretKey);
|
|
1770
|
+
return safeCompare(String(xSignature).toLowerCase(), computed.toLowerCase());
|
|
1771
|
+
}
|
|
1731
1772
|
function verifyIpaymuCallback(payload) {
|
|
1732
1773
|
const status = (payload.status || "").toLowerCase();
|
|
1733
1774
|
const statusCode = payload.status_code !== void 0 ? String(payload.status_code) : "";
|
|
@@ -1893,15 +1934,20 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1893
1934
|
const { isPaid, isPending, isFailed } = verifyIpaymuCallback(body);
|
|
1894
1935
|
const orderId = body.reference_id || body.referenceId || body.trx_id || "";
|
|
1895
1936
|
const amount = body.amount || body.total || 0;
|
|
1937
|
+
const secretKey = config.merchantCode || config.merchantId || "";
|
|
1938
|
+
const headers = config.extra?.headers || {};
|
|
1939
|
+
const rawSig = headers["x-signature"] ?? headers["X-Signature"] ?? "";
|
|
1940
|
+
const xSignature = Array.isArray(rawSig) ? rawSig[0] : rawSig;
|
|
1941
|
+
const isValid = verifyIpaymuCallbackSignature(body, secretKey, xSignature);
|
|
1896
1942
|
return {
|
|
1897
|
-
isValid
|
|
1943
|
+
isValid,
|
|
1898
1944
|
provider: "ipaymu",
|
|
1899
1945
|
orderId: String(orderId),
|
|
1900
1946
|
amount: Number(amount) || 0,
|
|
1901
1947
|
status: isPaid ? "paid" : isPending ? "pending" : "failed",
|
|
1902
|
-
isPaid,
|
|
1903
|
-
isPending,
|
|
1904
|
-
isFailed,
|
|
1948
|
+
isPaid: isValid && isPaid,
|
|
1949
|
+
isPending: isValid && isPending,
|
|
1950
|
+
isFailed: !isValid || isFailed,
|
|
1905
1951
|
isExpired: (body.status || "").toLowerCase() === "expired",
|
|
1906
1952
|
statusCode: String(body.status_code || body.status || ""),
|
|
1907
1953
|
rawPayload: body
|
|
@@ -1984,6 +2030,10 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1984
2030
|
feeDetail: ch.TransactionFee
|
|
1985
2031
|
}
|
|
1986
2032
|
};
|
|
2033
|
+
const health = String(ch.HealthStatus || "").toLowerCase();
|
|
2034
|
+
const feature = String(ch.FeatureStatus || "").toLowerCase();
|
|
2035
|
+
const explicitlyUnavailable = feature !== "" && feature !== "active" || health !== "" && health !== "online";
|
|
2036
|
+
if (explicitlyUnavailable) continue;
|
|
1987
2037
|
methods.push(pm);
|
|
1988
2038
|
if (!categories[category]) categories[category] = [];
|
|
1989
2039
|
categories[category].push(pm);
|
|
@@ -10478,6 +10528,7 @@ var buayar = new Buayar();
|
|
|
10478
10528
|
buildBraintreeBasicAuth,
|
|
10479
10529
|
buildCoreChargePayload,
|
|
10480
10530
|
buildDefaultDescriptors,
|
|
10531
|
+
buildIpaymuCallbackString,
|
|
10481
10532
|
buildPaypalBasicAuth,
|
|
10482
10533
|
buildPayuBasicAuth,
|
|
10483
10534
|
buildRazorpayBasicAuth,
|
|
@@ -10500,6 +10551,7 @@ var buayar = new Buayar();
|
|
|
10500
10551
|
hmacSha256,
|
|
10501
10552
|
md5,
|
|
10502
10553
|
minifyJson,
|
|
10554
|
+
normalizeIpaymuCallback,
|
|
10503
10555
|
parseCoreChargeResponse,
|
|
10504
10556
|
paymentManager,
|
|
10505
10557
|
providerRegistry,
|
|
@@ -10533,6 +10585,7 @@ var buayar = new Buayar();
|
|
|
10533
10585
|
verifyFaspaySignature,
|
|
10534
10586
|
verifyFinpaySignature,
|
|
10535
10587
|
verifyIpaymuCallback,
|
|
10588
|
+
verifyIpaymuCallbackSignature,
|
|
10536
10589
|
verifyNicepayWebhook,
|
|
10537
10590
|
verifyOyWebhook,
|
|
10538
10591
|
verifyPaypalWebhookSimple,
|
package/dist/index.mjs
CHANGED
|
@@ -1564,6 +1564,44 @@ function generateIpaymuSignature(method, va, apiKey, body) {
|
|
|
1564
1564
|
const signature = hmacSha256(stringToSign, apiKey);
|
|
1565
1565
|
return { signature, timestamp };
|
|
1566
1566
|
}
|
|
1567
|
+
function normalizeIpaymuCallback(payload) {
|
|
1568
|
+
const result = {};
|
|
1569
|
+
for (const key of Object.keys(payload || {})) {
|
|
1570
|
+
const val = payload[key];
|
|
1571
|
+
if (key === "is_escrow") {
|
|
1572
|
+
result[key] = val === "true" || val === "1" || val === 1 || val === true;
|
|
1573
|
+
} else if (["trx_id", "status_code", "transaction_status_code", "paid_off"].includes(key)) {
|
|
1574
|
+
const intVal = parseInt(String(val), 10);
|
|
1575
|
+
result[key] = Number.isNaN(intVal) ? 0 : intVal;
|
|
1576
|
+
} else if (key === "additional_info") {
|
|
1577
|
+
result[key] = val === "[]" || val === "null" ? [] : val;
|
|
1578
|
+
} else if (key === "signature") {
|
|
1579
|
+
continue;
|
|
1580
|
+
} else {
|
|
1581
|
+
result[key] = String(val);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
if (!Object.prototype.hasOwnProperty.call(result, "additional_info")) {
|
|
1585
|
+
result.additional_info = [];
|
|
1586
|
+
}
|
|
1587
|
+
return result;
|
|
1588
|
+
}
|
|
1589
|
+
function buildIpaymuCallbackString(payload) {
|
|
1590
|
+
const normalized = normalizeIpaymuCallback(payload);
|
|
1591
|
+
const sorted = {};
|
|
1592
|
+
for (const key of Object.keys(normalized).sort((a, b) => a.localeCompare(b))) {
|
|
1593
|
+
sorted[key] = normalized[key];
|
|
1594
|
+
}
|
|
1595
|
+
let json = JSON.stringify(sorted);
|
|
1596
|
+
json = json.replace(/\//g, "\\/");
|
|
1597
|
+
return json;
|
|
1598
|
+
}
|
|
1599
|
+
function verifyIpaymuCallbackSignature(payload, secretKey, xSignature) {
|
|
1600
|
+
if (!secretKey || !xSignature) return false;
|
|
1601
|
+
const stringToSign = buildIpaymuCallbackString(payload);
|
|
1602
|
+
const computed = hmacSha256(stringToSign, secretKey);
|
|
1603
|
+
return safeCompare(String(xSignature).toLowerCase(), computed.toLowerCase());
|
|
1604
|
+
}
|
|
1567
1605
|
function verifyIpaymuCallback(payload) {
|
|
1568
1606
|
const status = (payload.status || "").toLowerCase();
|
|
1569
1607
|
const statusCode = payload.status_code !== void 0 ? String(payload.status_code) : "";
|
|
@@ -1729,15 +1767,20 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1729
1767
|
const { isPaid, isPending, isFailed } = verifyIpaymuCallback(body);
|
|
1730
1768
|
const orderId = body.reference_id || body.referenceId || body.trx_id || "";
|
|
1731
1769
|
const amount = body.amount || body.total || 0;
|
|
1770
|
+
const secretKey = config.merchantCode || config.merchantId || "";
|
|
1771
|
+
const headers = config.extra?.headers || {};
|
|
1772
|
+
const rawSig = headers["x-signature"] ?? headers["X-Signature"] ?? "";
|
|
1773
|
+
const xSignature = Array.isArray(rawSig) ? rawSig[0] : rawSig;
|
|
1774
|
+
const isValid = verifyIpaymuCallbackSignature(body, secretKey, xSignature);
|
|
1732
1775
|
return {
|
|
1733
|
-
isValid
|
|
1776
|
+
isValid,
|
|
1734
1777
|
provider: "ipaymu",
|
|
1735
1778
|
orderId: String(orderId),
|
|
1736
1779
|
amount: Number(amount) || 0,
|
|
1737
1780
|
status: isPaid ? "paid" : isPending ? "pending" : "failed",
|
|
1738
|
-
isPaid,
|
|
1739
|
-
isPending,
|
|
1740
|
-
isFailed,
|
|
1781
|
+
isPaid: isValid && isPaid,
|
|
1782
|
+
isPending: isValid && isPending,
|
|
1783
|
+
isFailed: !isValid || isFailed,
|
|
1741
1784
|
isExpired: (body.status || "").toLowerCase() === "expired",
|
|
1742
1785
|
statusCode: String(body.status_code || body.status || ""),
|
|
1743
1786
|
rawPayload: body
|
|
@@ -1820,6 +1863,10 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1820
1863
|
feeDetail: ch.TransactionFee
|
|
1821
1864
|
}
|
|
1822
1865
|
};
|
|
1866
|
+
const health = String(ch.HealthStatus || "").toLowerCase();
|
|
1867
|
+
const feature = String(ch.FeatureStatus || "").toLowerCase();
|
|
1868
|
+
const explicitlyUnavailable = feature !== "" && feature !== "active" || health !== "" && health !== "online";
|
|
1869
|
+
if (explicitlyUnavailable) continue;
|
|
1823
1870
|
methods.push(pm);
|
|
1824
1871
|
if (!categories[category]) categories[category] = [];
|
|
1825
1872
|
categories[category].push(pm);
|
|
@@ -10313,6 +10360,7 @@ export {
|
|
|
10313
10360
|
buildBraintreeBasicAuth,
|
|
10314
10361
|
buildCoreChargePayload,
|
|
10315
10362
|
buildDefaultDescriptors,
|
|
10363
|
+
buildIpaymuCallbackString,
|
|
10316
10364
|
buildPaypalBasicAuth,
|
|
10317
10365
|
buildPayuBasicAuth,
|
|
10318
10366
|
buildRazorpayBasicAuth,
|
|
@@ -10335,6 +10383,7 @@ export {
|
|
|
10335
10383
|
hmacSha256,
|
|
10336
10384
|
md5,
|
|
10337
10385
|
minifyJson,
|
|
10386
|
+
normalizeIpaymuCallback,
|
|
10338
10387
|
parseCoreChargeResponse,
|
|
10339
10388
|
paymentManager,
|
|
10340
10389
|
providerRegistry,
|
|
@@ -10368,6 +10417,7 @@ export {
|
|
|
10368
10417
|
verifyFaspaySignature,
|
|
10369
10418
|
verifyFinpaySignature,
|
|
10370
10419
|
verifyIpaymuCallback,
|
|
10420
|
+
verifyIpaymuCallbackSignature,
|
|
10371
10421
|
verifyNicepayWebhook,
|
|
10372
10422
|
verifyOyWebhook,
|
|
10373
10423
|
verifyPaypalWebhookSimple,
|
package/docs/ipaymu.md
CHANGED
|
@@ -80,6 +80,11 @@ if (result.success) {
|
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
> **Automatis filter availability:** Buayar hanya mengembalikan saluran yang benar-benar
|
|
84
|
+
> tersedia — saluran dengan `FeatureStatus` selain `"active"` (mis. `inactive`, `disabled`, `suspended`)
|
|
85
|
+
> atau `HealthStatus` selain `"online"` (mis. `offline`, `maintenance`) **otomatis dibuang** dari daftar.
|
|
86
|
+
> Jadi metode yang muncul selalu berasal dari data real-time iPaymu, bukan asumsi.
|
|
87
|
+
|
|
83
88
|
---
|
|
84
89
|
|
|
85
90
|
## 4. Pembuatan Tagihan (Invoice)
|
|
@@ -249,12 +254,17 @@ const banks = await client.getBankList();
|
|
|
249
254
|
|
|
250
255
|
## 9. Webhook & Verifikasi Notifikasi Callback
|
|
251
256
|
|
|
252
|
-
Saat pembeli menyelesaikan pembayaran, iPaymu mengirimkan HTTP POST request ke `notifyUrl
|
|
257
|
+
Saat pembeli menyelesaikan pembayaran, iPaymu mengirimkan HTTP POST request ke `notifyUrl`.
|
|
258
|
+
Callback **harus** membawa header `X-Signature`; Buayar memverifikasinya dengan
|
|
259
|
+
**HMAC-SHA256** atas payload callback yang dinormalisasi (sort kunci A–Z + escape slash)
|
|
260
|
+
menggunakan **Merchant VA** sebagai secret key. Callback tanpa `X-Signature` yang sah
|
|
261
|
+
akan selalu ditolak (`isValid === false`).
|
|
253
262
|
|
|
254
263
|
```typescript
|
|
255
|
-
// Di handler Express.js / Next.js API route:
|
|
264
|
+
// Di handler Express.js / Next.js API route + REST framework apapun (Elysia/Hono/...):
|
|
256
265
|
app.post("/api/payment/webhook", (req, res) => {
|
|
257
|
-
|
|
266
|
+
// Header request (termasuk `x-signature`) WAJIB diferuskan:
|
|
267
|
+
const result = buayar.verifyWebhook(req.body, req.headers);
|
|
258
268
|
|
|
259
269
|
if (result.isValid && result.isPaid) {
|
|
260
270
|
console.log("Pembayaran Berhasil untuk Order ID:", result.orderId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crediblemark/buayar",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
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",
|