@crediblemark/buayar 0.8.0 → 0.8.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/README.md +18 -18
- package/dist/cli/index.js +1 -1
- package/dist/index.d.mts +77 -17
- package/dist/index.d.ts +77 -17
- package/dist/index.js +213 -229
- package/dist/index.mjs +213 -229
- package/docs/guide.md +19 -19
- package/docs/ipaymu.md +295 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -288,16 +288,20 @@ var CANONICAL_TO_IPAYMU = {
|
|
|
288
288
|
danamon_va: { paymentMethod: "va", paymentChannel: "danamon" },
|
|
289
289
|
bsi_va: { paymentMethod: "va", paymentChannel: "bsi" },
|
|
290
290
|
bag_va: { paymentMethod: "va", paymentChannel: "bag" },
|
|
291
|
+
btn_va: { paymentMethod: "va", paymentChannel: "btn" },
|
|
291
292
|
muamalat_va: { paymentMethod: "va", paymentChannel: "bmi" },
|
|
292
293
|
bmi_va: { paymentMethod: "va", paymentChannel: "bmi" },
|
|
293
294
|
qris: { paymentMethod: "qris", paymentChannel: "mpm" },
|
|
294
295
|
gopay_qris: { paymentMethod: "qris", paymentChannel: "mpm" },
|
|
295
296
|
shopeepay_qris: { paymentMethod: "qris", paymentChannel: "mpm" },
|
|
297
|
+
dana: { paymentMethod: "ewallet", paymentChannel: "dana" },
|
|
298
|
+
shopeepay: { paymentMethod: "ewallet", paymentChannel: "shopeepay" },
|
|
296
299
|
alfamart: { paymentMethod: "cstore", paymentChannel: "alfamart" },
|
|
297
300
|
indomaret: { paymentMethod: "cstore", paymentChannel: "indomaret" },
|
|
298
301
|
credit_card: { paymentMethod: "cc", paymentChannel: "cc" },
|
|
299
302
|
akulaku: { paymentMethod: "paylater", paymentChannel: "akulaku" },
|
|
300
|
-
kredivo: { paymentMethod: "paylater", paymentChannel: "kredivo" }
|
|
303
|
+
kredivo: { paymentMethod: "paylater", paymentChannel: "kredivo" },
|
|
304
|
+
cod: { paymentMethod: "cod", paymentChannel: "cod" }
|
|
301
305
|
};
|
|
302
306
|
var CANONICAL_TO_XENDIT = {
|
|
303
307
|
bca_va: { type: "VIRTUAL_ACCOUNT", channel_code: "BCA" },
|
|
@@ -482,6 +486,9 @@ function toIpaymuPaymentMethod(code) {
|
|
|
482
486
|
if (lower.includes("alfa") || lower.includes("indo")) {
|
|
483
487
|
return { paymentMethod: "cstore", paymentChannel: lower };
|
|
484
488
|
}
|
|
489
|
+
if (lower.includes("dana") || lower.includes("shopee") || lower.includes("ovo") || lower.includes("gopay") || lower.includes("linkaja")) {
|
|
490
|
+
return { paymentMethod: "ewallet", paymentChannel: lower };
|
|
491
|
+
}
|
|
485
492
|
return { paymentMethod: lower };
|
|
486
493
|
}
|
|
487
494
|
function toXenditPaymentMethod(code) {
|
|
@@ -1715,8 +1722,8 @@ var MidtransProvider = class extends BasePaymentProvider {
|
|
|
1715
1722
|
// src/providers/ipaymu/signature.ts
|
|
1716
1723
|
function generateIpaymuSignature(method, va, apiKey, body) {
|
|
1717
1724
|
const timestamp = Date.now().toString();
|
|
1718
|
-
const bodyString = body ? typeof body === "string" ? body : JSON.stringify(body) : "";
|
|
1719
|
-
const bodyHash =
|
|
1725
|
+
const bodyString = body ? typeof body === "string" ? body : JSON.stringify(body) : "{}";
|
|
1726
|
+
const bodyHash = sha256(bodyString).toLowerCase();
|
|
1720
1727
|
const stringToSign = `${method.toUpperCase()}:${va}:${bodyHash}:${apiKey}`;
|
|
1721
1728
|
const signature = hmacSha256(stringToSign, apiKey);
|
|
1722
1729
|
return { signature, timestamp };
|
|
@@ -1751,6 +1758,7 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1751
1758
|
const redirectUrl = returnUrl || config.returnUrl || "https://localhost/return";
|
|
1752
1759
|
const feeDirection = params.feeDirection || params.extra?.feeDirection || config.extra?.feeDirection;
|
|
1753
1760
|
const escrow = params.escrow !== void 0 ? params.escrow : params.extra?.escrow !== void 0 ? params.extra?.escrow : config.extra?.escrow;
|
|
1761
|
+
const subAccount = params.subAccountId || params.extra?.subAccountId || params.extra?.account || params.extra?.childAccount || params.account || config.extra?.account;
|
|
1754
1762
|
let payload;
|
|
1755
1763
|
if (isDirect) {
|
|
1756
1764
|
payload = {
|
|
@@ -1767,6 +1775,7 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1767
1775
|
...ipaymuMethod.paymentChannel ? { paymentChannel: ipaymuMethod.paymentChannel } : {},
|
|
1768
1776
|
...feeDirection ? { feeDirection } : {},
|
|
1769
1777
|
...escrow !== void 0 ? { escrow } : {},
|
|
1778
|
+
...subAccount ? { account: subAccount } : {},
|
|
1770
1779
|
...params.providerParams
|
|
1771
1780
|
};
|
|
1772
1781
|
} else {
|
|
@@ -1789,6 +1798,7 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1789
1798
|
buyerPhone: customer.phone || "081234567890",
|
|
1790
1799
|
...feeDirection ? { feeDirection } : {},
|
|
1791
1800
|
...escrow !== void 0 ? { escrow } : {},
|
|
1801
|
+
...subAccount ? { account: subAccount } : {},
|
|
1792
1802
|
...params.providerParams
|
|
1793
1803
|
};
|
|
1794
1804
|
}
|
|
@@ -1836,13 +1846,23 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1836
1846
|
if (ipaymuMethod?.paymentMethod === "va") {
|
|
1837
1847
|
res.vaNumber = resData.PaymentNo;
|
|
1838
1848
|
res.vaBank = ipaymuMethod.paymentChannel;
|
|
1849
|
+
res.mode = "va";
|
|
1839
1850
|
} else if (ipaymuMethod?.paymentMethod === "cstore") {
|
|
1840
1851
|
res.paymentCode = resData.PaymentNo;
|
|
1852
|
+
res.mode = "retail";
|
|
1841
1853
|
}
|
|
1842
1854
|
}
|
|
1843
1855
|
if (resData.QrString || resData.QrImage) {
|
|
1844
1856
|
res.qrString = resData.QrString;
|
|
1845
1857
|
res.qrCodeUrl = resData.QrImage || resData.QrTemplate;
|
|
1858
|
+
res.mode = "qris";
|
|
1859
|
+
}
|
|
1860
|
+
if (ipaymuMethod?.paymentMethod === "ewallet") {
|
|
1861
|
+
res.mode = "ewallet";
|
|
1862
|
+
if (resData.Url) {
|
|
1863
|
+
res.deeplink = resData.Url;
|
|
1864
|
+
res.paymentUrl = resData.Url;
|
|
1865
|
+
}
|
|
1846
1866
|
}
|
|
1847
1867
|
if (resData.Expired) {
|
|
1848
1868
|
res.expiresAt = new Date(resData.Expired);
|
|
@@ -1891,221 +1911,110 @@ var IpaymuProvider = class extends BasePaymentProvider {
|
|
|
1891
1911
|
const va = config.merchantCode || config.merchantId || "";
|
|
1892
1912
|
const apiKey = config.apiKey || "";
|
|
1893
1913
|
const sandbox = !!config.sandbox;
|
|
1894
|
-
if (va
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1914
|
+
if (!va || !apiKey) {
|
|
1915
|
+
return {
|
|
1916
|
+
success: false,
|
|
1917
|
+
provider: "ipaymu",
|
|
1918
|
+
methods: [],
|
|
1919
|
+
categories: {},
|
|
1920
|
+
error: "Missing iPaymu credentials (BUAYAR_MERCHANT_CODE/VA or BUAYAR_API_KEY)",
|
|
1921
|
+
rawResponse: null
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
try {
|
|
1925
|
+
const url = `${this.getBaseUrl(sandbox)}/payment-channels`;
|
|
1926
|
+
const { signature, timestamp } = generateIpaymuSignature("GET", va, apiKey);
|
|
1927
|
+
const response = await fetch(url, {
|
|
1928
|
+
method: "GET",
|
|
1929
|
+
headers: {
|
|
1930
|
+
"Content-Type": "application/json",
|
|
1931
|
+
"Accept": "application/json",
|
|
1932
|
+
"va": va,
|
|
1933
|
+
"signature": signature,
|
|
1934
|
+
"timestamp": timestamp
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
const data = await response.json().catch(() => null);
|
|
1938
|
+
if (response.ok && data?.Data && Array.isArray(data.Data)) {
|
|
1939
|
+
const methods = [];
|
|
1940
|
+
const categories = {};
|
|
1941
|
+
for (const group of data.Data) {
|
|
1942
|
+
const groupCode = (group.Code || "").toLowerCase();
|
|
1943
|
+
const groupName = group.Name || group.Description || "Lainnya";
|
|
1944
|
+
const channels = group.Channels || [];
|
|
1945
|
+
let category = "Lainnya";
|
|
1946
|
+
if (groupCode === "va") category = "Virtual Account";
|
|
1947
|
+
else if (groupCode === "cstore") category = "Retail / Gerai";
|
|
1948
|
+
else if (groupCode === "qris") category = "QRIS";
|
|
1949
|
+
else if (groupCode === "cc") category = "Kartu Kredit";
|
|
1950
|
+
else if (groupCode === "paylater") category = "Paylater / Cicilan";
|
|
1951
|
+
else if (groupCode === "cod") category = "COD";
|
|
1952
|
+
else if (groupCode === "ewallet" || groupCode === "ewallet-asia") category = "E-Wallet";
|
|
1953
|
+
else if (groupCode === "debitonline") category = "Debit Online";
|
|
1954
|
+
else category = groupName;
|
|
1955
|
+
for (const ch of channels) {
|
|
1956
|
+
const chCode = (ch.Code || "").toLowerCase();
|
|
1957
|
+
let canonicalCode = chCode;
|
|
1958
|
+
if (groupCode === "va") {
|
|
1959
|
+
canonicalCode = chCode === "bag" ? "bag_va" : chCode === "bmi" ? "muamalat_va" : `${chCode}_va`;
|
|
1960
|
+
} else if (groupCode === "cc") {
|
|
1961
|
+
canonicalCode = "credit_card";
|
|
1962
|
+
} else if (groupCode === "qris") {
|
|
1963
|
+
canonicalCode = "qris";
|
|
1964
|
+
}
|
|
1965
|
+
let totalFee = "-";
|
|
1966
|
+
if (ch.TransactionFee) {
|
|
1967
|
+
if (ch.TransactionFee.ActualFeeType === "PERCENT") {
|
|
1968
|
+
totalFee = `${ch.TransactionFee.ActualFee}%`;
|
|
1969
|
+
} else if (ch.TransactionFee.ActualFee !== void 0) {
|
|
1970
|
+
totalFee = `IDR ${Number(ch.TransactionFee.ActualFee).toLocaleString()}`;
|
|
1941
1971
|
}
|
|
1942
|
-
const pm = {
|
|
1943
|
-
paymentMethod: canonicalCode,
|
|
1944
|
-
code: canonicalCode,
|
|
1945
|
-
paymentName: ch.Name || ch.Description || canonicalCode,
|
|
1946
|
-
paymentImage: `https://my.ipaymu.com/images/banks/${chCode}.png`,
|
|
1947
|
-
totalFee,
|
|
1948
|
-
category,
|
|
1949
|
-
extra: {
|
|
1950
|
-
healthStatus: ch.HealthStatus,
|
|
1951
|
-
instructionsDoc: ch.PaymentInstructionsDoc,
|
|
1952
|
-
feeDetail: ch.TransactionFee
|
|
1953
|
-
}
|
|
1954
|
-
};
|
|
1955
|
-
methods.push(pm);
|
|
1956
|
-
if (!categories2[category]) categories2[category] = [];
|
|
1957
|
-
categories2[category].push(pm);
|
|
1958
1972
|
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1973
|
+
const pm = {
|
|
1974
|
+
paymentMethod: canonicalCode,
|
|
1975
|
+
code: canonicalCode,
|
|
1976
|
+
paymentName: ch.Name || ch.Description || canonicalCode,
|
|
1977
|
+
paymentImage: ch.Logo || `https://my.ipaymu.com/images/banks/${chCode}.png`,
|
|
1978
|
+
totalFee,
|
|
1979
|
+
category,
|
|
1980
|
+
extra: {
|
|
1981
|
+
healthStatus: ch.HealthStatus,
|
|
1982
|
+
featureStatus: ch.FeatureStatus,
|
|
1983
|
+
instructionsDoc: ch.PaymentInstructionsDoc,
|
|
1984
|
+
feeDetail: ch.TransactionFee
|
|
1985
|
+
}
|
|
1967
1986
|
};
|
|
1987
|
+
methods.push(pm);
|
|
1988
|
+
if (!categories[category]) categories[category] = [];
|
|
1989
|
+
categories[category].push(pm);
|
|
1968
1990
|
}
|
|
1969
1991
|
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
paymentName: "BCA Virtual Account",
|
|
1978
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bca.png",
|
|
1979
|
-
totalFee: "IDR 3,500",
|
|
1980
|
-
category: "Virtual Account"
|
|
1981
|
-
},
|
|
1982
|
-
{
|
|
1983
|
-
paymentMethod: "mandiri_va",
|
|
1984
|
-
code: "mandiri_va",
|
|
1985
|
-
paymentName: "Mandiri Virtual Account",
|
|
1986
|
-
paymentImage: "https://my.ipaymu.com/images/banks/mandiri.png",
|
|
1987
|
-
totalFee: "IDR 3,500",
|
|
1988
|
-
category: "Virtual Account"
|
|
1989
|
-
},
|
|
1990
|
-
{
|
|
1991
|
-
paymentMethod: "bni_va",
|
|
1992
|
-
code: "bni_va",
|
|
1993
|
-
paymentName: "BNI Virtual Account",
|
|
1994
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bni.png",
|
|
1995
|
-
totalFee: "IDR 3,500",
|
|
1996
|
-
category: "Virtual Account"
|
|
1997
|
-
},
|
|
1998
|
-
{
|
|
1999
|
-
paymentMethod: "bri_va",
|
|
2000
|
-
code: "bri_va",
|
|
2001
|
-
paymentName: "BRI Virtual Account",
|
|
2002
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bri.png",
|
|
2003
|
-
totalFee: "IDR 3,500",
|
|
2004
|
-
category: "Virtual Account"
|
|
2005
|
-
},
|
|
2006
|
-
{
|
|
2007
|
-
paymentMethod: "cimb_va",
|
|
2008
|
-
code: "cimb_va",
|
|
2009
|
-
paymentName: "CIMB Niaga Virtual Account",
|
|
2010
|
-
paymentImage: "https://my.ipaymu.com/images/banks/cimb.png",
|
|
2011
|
-
totalFee: "IDR 3,500",
|
|
2012
|
-
category: "Virtual Account"
|
|
2013
|
-
},
|
|
2014
|
-
{
|
|
2015
|
-
paymentMethod: "permata_va",
|
|
2016
|
-
code: "permata_va",
|
|
2017
|
-
paymentName: "Permata Virtual Account",
|
|
2018
|
-
paymentImage: "https://my.ipaymu.com/images/banks/permata.png",
|
|
2019
|
-
totalFee: "IDR 3,500",
|
|
2020
|
-
category: "Virtual Account"
|
|
2021
|
-
},
|
|
2022
|
-
{
|
|
2023
|
-
paymentMethod: "danamon_va",
|
|
2024
|
-
code: "danamon_va",
|
|
2025
|
-
paymentName: "Danamon Virtual Account",
|
|
2026
|
-
paymentImage: "https://my.ipaymu.com/images/banks/danamon.png",
|
|
2027
|
-
totalFee: "IDR 3,500",
|
|
2028
|
-
category: "Virtual Account"
|
|
2029
|
-
},
|
|
2030
|
-
{
|
|
2031
|
-
paymentMethod: "bsi_va",
|
|
2032
|
-
code: "bsi_va",
|
|
2033
|
-
paymentName: "BSI Virtual Account",
|
|
2034
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bsi.png",
|
|
2035
|
-
totalFee: "IDR 3,500",
|
|
2036
|
-
category: "Virtual Account"
|
|
2037
|
-
},
|
|
2038
|
-
{
|
|
2039
|
-
paymentMethod: "bag_va",
|
|
2040
|
-
code: "bag_va",
|
|
2041
|
-
paymentName: "Bank Artha Graha Virtual Account",
|
|
2042
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bag.png",
|
|
2043
|
-
totalFee: "IDR 3,500",
|
|
2044
|
-
category: "Virtual Account"
|
|
2045
|
-
},
|
|
2046
|
-
{
|
|
2047
|
-
paymentMethod: "muamalat_va",
|
|
2048
|
-
code: "muamalat_va",
|
|
2049
|
-
paymentName: "Bank Muamalat Virtual Account",
|
|
2050
|
-
paymentImage: "https://my.ipaymu.com/images/banks/bmi.png",
|
|
2051
|
-
totalFee: "IDR 3,500",
|
|
2052
|
-
category: "Virtual Account"
|
|
2053
|
-
},
|
|
2054
|
-
{
|
|
2055
|
-
paymentMethod: "qris",
|
|
2056
|
-
code: "qris",
|
|
2057
|
-
paymentName: "QRIS (GoPay, ShopeePay, DANA, OVO, LinkAja)",
|
|
2058
|
-
paymentImage: "https://my.ipaymu.com/images/banks/qris.png",
|
|
2059
|
-
totalFee: "0.7%",
|
|
2060
|
-
category: "QRIS"
|
|
2061
|
-
},
|
|
2062
|
-
{
|
|
2063
|
-
paymentMethod: "alfamart",
|
|
2064
|
-
code: "alfamart",
|
|
2065
|
-
paymentName: "Alfamart",
|
|
2066
|
-
paymentImage: "https://my.ipaymu.com/images/banks/alfamart.png",
|
|
2067
|
-
totalFee: "IDR 5,000",
|
|
2068
|
-
category: "Retail / Gerai"
|
|
2069
|
-
},
|
|
2070
|
-
{
|
|
2071
|
-
paymentMethod: "indomaret",
|
|
2072
|
-
code: "indomaret",
|
|
2073
|
-
paymentName: "Indomaret",
|
|
2074
|
-
paymentImage: "https://my.ipaymu.com/images/banks/indomaret.png",
|
|
2075
|
-
totalFee: "IDR 5,000",
|
|
2076
|
-
category: "Retail / Gerai"
|
|
2077
|
-
},
|
|
2078
|
-
{
|
|
2079
|
-
paymentMethod: "credit_card",
|
|
2080
|
-
code: "credit_card",
|
|
2081
|
-
paymentName: "Credit / Debit Card (Visa, Mastercard)",
|
|
2082
|
-
paymentImage: "https://my.ipaymu.com/images/banks/cc.png",
|
|
2083
|
-
totalFee: "2.9% + IDR 2,000",
|
|
2084
|
-
category: "Kartu Kredit"
|
|
2085
|
-
},
|
|
2086
|
-
{
|
|
2087
|
-
paymentMethod: "akulaku",
|
|
2088
|
-
code: "akulaku",
|
|
2089
|
-
paymentName: "Akulaku Paylater",
|
|
2090
|
-
paymentImage: "https://my.ipaymu.com/images/banks/akulaku.png",
|
|
2091
|
-
totalFee: "1.7%",
|
|
2092
|
-
category: "Paylater / Cicilan"
|
|
2093
|
-
}
|
|
2094
|
-
];
|
|
2095
|
-
const categories = {};
|
|
2096
|
-
for (const item of staticMethods) {
|
|
2097
|
-
if (!categories[item.category]) {
|
|
2098
|
-
categories[item.category] = [];
|
|
1992
|
+
return {
|
|
1993
|
+
success: true,
|
|
1994
|
+
provider: "ipaymu",
|
|
1995
|
+
methods,
|
|
1996
|
+
categories,
|
|
1997
|
+
rawResponse: data
|
|
1998
|
+
};
|
|
2099
1999
|
}
|
|
2100
|
-
|
|
2000
|
+
return {
|
|
2001
|
+
success: false,
|
|
2002
|
+
provider: "ipaymu",
|
|
2003
|
+
methods: [],
|
|
2004
|
+
categories: {},
|
|
2005
|
+
error: data?.Message || data?.message || `Failed to fetch payment channels (HTTP ${response.status})`,
|
|
2006
|
+
rawResponse: data
|
|
2007
|
+
};
|
|
2008
|
+
} catch (err) {
|
|
2009
|
+
return {
|
|
2010
|
+
success: false,
|
|
2011
|
+
provider: "ipaymu",
|
|
2012
|
+
methods: [],
|
|
2013
|
+
categories: {},
|
|
2014
|
+
error: err.message || "Failed to fetch iPaymu payment channels",
|
|
2015
|
+
rawResponse: null
|
|
2016
|
+
};
|
|
2101
2017
|
}
|
|
2102
|
-
return {
|
|
2103
|
-
success: true,
|
|
2104
|
-
provider: "ipaymu",
|
|
2105
|
-
methods: staticMethods,
|
|
2106
|
-
categories,
|
|
2107
|
-
rawResponse: staticMethods
|
|
2108
|
-
};
|
|
2109
2018
|
}
|
|
2110
2019
|
async checkTransaction(params, config) {
|
|
2111
2020
|
const { merchantOrderId } = params;
|
|
@@ -8376,13 +8285,19 @@ var IpaymuClient = class {
|
|
|
8376
8285
|
return this.request("POST", "/transaction", { transactionId });
|
|
8377
8286
|
}
|
|
8378
8287
|
/**
|
|
8379
|
-
* Ambil daftar channel pembayaran aktif milik merchant
|
|
8288
|
+
* Ambil daftar channel pembayaran aktif milik merchant (Official v2: GET /payment-channels)
|
|
8380
8289
|
*/
|
|
8381
8290
|
async getPaymentMethods() {
|
|
8382
|
-
return this.request("
|
|
8291
|
+
return this.request("GET", "/payment-channels");
|
|
8292
|
+
}
|
|
8293
|
+
/**
|
|
8294
|
+
* Alias untuk getPaymentMethods (Official v2)
|
|
8295
|
+
*/
|
|
8296
|
+
async getPaymentChannels() {
|
|
8297
|
+
return this.request("GET", "/payment-channels");
|
|
8383
8298
|
}
|
|
8384
8299
|
/**
|
|
8385
|
-
* Ambil riwayat transaksi merchant berpaginasi
|
|
8300
|
+
* Ambil riwayat transaksi merchant berpaginasi (Official v2: POST /history)
|
|
8386
8301
|
*/
|
|
8387
8302
|
async getHistory(params) {
|
|
8388
8303
|
const payload = {
|
|
@@ -8394,42 +8309,111 @@ var IpaymuClient = class {
|
|
|
8394
8309
|
return this.request("POST", "/history", payload);
|
|
8395
8310
|
}
|
|
8396
8311
|
/**
|
|
8397
|
-
* Ambil daftar seluruh bank di Indonesia
|
|
8312
|
+
* Ambil daftar seluruh bank di Indonesia (Official v2: POST /banklist)
|
|
8398
8313
|
*/
|
|
8399
8314
|
async getBankList() {
|
|
8400
8315
|
return this.request("POST", "/banklist", { account: this.va });
|
|
8401
8316
|
}
|
|
8402
8317
|
/**
|
|
8403
|
-
*
|
|
8318
|
+
* Cari jangkauan area pengiriman COD (Official v2: GET /cod/area?area=keyword)
|
|
8404
8319
|
*/
|
|
8405
|
-
async getCodArea(
|
|
8406
|
-
const
|
|
8407
|
-
|
|
8408
|
-
return this.request("POST", "/cod/getarea", payload);
|
|
8320
|
+
async getCodArea(area) {
|
|
8321
|
+
const query = { area };
|
|
8322
|
+
return this.request("GET", `/cod/area?area=${encodeURIComponent(area)}`, query);
|
|
8409
8323
|
}
|
|
8410
8324
|
/**
|
|
8411
|
-
* Hitung tarif ongkir pengiriman COD
|
|
8325
|
+
* Hitung tarif ongkir pengiriman COD (Official v2: POST /cod/shipping-calculate)
|
|
8412
8326
|
*/
|
|
8413
8327
|
async getCodRate(params) {
|
|
8414
|
-
|
|
8328
|
+
const { pickupArea, deliveryArea, ...rest } = params;
|
|
8329
|
+
const pickupId = params.pickup_area_id !== void 0 ? params.pickup_area_id : pickupArea;
|
|
8330
|
+
const destId = params.destination_area_id !== void 0 ? params.destination_area_id : deliveryArea;
|
|
8331
|
+
const payload = {
|
|
8332
|
+
...rest,
|
|
8333
|
+
pickup_area_id: pickupId !== void 0 ? String(pickupId) : void 0,
|
|
8334
|
+
destination_area_id: destId !== void 0 ? String(destId) : void 0,
|
|
8335
|
+
amount: params.amount || 0
|
|
8336
|
+
};
|
|
8337
|
+
return this.request("POST", "/cod/shipping-calculate", payload);
|
|
8415
8338
|
}
|
|
8416
8339
|
/**
|
|
8417
|
-
* Request pickup kurir COD
|
|
8340
|
+
* Request pickup kurir COD (Official v2: POST /cod/pickup)
|
|
8418
8341
|
*/
|
|
8419
8342
|
async getCodPickup(params) {
|
|
8420
|
-
|
|
8343
|
+
const { transactionId, ...rest } = params;
|
|
8344
|
+
const payload = {
|
|
8345
|
+
...rest,
|
|
8346
|
+
transaction_id: params.transaction_id || transactionId
|
|
8347
|
+
};
|
|
8348
|
+
return this.request("POST", "/cod/pickup", payload);
|
|
8421
8349
|
}
|
|
8422
8350
|
/**
|
|
8423
|
-
*
|
|
8351
|
+
* Unduh label pengiriman / AWB COD (Official v2: GET /cod/download-label/:transaction_id)
|
|
8424
8352
|
*/
|
|
8425
8353
|
async getCodAwb(transactionId) {
|
|
8426
|
-
return this.request("
|
|
8354
|
+
return this.request("GET", `/cod/download-label/${transactionId}`);
|
|
8355
|
+
}
|
|
8356
|
+
/**
|
|
8357
|
+
* Lacak status pengiriman kurir COD berdasarkan no resi / AWB (Official v2: POST /cod/tracking)
|
|
8358
|
+
*/
|
|
8359
|
+
async getCodTracking(params) {
|
|
8360
|
+
const payload = typeof params === "string" ? { awb: params } : {
|
|
8361
|
+
awb: params.awb,
|
|
8362
|
+
transaction_id: params.transaction_id || params.transactionId
|
|
8363
|
+
};
|
|
8364
|
+
return this.request("POST", "/cod/tracking", payload);
|
|
8365
|
+
}
|
|
8366
|
+
// ==========================================
|
|
8367
|
+
// Public Area Lookup API (docs.ipaymu.com/en/docs/area-api)
|
|
8368
|
+
// Read-only endpoint untuk provinsi, kota/kabupaten, kecamatan, dan kelurahan
|
|
8369
|
+
// ==========================================
|
|
8370
|
+
/**
|
|
8371
|
+
* Ambil daftar seluruh provinsi di Indonesia
|
|
8372
|
+
*/
|
|
8373
|
+
async getAreasProvince() {
|
|
8374
|
+
const res = await fetch("https://my.ipaymu.com/api/areas/province");
|
|
8375
|
+
return res.json();
|
|
8376
|
+
}
|
|
8377
|
+
/**
|
|
8378
|
+
* Ambil daftar kota / kabupaten berdasarkan ID provinsi
|
|
8379
|
+
*/
|
|
8380
|
+
async getAreasCity(provinceId) {
|
|
8381
|
+
const res = await fetch(`https://my.ipaymu.com/api/areas/city/${provinceId}`);
|
|
8382
|
+
return res.json();
|
|
8383
|
+
}
|
|
8384
|
+
/**
|
|
8385
|
+
* Ambil daftar kecamatan berdasarkan ID kota / kabupaten
|
|
8386
|
+
*/
|
|
8387
|
+
async getAreasDistrict(cityId) {
|
|
8388
|
+
const res = await fetch(`https://my.ipaymu.com/api/areas/district/${cityId}`);
|
|
8389
|
+
return res.json();
|
|
8427
8390
|
}
|
|
8428
8391
|
/**
|
|
8429
|
-
*
|
|
8392
|
+
* Ambil daftar kelurahan berdasarkan ID kecamatan
|
|
8393
|
+
*/
|
|
8394
|
+
async getAreasVillage(districtId) {
|
|
8395
|
+
const res = await fetch(`https://my.ipaymu.com/api/areas/village/${districtId}`);
|
|
8396
|
+
return res.json();
|
|
8397
|
+
}
|
|
8398
|
+
// ==========================================
|
|
8399
|
+
// Split Payment — Single Register API
|
|
8400
|
+
// https://ipaymu.com/en/split-payment/
|
|
8401
|
+
// ==========================================
|
|
8402
|
+
/**
|
|
8403
|
+
* Daftarkan agen / reseller / mitra baru untuk Split Payment (Single Register API: POST /api/v2/register)
|
|
8404
|
+
* Mengembalikan VA child account yang siap digunakan untuk parameter `subAccountId` saat membuat transaksi.
|
|
8430
8405
|
*/
|
|
8431
|
-
async
|
|
8432
|
-
|
|
8406
|
+
async registerUser(params) {
|
|
8407
|
+
const { name, email, phone, password, ...rest } = params;
|
|
8408
|
+
const payload = {
|
|
8409
|
+
...rest,
|
|
8410
|
+
account: this.va,
|
|
8411
|
+
name,
|
|
8412
|
+
email,
|
|
8413
|
+
phone,
|
|
8414
|
+
password: password || "Password123!"
|
|
8415
|
+
};
|
|
8416
|
+
return this.request("POST", "/register", payload);
|
|
8433
8417
|
}
|
|
8434
8418
|
};
|
|
8435
8419
|
|