@tapsilat/tapsilat-js 2026.1.14 → 2026.6.17
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 +28 -1
- package/dist/TapsilatSDK.d.ts +199 -56
- package/dist/TapsilatSDK.d.ts.map +1 -1
- package/dist/index.cjs +699 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +977 -102
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +700 -138
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +780 -45
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +12 -10
package/dist/index.cjs
CHANGED
|
@@ -612,7 +612,7 @@ class HttpClient {
|
|
|
612
612
|
...config?.headers,
|
|
613
613
|
});
|
|
614
614
|
// Set content type for requests with body
|
|
615
|
-
if (body && method !== "GET"
|
|
615
|
+
if (body && method !== "GET") {
|
|
616
616
|
if (!(body instanceof FormData)) {
|
|
617
617
|
headers.set("Content-Type", "application/json");
|
|
618
618
|
}
|
|
@@ -622,8 +622,8 @@ class HttpClient {
|
|
|
622
622
|
headers,
|
|
623
623
|
...config,
|
|
624
624
|
};
|
|
625
|
-
// Add body for non-GET
|
|
626
|
-
if (body && method !== "GET"
|
|
625
|
+
// Add body for non-GET requests
|
|
626
|
+
if (body && method !== "GET") {
|
|
627
627
|
if (body instanceof FormData) {
|
|
628
628
|
options.body = body;
|
|
629
629
|
}
|
|
@@ -1131,7 +1131,7 @@ function validateInstallments(installments) {
|
|
|
1131
1131
|
originalInput: String(originalInput)
|
|
1132
1132
|
};
|
|
1133
1133
|
}
|
|
1134
|
-
let installmentArray
|
|
1134
|
+
let installmentArray;
|
|
1135
1135
|
try {
|
|
1136
1136
|
if (typeof installments === 'number') {
|
|
1137
1137
|
// Single number
|
|
@@ -1423,6 +1423,110 @@ class TapsilatSDK {
|
|
|
1423
1423
|
this.configManager = new ConfigManager(config);
|
|
1424
1424
|
this.httpClient = new HttpClient(this.configManager.getInternalConfig());
|
|
1425
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Access to order operations
|
|
1428
|
+
*/
|
|
1429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1430
|
+
get orders() {
|
|
1431
|
+
return {
|
|
1432
|
+
create: (request) => this.createOrder(request),
|
|
1433
|
+
get: (referenceId) => this.getOrder(referenceId),
|
|
1434
|
+
list: (params) => this.getOrders(params),
|
|
1435
|
+
cancel: (referenceId) => this.cancelOrder(referenceId),
|
|
1436
|
+
status: (referenceId) => this.getOrderStatus(referenceId),
|
|
1437
|
+
refund: (request) => this.refundOrder(request),
|
|
1438
|
+
refundAll: (referenceId) => this.refundAllOrder(referenceId),
|
|
1439
|
+
paymentDetails: (request) => this.getOrderPaymentDetails(request),
|
|
1440
|
+
paymentDetailsById: (referenceId) => this.getOrderPaymentDetailsById(referenceId),
|
|
1441
|
+
callback: (id) => this.orderCallback(id),
|
|
1442
|
+
updatePaymentOptions: (request) => this.updatePaymentOptions(request),
|
|
1443
|
+
splitItemPayment: (request) => this.splitOrderItemPayment(request),
|
|
1444
|
+
vposQuery: (id) => this.orderVposQuery(id),
|
|
1445
|
+
byConversationId: (conversationId) => this.getOrderByConversationId(conversationId),
|
|
1446
|
+
transactions: (referenceId) => this.getOrderTransactions(referenceId),
|
|
1447
|
+
submerchants: (params) => this.getOrderSubmerchants(params),
|
|
1448
|
+
checkoutUrl: (referenceId) => this.getCheckoutUrl(referenceId),
|
|
1449
|
+
accounting: (request) => this.orderAccounting(request),
|
|
1450
|
+
postAuth: (request) => this.orderPostAuth(request),
|
|
1451
|
+
manualCallback: (referenceId, conversationId) => this.orderManualCallback(referenceId, conversationId),
|
|
1452
|
+
relatedUpdate: (referenceId, relatedReferenceId) => this.orderRelatedUpdate(referenceId, relatedReferenceId),
|
|
1453
|
+
addBasketItem: (request) => this.addBasketItem(request),
|
|
1454
|
+
removeBasketItem: (request) => this.removeBasketItem(request),
|
|
1455
|
+
updateBasketItem: (request) => this.updateBasketItem(request),
|
|
1456
|
+
createTerm: (request) => this.createOrderTerm(request),
|
|
1457
|
+
updateTerm: (request) => this.updateOrderTerm(request),
|
|
1458
|
+
deleteTerm: (request) => this.deleteOrderTerm(request),
|
|
1459
|
+
refundTerm: (request) => this.refundOrderTerm(request),
|
|
1460
|
+
getTerm: (termReferenceId) => this.getOrderTerm(termReferenceId),
|
|
1461
|
+
terminateTerm: (request) => this.terminateOrderTerm(request),
|
|
1462
|
+
terminate: (request) => this.terminateOrder(request),
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Access to subscription operations
|
|
1467
|
+
*/
|
|
1468
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1469
|
+
get subscriptions() {
|
|
1470
|
+
return {
|
|
1471
|
+
create: (request) => this.createSubscription(request),
|
|
1472
|
+
get: (request) => this.getSubscription(request),
|
|
1473
|
+
list: (params) => this.listSubscriptions(params),
|
|
1474
|
+
cancel: (request) => this.cancelSubscription(request),
|
|
1475
|
+
redirect: (request) => this.redirectSubscription(request),
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Access to organization operations
|
|
1480
|
+
*/
|
|
1481
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1482
|
+
get organization() {
|
|
1483
|
+
return {
|
|
1484
|
+
settings: () => this.getOrganizationSettings(),
|
|
1485
|
+
callback: () => this.getOrganizationCallback(),
|
|
1486
|
+
updateCallback: (request) => this.updateOrganizationCallback(request),
|
|
1487
|
+
createBusiness: (request) => this.createOrganizationBusiness(request),
|
|
1488
|
+
currencies: () => this.getOrganizationCurrencies(),
|
|
1489
|
+
getLimitUser: (request) => this.getOrganizationLimitUser(request),
|
|
1490
|
+
setLimitUser: (request) => this.setOrganizationLimitUser(request),
|
|
1491
|
+
limits: () => this.getOrganizationLimits(),
|
|
1492
|
+
meta: (name) => this.getOrganizationMeta(name),
|
|
1493
|
+
scopes: () => this.getOrganizationScopes(),
|
|
1494
|
+
suborganizations: (params) => this.getOrganizationSuborganizations(params),
|
|
1495
|
+
createUser: (request) => this.createOrganizationUser(request),
|
|
1496
|
+
verifyUser: (request) => this.verifyOrganizationUser(request),
|
|
1497
|
+
verifyUserMobile: (request) => this.verifyOrganizationUserMobile(request),
|
|
1498
|
+
listVpos: (request) => this.listOrganizationVpos(request),
|
|
1499
|
+
currencyPresets: () => this.getOrganizationCurrencyPresets(),
|
|
1500
|
+
suborganizationDetails: (id) => this.getOrganizationSuborganizationDetails(id),
|
|
1501
|
+
suborganizationSubmerchants: (id) => this.getOrganizationSuborganizationSubmerchants(id),
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Access to system operations
|
|
1506
|
+
*/
|
|
1507
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1508
|
+
get system() {
|
|
1509
|
+
return {
|
|
1510
|
+
orderStatuses: () => this.getSystemOrderStatuses(),
|
|
1511
|
+
basketItemTypes: () => this.getSystemBasketItemTypes(),
|
|
1512
|
+
errorCodes: () => this.getSystemErrorCodes(),
|
|
1513
|
+
paymentTermStatuses: () => this.getSystemPaymentTermStatuses(),
|
|
1514
|
+
productTypes: () => this.getSystemProductTypes(),
|
|
1515
|
+
shortcutTypes: () => this.getSystemShortcutTypes(),
|
|
1516
|
+
transactionPaymentTypes: () => this.getSystemTransactionPaymentTypes(),
|
|
1517
|
+
transactionPurposes: () => this.getSystemTransactionPurposes(),
|
|
1518
|
+
transactionStatuses: () => this.getSystemTransactionStatuses(),
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Access to webhook operations
|
|
1523
|
+
*/
|
|
1524
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1525
|
+
get webhooks() {
|
|
1526
|
+
return {
|
|
1527
|
+
verify: (payload, signature, secret) => this.verifyWebhook(payload, signature, secret),
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1426
1530
|
// ORDER CREATION
|
|
1427
1531
|
// Summary: Create new payment order and get checkout URL
|
|
1428
1532
|
// Description: Initiates payment process with buyer info and returns secure checkout URL
|
|
@@ -1457,10 +1561,10 @@ class TapsilatSDK {
|
|
|
1457
1561
|
* @param {string} [orderRequest.payment_success_url] - URL to redirect after successful payment
|
|
1458
1562
|
* @param {string} [orderRequest.payment_failure_url] - URL to redirect after failed payment
|
|
1459
1563
|
* @param {number[]} [orderRequest.enabled_installments] - Allowed installment counts
|
|
1460
|
-
* @param {
|
|
1564
|
+
* @param {OrderMetadata[]} [orderRequest.metadata] - Additional custom key/value data
|
|
1461
1565
|
*
|
|
1462
1566
|
* @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
|
|
1463
|
-
* @returns {string} OrderCreateResponse.
|
|
1567
|
+
* @returns {string} [OrderCreateResponse.id] - Internal order identifier
|
|
1464
1568
|
* @returns {string} OrderCreateResponse.reference_id - Unique order reference for tracking
|
|
1465
1569
|
* @returns {string} [OrderCreateResponse.checkout_url] - Payment page URL for customer
|
|
1466
1570
|
* @returns {string} [OrderCreateResponse.conversation_id] - Echo of provided conversation ID
|
|
@@ -1516,16 +1620,6 @@ class TapsilatSDK {
|
|
|
1516
1620
|
if (!isValidEmail(buyer.email)) {
|
|
1517
1621
|
throw new TapsilatValidationError("Buyer email must be a valid email address", { provided: buyer.email });
|
|
1518
1622
|
}
|
|
1519
|
-
// Validate basket items
|
|
1520
|
-
if (!orderRequest.basket_items ||
|
|
1521
|
-
!Array.isArray(orderRequest.basket_items) ||
|
|
1522
|
-
orderRequest.basket_items.length === 0) {
|
|
1523
|
-
throw new TapsilatValidationError("Basket items are required and must be a non-empty array");
|
|
1524
|
-
}
|
|
1525
|
-
// Validate billing address
|
|
1526
|
-
if (!orderRequest.billing_address) {
|
|
1527
|
-
throw new TapsilatValidationError("Billing address is required");
|
|
1528
|
-
}
|
|
1529
1623
|
try {
|
|
1530
1624
|
// Make the API request
|
|
1531
1625
|
const createOrderResponse = await this.httpClient.post("/order/create", orderRequest);
|
|
@@ -1547,7 +1641,7 @@ class TapsilatSDK {
|
|
|
1547
1641
|
* @description Handles accounting operations for a specific order using its reference ID.
|
|
1548
1642
|
*
|
|
1549
1643
|
* @param {OrderAccountingRequest} request - Accounting request details
|
|
1550
|
-
* @returns {Promise<
|
|
1644
|
+
* @returns {Promise<OrderAccountingResponse>} Promise resolving to the accounting response
|
|
1551
1645
|
* @throws {TapsilatValidationError} When input validation fails
|
|
1552
1646
|
* @throws {TapsilatError} When API returns an error response
|
|
1553
1647
|
*/
|
|
@@ -1556,8 +1650,8 @@ class TapsilatSDK {
|
|
|
1556
1650
|
throw new TapsilatValidationError("Order reference ID is required and must be a non-empty string", { provided: request.order_reference_id });
|
|
1557
1651
|
}
|
|
1558
1652
|
try {
|
|
1559
|
-
const
|
|
1560
|
-
return handleResponse(
|
|
1653
|
+
const orderAccountingResponse = await this.httpClient.post("/order/accounting", request);
|
|
1654
|
+
return handleResponse(orderAccountingResponse, "Order accounting");
|
|
1561
1655
|
}
|
|
1562
1656
|
catch (error) {
|
|
1563
1657
|
return handleError(error, "order accounting");
|
|
@@ -1573,7 +1667,7 @@ class TapsilatSDK {
|
|
|
1573
1667
|
* @description Handles post-authorization operations for a specific order.
|
|
1574
1668
|
*
|
|
1575
1669
|
* @param {OrderPostAuthRequest} request - Post-authorization request details
|
|
1576
|
-
* @returns {Promise<
|
|
1670
|
+
* @returns {Promise<OrderPostAuthResponse>} Promise resolving to the post-auth response
|
|
1577
1671
|
* @throws {TapsilatValidationError} When input validation fails
|
|
1578
1672
|
* @throws {TapsilatError} When API returns an error response
|
|
1579
1673
|
*/
|
|
@@ -1587,8 +1681,8 @@ class TapsilatSDK {
|
|
|
1587
1681
|
});
|
|
1588
1682
|
}
|
|
1589
1683
|
try {
|
|
1590
|
-
const
|
|
1591
|
-
return handleResponse(
|
|
1684
|
+
const orderPostAuthResponse = await this.httpClient.post("/order/postauth", request);
|
|
1685
|
+
return handleResponse(orderPostAuthResponse, "Order post-auth");
|
|
1592
1686
|
}
|
|
1593
1687
|
catch (error) {
|
|
1594
1688
|
return handleError(error, "order post-auth");
|
|
@@ -1603,18 +1697,122 @@ class TapsilatSDK {
|
|
|
1603
1697
|
* @summary Retrieve system order statuses
|
|
1604
1698
|
* @description Gets a list of all possible order statuses in the system.
|
|
1605
1699
|
*
|
|
1606
|
-
* @returns {Promise<
|
|
1700
|
+
* @returns {Promise<GetSystemOrderStatusesResponse>} Promise resolving to system order statuses
|
|
1607
1701
|
* @throws {TapsilatError} When API returns an error response
|
|
1608
1702
|
*/
|
|
1609
1703
|
async getSystemOrderStatuses() {
|
|
1610
1704
|
try {
|
|
1611
|
-
const
|
|
1612
|
-
return handleResponse(
|
|
1705
|
+
const getSystemOrderStatusesResponse = await this.httpClient.get("/system/order-statuses");
|
|
1706
|
+
return handleResponse(getSystemOrderStatusesResponse, "Get system order statuses");
|
|
1613
1707
|
}
|
|
1614
1708
|
catch (error) {
|
|
1615
1709
|
return handleError(error, "get system order statuses");
|
|
1616
1710
|
}
|
|
1617
1711
|
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Retrieves system basket item types.
|
|
1714
|
+
* Based on `get_system_basket_item_types` from Python SDK.
|
|
1715
|
+
*/
|
|
1716
|
+
async getSystemBasketItemTypes() {
|
|
1717
|
+
try {
|
|
1718
|
+
const response = await this.httpClient.get("/system/basket-item-types");
|
|
1719
|
+
return handleResponse(response, "Get system basket item types");
|
|
1720
|
+
}
|
|
1721
|
+
catch (error) {
|
|
1722
|
+
return handleError(error, "get system basket item types");
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Retrieves system error codes.
|
|
1727
|
+
* Based on `get_system_error_codes` from Python SDK.
|
|
1728
|
+
*/
|
|
1729
|
+
async getSystemErrorCodes() {
|
|
1730
|
+
try {
|
|
1731
|
+
const response = await this.httpClient.get("/system/error-codes");
|
|
1732
|
+
return handleResponse(response, "Get system error codes");
|
|
1733
|
+
}
|
|
1734
|
+
catch (error) {
|
|
1735
|
+
return handleError(error, "get system error codes");
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Retrieves system payment term statuses.
|
|
1740
|
+
* Based on `get_system_payment_term_statuses` from Python SDK.
|
|
1741
|
+
*/
|
|
1742
|
+
async getSystemPaymentTermStatuses() {
|
|
1743
|
+
try {
|
|
1744
|
+
const response = await this.httpClient.get("/system/payment-term-statuses");
|
|
1745
|
+
return handleResponse(response, "Get system payment term statuses");
|
|
1746
|
+
}
|
|
1747
|
+
catch (error) {
|
|
1748
|
+
return handleError(error, "get system payment term statuses");
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Retrieves system product types.
|
|
1753
|
+
* Based on `get_system_product_types` from Python SDK.
|
|
1754
|
+
*/
|
|
1755
|
+
async getSystemProductTypes() {
|
|
1756
|
+
try {
|
|
1757
|
+
const response = await this.httpClient.get("/system/product-types");
|
|
1758
|
+
return handleResponse(response, "Get system product types");
|
|
1759
|
+
}
|
|
1760
|
+
catch (error) {
|
|
1761
|
+
return handleError(error, "get system product types");
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Retrieves system shortcut types.
|
|
1766
|
+
* Based on `get_system_shortcut_types` from Python SDK.
|
|
1767
|
+
*/
|
|
1768
|
+
async getSystemShortcutTypes() {
|
|
1769
|
+
try {
|
|
1770
|
+
const response = await this.httpClient.get("/system/shortcut-types");
|
|
1771
|
+
return handleResponse(response, "Get system shortcut types");
|
|
1772
|
+
}
|
|
1773
|
+
catch (error) {
|
|
1774
|
+
return handleError(error, "get system shortcut types");
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Retrieves system transaction payment types.
|
|
1779
|
+
* Based on `get_system_transaction_payment_types` from Python SDK.
|
|
1780
|
+
*/
|
|
1781
|
+
async getSystemTransactionPaymentTypes() {
|
|
1782
|
+
try {
|
|
1783
|
+
const response = await this.httpClient.get("/system/transaction-payment-types");
|
|
1784
|
+
return handleResponse(response, "Get system transaction payment types");
|
|
1785
|
+
}
|
|
1786
|
+
catch (error) {
|
|
1787
|
+
return handleError(error, "get system transaction payment types");
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Retrieves system transaction purposes.
|
|
1792
|
+
* Based on `get_system_transaction_purposes` from Python SDK.
|
|
1793
|
+
*/
|
|
1794
|
+
async getSystemTransactionPurposes() {
|
|
1795
|
+
try {
|
|
1796
|
+
const response = await this.httpClient.get("/system/transaction-purposes");
|
|
1797
|
+
return handleResponse(response, "Get system transaction purposes");
|
|
1798
|
+
}
|
|
1799
|
+
catch (error) {
|
|
1800
|
+
return handleError(error, "get system transaction purposes");
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Retrieves system transaction statuses.
|
|
1805
|
+
* Based on `get_system_transaction_statuses` from Python SDK.
|
|
1806
|
+
*/
|
|
1807
|
+
async getSystemTransactionStatuses() {
|
|
1808
|
+
try {
|
|
1809
|
+
const response = await this.httpClient.get("/system/transaction-statuses");
|
|
1810
|
+
return handleResponse(response, "Get system transaction statuses");
|
|
1811
|
+
}
|
|
1812
|
+
catch (error) {
|
|
1813
|
+
return handleError(error, "get system transaction statuses");
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1618
1816
|
// ORDER RETRIEVAL BY REFERENCE ID
|
|
1619
1817
|
// Summary: Get complete order details and information
|
|
1620
1818
|
// Description: Retrieves full order data including buyer info, amounts, and current status
|
|
@@ -1687,6 +1885,10 @@ class TapsilatSDK {
|
|
|
1687
1885
|
throw new TapsilatValidationError("Items per page must be greater than 0", { provided: params.per_page });
|
|
1688
1886
|
}
|
|
1689
1887
|
}
|
|
1888
|
+
// Check if status is defined
|
|
1889
|
+
if (params.status !== undefined && !isInteger(params.status)) {
|
|
1890
|
+
throw new TapsilatValidationError("Status must be an integer", { provided: params.status });
|
|
1891
|
+
}
|
|
1690
1892
|
// Make the API request
|
|
1691
1893
|
const getOrdersResponse = await this.httpClient.get("/order/list", { params: params });
|
|
1692
1894
|
// Use our generic response handler
|
|
@@ -1712,23 +1914,28 @@ class TapsilatSDK {
|
|
|
1712
1914
|
* @throws {TapsilatError} When API returns an error response or order cannot be canceled
|
|
1713
1915
|
*/
|
|
1714
1916
|
async cancelOrder(referenceId) {
|
|
1715
|
-
// Validate referenceId
|
|
1716
1917
|
if (!isNonEmptyString(referenceId)) {
|
|
1717
1918
|
throw new TapsilatValidationError("Order referenceId is required and must be a non-empty string", { provided: referenceId });
|
|
1718
1919
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1920
|
+
try {
|
|
1921
|
+
const cancelOrderPayload = {
|
|
1922
|
+
reference_id: referenceId,
|
|
1923
|
+
};
|
|
1924
|
+
const cancelOrderResponse = await this.httpClient.post("/order/cancel", cancelOrderPayload);
|
|
1925
|
+
// Check if API call was successful
|
|
1926
|
+
if (!cancelOrderResponse.success) {
|
|
1927
|
+
throw new TapsilatError(cancelOrderResponse.error?.message ||
|
|
1928
|
+
"Order cancellation API call failed", cancelOrderResponse.error?.code || "CANCELLATION_API_FAILED");
|
|
1929
|
+
}
|
|
1930
|
+
// Check if response data exists
|
|
1931
|
+
if (!cancelOrderResponse.data) {
|
|
1932
|
+
throw new TapsilatError("Order cancellation response data is missing", "CANCELLATION_DATA_MISSING");
|
|
1933
|
+
}
|
|
1934
|
+
return cancelOrderResponse.data;
|
|
1726
1935
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
throw new TapsilatError("Order cancellation response data is missing", "CANCELLATION_DATA_MISSING");
|
|
1936
|
+
catch (error) {
|
|
1937
|
+
return handleError(error, "order cancellation");
|
|
1730
1938
|
}
|
|
1731
|
-
return cancelOrderResponse.data;
|
|
1732
1939
|
}
|
|
1733
1940
|
// ORDER STATUS RETRIEVAL
|
|
1734
1941
|
// Summary: Retrieves real-time payment status and tracking information for a specific order
|
|
@@ -1739,12 +1946,12 @@ class TapsilatSDK {
|
|
|
1739
1946
|
* @summary Retrieves real-time payment status and tracking information for a specific order
|
|
1740
1947
|
* @description
|
|
1741
1948
|
* Queries the Tapsilat payment platform to retrieve the current status of an order using its
|
|
1742
|
-
* unique reference ID. This method provides real-time information about payment
|
|
1743
|
-
*
|
|
1949
|
+
* unique reference ID. This method provides real-time information about payment processing
|
|
1950
|
+
* status and error code (if returned by the API). It's essential for tracking payment flow
|
|
1744
1951
|
* and implementing proper order state management in your application.
|
|
1745
1952
|
*
|
|
1746
|
-
* The status information includes payment state
|
|
1747
|
-
*
|
|
1953
|
+
* The status information includes payment state and API-level error code metadata.
|
|
1954
|
+
* This method should be used to:
|
|
1748
1955
|
* - Check if a payment has been completed after redirecting from checkout
|
|
1749
1956
|
* - Monitor payment status for pending transactions
|
|
1750
1957
|
* - Verify order state before fulfilling goods/services
|
|
@@ -1753,13 +1960,11 @@ class TapsilatSDK {
|
|
|
1753
1960
|
* @param {string} referenceId - Unique order reference identifier from order creation
|
|
1754
1961
|
*
|
|
1755
1962
|
* @returns {Promise<OrderStatusResponse>} Promise resolving to current order status information
|
|
1756
|
-
* @returns {string} OrderStatusResponse.
|
|
1757
|
-
* @returns {string} OrderStatusResponse.status - Current payment status
|
|
1758
|
-
* @returns {string} OrderStatusResponse.lastUpdatedAt - ISO 8601 timestamp of last status change
|
|
1963
|
+
* @returns {string} [OrderStatusResponse.error_code] - API-level error code when present
|
|
1964
|
+
* @returns {string} [OrderStatusResponse.status] - Current payment processing status
|
|
1759
1965
|
*
|
|
1760
1966
|
* @throws {TapsilatValidationError} When input validation fails:
|
|
1761
1967
|
* - Reference ID is null, undefined, or empty string
|
|
1762
|
-
* - Reference ID format is invalid (should match order ID pattern)
|
|
1763
1968
|
* @throws {TapsilatNetworkError} When network request fails:
|
|
1764
1969
|
* - Connection timeout during status check
|
|
1765
1970
|
* - DNS resolution failure
|
|
@@ -1800,14 +2005,19 @@ class TapsilatSDK {
|
|
|
1800
2005
|
* @throws {TapsilatError} When API returns an error response or refund fails
|
|
1801
2006
|
*/
|
|
1802
2007
|
async refundOrder(refundData) {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
2008
|
+
try {
|
|
2009
|
+
const refundOrderResponse = await this.httpClient.post("/order/refund", refundData);
|
|
2010
|
+
if (!refundOrderResponse.success) {
|
|
2011
|
+
throw new TapsilatError(refundOrderResponse.error?.message || "Order refund failed", refundOrderResponse.error?.code || "REFUND_FAILED");
|
|
2012
|
+
}
|
|
2013
|
+
if (!refundOrderResponse.data) {
|
|
2014
|
+
throw new TapsilatError("Order refund response data is missing", "REFUND_DATA_MISSING");
|
|
2015
|
+
}
|
|
2016
|
+
return refundOrderResponse.data;
|
|
1806
2017
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
2018
|
+
catch (error) {
|
|
2019
|
+
return handleError(error, "order refund");
|
|
1809
2020
|
}
|
|
1810
|
-
return refundOrderResponse.data;
|
|
1811
2021
|
}
|
|
1812
2022
|
// ORDER FULL REFUND OPERATIONS
|
|
1813
2023
|
// Summary: Process full refund for a completed order
|
|
@@ -1824,48 +2034,109 @@ class TapsilatSDK {
|
|
|
1824
2034
|
* @throws {TapsilatError} When API returns an error response or full refund fails
|
|
1825
2035
|
*/
|
|
1826
2036
|
async refundAllOrder(referenceId) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
2037
|
+
try {
|
|
2038
|
+
const refundAllPayload = {
|
|
2039
|
+
reference_id: referenceId,
|
|
2040
|
+
};
|
|
2041
|
+
const refundAllOrderResponse = await this.httpClient.post("/order/refund-all", refundAllPayload);
|
|
2042
|
+
if (!refundAllOrderResponse.success) {
|
|
2043
|
+
throw new TapsilatError(refundAllOrderResponse.error?.message || "Full order refund failed", refundAllOrderResponse.error?.code || "FULL_REFUND_FAILED");
|
|
2044
|
+
}
|
|
2045
|
+
if (!refundAllOrderResponse.data) {
|
|
2046
|
+
throw new TapsilatError("Full order refund response data is missing", "FULL_REFUND_DATA_MISSING");
|
|
2047
|
+
}
|
|
2048
|
+
return refundAllOrderResponse.data;
|
|
1832
2049
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
2050
|
+
catch (error) {
|
|
2051
|
+
return handleError(error, "full order refund");
|
|
1835
2052
|
}
|
|
1836
|
-
return refundAllOrderResponse.data;
|
|
1837
2053
|
}
|
|
1838
2054
|
// ORDER PAYMENT DETAILS
|
|
1839
2055
|
// Summary: Retrieve detailed payment transaction information for an order
|
|
1840
2056
|
// Description: Gets payment method, amount, status, and card info for order transactions
|
|
1841
2057
|
/**
|
|
1842
|
-
* Retrieves the payment details for an order.
|
|
2058
|
+
* Retrieves the payment details for an order via POST request.
|
|
1843
2059
|
* Based on `get_order_payment_details` from the Python SDK.
|
|
1844
|
-
*
|
|
1845
|
-
* @summary Retrieve detailed payment transaction information for an order
|
|
1846
|
-
* @description Gets payment method, amount, status, and card info for order transactions.
|
|
1847
|
-
*
|
|
1848
|
-
* @param referenceId - The unique identifier of the order.
|
|
1849
|
-
* @param conversationId - Optional conversation ID for more specific querying.
|
|
1850
|
-
* @returns Promise resolving to a list of payment details.
|
|
1851
|
-
* @throws {TapsilatValidationError} When referenceId is invalid
|
|
1852
|
-
* @throws {TapsilatError} When API returns an error response or payment details are missing
|
|
1853
2060
|
*/
|
|
1854
|
-
async getOrderPaymentDetails(
|
|
2061
|
+
async getOrderPaymentDetails(request) {
|
|
2062
|
+
try {
|
|
2063
|
+
const getOrderPaymentDetailsResponse = await this.httpClient.post("/order/payment-details", request);
|
|
2064
|
+
return handleResponse(getOrderPaymentDetailsResponse, "Order payment details");
|
|
2065
|
+
}
|
|
2066
|
+
catch (error) {
|
|
2067
|
+
return handleError(error, "order payment details");
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* Retrieves the payment details for an order by ID.
|
|
2072
|
+
* Based on `get_order_payment_details_by_id` from the Python SDK.
|
|
2073
|
+
*/
|
|
2074
|
+
async getOrderPaymentDetailsById(referenceId) {
|
|
1855
2075
|
if (!isNonEmptyString(referenceId))
|
|
1856
2076
|
throw new TapsilatValidationError("Reference ID is required and must be a non-empty string");
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2077
|
+
try {
|
|
2078
|
+
const getOrderPaymentDetailsResponse = await this.httpClient.get(`/order/${referenceId}/payment-details`);
|
|
2079
|
+
return handleResponse(getOrderPaymentDetailsResponse, "Order payment details by id");
|
|
2080
|
+
}
|
|
2081
|
+
catch (error) {
|
|
2082
|
+
return handleError(error, "order payment details by id");
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Retrieves the order callback via GET request.
|
|
2087
|
+
* Based on `order_callback` from the Python SDK.
|
|
2088
|
+
*/
|
|
2089
|
+
async orderCallback(id) {
|
|
2090
|
+
if (!isNonEmptyString(id))
|
|
2091
|
+
throw new TapsilatValidationError("ID is required and must be a non-empty string");
|
|
2092
|
+
try {
|
|
2093
|
+
const response = await this.httpClient.get(`/orders/${id}/callback`);
|
|
2094
|
+
return handleResponse(response, "Order callback");
|
|
2095
|
+
}
|
|
2096
|
+
catch (error) {
|
|
2097
|
+
return handleError(error, "order callback");
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Updates payment options for an order.
|
|
2102
|
+
* Based on `update_payment_options` from the Python SDK.
|
|
2103
|
+
*/
|
|
2104
|
+
async updatePaymentOptions(request) {
|
|
2105
|
+
try {
|
|
2106
|
+
const response = await this.httpClient.patch("/order/payment-options", request);
|
|
2107
|
+
return handleResponse(response, "Update payment options");
|
|
2108
|
+
}
|
|
2109
|
+
catch (error) {
|
|
2110
|
+
return handleError(error, "update payment options");
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Splits order item payment.
|
|
2115
|
+
* Based on `split_order_item_payment` from the Python SDK.
|
|
2116
|
+
*/
|
|
2117
|
+
async splitOrderItemPayment(request) {
|
|
2118
|
+
try {
|
|
2119
|
+
const response = await this.httpClient.post("/order/split", request);
|
|
2120
|
+
return handleResponse(response, "Split order item payment");
|
|
2121
|
+
}
|
|
2122
|
+
catch (error) {
|
|
2123
|
+
return handleError(error, "split order item payment");
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
/**
|
|
2127
|
+
* Queries vpos for an order.
|
|
2128
|
+
* Based on `order_vpos_query` from the Python SDK.
|
|
2129
|
+
*/
|
|
2130
|
+
async orderVposQuery(id) {
|
|
2131
|
+
if (!isNonEmptyString(id))
|
|
2132
|
+
throw new TapsilatValidationError("ID is required and must be a non-empty string");
|
|
2133
|
+
try {
|
|
2134
|
+
const response = await this.httpClient.get(`/orders/${id}/vpos-query`);
|
|
2135
|
+
return handleResponse(response, "Order vpos query");
|
|
2136
|
+
}
|
|
2137
|
+
catch (error) {
|
|
2138
|
+
return handleError(error, "order vpos query");
|
|
2139
|
+
}
|
|
1869
2140
|
}
|
|
1870
2141
|
// ORDER LOOKUP BY CONVERSATION ID
|
|
1871
2142
|
// Summary: Find order using conversation ID instead of reference ID
|
|
@@ -1887,13 +2158,18 @@ class TapsilatSDK {
|
|
|
1887
2158
|
if (!isNonEmptyString(conversationId)) {
|
|
1888
2159
|
throw new TapsilatValidationError("Order conversationId is required and must be a non-empty string", { provided: conversationId });
|
|
1889
2160
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
2161
|
+
try {
|
|
2162
|
+
const getOrderByConversationIdResponse = await this.httpClient.get(`/order/conversation/${conversationId}`);
|
|
2163
|
+
if (!getOrderByConversationIdResponse.success)
|
|
2164
|
+
throw new TapsilatError(getOrderByConversationIdResponse.error?.message ||
|
|
2165
|
+
"Order retrieval by conversation ID failed", getOrderByConversationIdResponse.error?.code || "ORDER_RETRIEVAL_FAILED");
|
|
2166
|
+
if (!getOrderByConversationIdResponse.data)
|
|
2167
|
+
throw new TapsilatError("Order response data is missing", "ORDER_DATA_MISSING");
|
|
2168
|
+
return getOrderByConversationIdResponse.data;
|
|
2169
|
+
}
|
|
2170
|
+
catch (error) {
|
|
2171
|
+
return handleError(error, "order retrieval by conversation ID");
|
|
2172
|
+
}
|
|
1897
2173
|
}
|
|
1898
2174
|
// ORDER TRANSACTION HISTORY
|
|
1899
2175
|
// Summary: Retrieve transaction history for an order
|
|
@@ -1915,14 +2191,19 @@ class TapsilatSDK {
|
|
|
1915
2191
|
if (!isNonEmptyString(referenceId)) {
|
|
1916
2192
|
throw new TapsilatValidationError("Order referenceId is required and must be a non-empty string", { provided: referenceId });
|
|
1917
2193
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2194
|
+
try {
|
|
2195
|
+
const getOrderTransactionsResponse = await this.httpClient.get(`/order/${referenceId}/transactions`);
|
|
2196
|
+
if (!getOrderTransactionsResponse.success)
|
|
2197
|
+
throw new TapsilatError(getOrderTransactionsResponse.error?.message ||
|
|
2198
|
+
"Order transactions retrieval failed", getOrderTransactionsResponse.error?.code ||
|
|
2199
|
+
"TRANSACTIONS_RETRIEVAL_FAILED");
|
|
2200
|
+
if (!getOrderTransactionsResponse.data)
|
|
2201
|
+
throw new TapsilatError("Order transactions response data is missing", "TRANSACTIONS_DATA_MISSING");
|
|
2202
|
+
return getOrderTransactionsResponse.data;
|
|
2203
|
+
}
|
|
2204
|
+
catch (error) {
|
|
2205
|
+
return handleError(error, "order transactions retrieval");
|
|
2206
|
+
}
|
|
1926
2207
|
}
|
|
1927
2208
|
// ORDER SUBMERCHANT LISTING
|
|
1928
2209
|
// Summary: Retrieve paginated list of submerchants for orders
|
|
@@ -1939,16 +2220,15 @@ class TapsilatSDK {
|
|
|
1939
2220
|
* @throws {TapsilatError} When API returns an error response
|
|
1940
2221
|
*/
|
|
1941
2222
|
async getOrderSubmerchants(params = {}) {
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
return getOrderSubmerchantsResponse.data;
|
|
2223
|
+
try {
|
|
2224
|
+
const getOrderSubmerchantsResponse = await this.httpClient.get("/order/submerchants", {
|
|
2225
|
+
params: params,
|
|
2226
|
+
});
|
|
2227
|
+
return handleResponse(getOrderSubmerchantsResponse, "Order submerchants retrieval");
|
|
2228
|
+
}
|
|
2229
|
+
catch (error) {
|
|
2230
|
+
return handleError(error, "order submerchants retrieval");
|
|
2231
|
+
}
|
|
1952
2232
|
}
|
|
1953
2233
|
// ORDER CHECKOUT URL RETRIEVAL
|
|
1954
2234
|
// Summary: Retrieve checkout URL for existing order
|
|
@@ -2008,19 +2288,22 @@ class TapsilatSDK {
|
|
|
2008
2288
|
* @throws {TapsilatError} When API health check fails or returns invalid data
|
|
2009
2289
|
*/
|
|
2010
2290
|
async healthCheck() {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2291
|
+
try {
|
|
2292
|
+
// We use the direct /health endpoint which returns plain string "OK"
|
|
2293
|
+
const healthCheckResponse = await this.httpClient.get("/health");
|
|
2294
|
+
const healthData = handleResponse(healthCheckResponse, "Health check");
|
|
2295
|
+
// The API returns "OK" string, verify consistency
|
|
2296
|
+
if (healthData !== "OK") {
|
|
2297
|
+
throw new TapsilatError(`Unexpected health check response: ${healthData}`, "HEALTH_CHECK_INVALID_RESPONSE");
|
|
2298
|
+
}
|
|
2299
|
+
return {
|
|
2300
|
+
status: "UP",
|
|
2301
|
+
timestamp: new Date().toISOString(),
|
|
2302
|
+
};
|
|
2015
2303
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
throw new TapsilatError(`Unexpected health check response: ${healthCheckResponse.data}`, "HEALTH_CHECK_INVALID_RESPONSE");
|
|
2304
|
+
catch (error) {
|
|
2305
|
+
return handleError(error, "health check");
|
|
2019
2306
|
}
|
|
2020
|
-
return {
|
|
2021
|
-
status: "UP",
|
|
2022
|
-
timestamp: new Date().toISOString(),
|
|
2023
|
-
};
|
|
2024
2307
|
}
|
|
2025
2308
|
// CONFIGURATION MANAGEMENT
|
|
2026
2309
|
// Summary: Access to the configuration manager for advanced configuration management
|
|
@@ -2313,8 +2596,8 @@ class TapsilatSDK {
|
|
|
2313
2596
|
payload.conversation_id = conversationId;
|
|
2314
2597
|
}
|
|
2315
2598
|
try {
|
|
2316
|
-
const
|
|
2317
|
-
return handleResponse(
|
|
2599
|
+
const orderManualCallbackResponse = await this.httpClient.post("/order/callback", payload);
|
|
2600
|
+
return handleResponse(orderManualCallbackResponse, "Order manual callback");
|
|
2318
2601
|
}
|
|
2319
2602
|
catch (error) {
|
|
2320
2603
|
return handleError(error, "order manual callback");
|
|
@@ -2328,11 +2611,12 @@ class TapsilatSDK {
|
|
|
2328
2611
|
throw new TapsilatValidationError("Related Reference ID is required and must be a non-empty string");
|
|
2329
2612
|
}
|
|
2330
2613
|
try {
|
|
2331
|
-
const
|
|
2614
|
+
const payload = {
|
|
2332
2615
|
reference_id: referenceId,
|
|
2333
2616
|
related_reference_id: relatedReferenceId,
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2617
|
+
};
|
|
2618
|
+
const orderRelatedUpdateResponse = await this.httpClient.patch("/order/releated", payload);
|
|
2619
|
+
return handleResponse(orderRelatedUpdateResponse, "Order related update");
|
|
2336
2620
|
}
|
|
2337
2621
|
catch (error) {
|
|
2338
2622
|
return handleError(error, "order related update");
|
|
@@ -2340,8 +2624,8 @@ class TapsilatSDK {
|
|
|
2340
2624
|
}
|
|
2341
2625
|
async getOrganizationSettings() {
|
|
2342
2626
|
try {
|
|
2343
|
-
const
|
|
2344
|
-
return handleResponse(
|
|
2627
|
+
const organizationSettingsResponse = await this.httpClient.get("/organization/settings");
|
|
2628
|
+
return handleResponse(organizationSettingsResponse, "Get organization settings");
|
|
2345
2629
|
}
|
|
2346
2630
|
catch (error) {
|
|
2347
2631
|
return handleError(error, "get organization settings");
|
|
@@ -2352,20 +2636,280 @@ class TapsilatSDK {
|
|
|
2352
2636
|
throw new TapsilatValidationError("Term Reference ID is required and must be a non-empty string");
|
|
2353
2637
|
}
|
|
2354
2638
|
try {
|
|
2355
|
-
const
|
|
2639
|
+
const orderTermResponse = await this.httpClient.get(`/order/term`, {
|
|
2356
2640
|
params: { term_reference_id: termReferenceId },
|
|
2357
2641
|
});
|
|
2358
|
-
return handleResponse(
|
|
2642
|
+
return handleResponse(orderTermResponse, "Get order term");
|
|
2359
2643
|
}
|
|
2360
2644
|
catch (error) {
|
|
2361
2645
|
return handleError(error, "get order term");
|
|
2362
2646
|
}
|
|
2363
2647
|
}
|
|
2364
2648
|
// SUBSCRIPTION METHODS
|
|
2649
|
+
/**
|
|
2650
|
+
* Add a new item to an existing order basket
|
|
2651
|
+
*/
|
|
2652
|
+
async addBasketItem(request) {
|
|
2653
|
+
try {
|
|
2654
|
+
const addBasketItemResponse = await this.httpClient.post("/order/basket-item", request);
|
|
2655
|
+
return handleResponse(addBasketItemResponse, "Add basket item");
|
|
2656
|
+
}
|
|
2657
|
+
catch (error) {
|
|
2658
|
+
return handleError(error, "add basket item");
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
/**
|
|
2662
|
+
* Remove an item from an existing order basket
|
|
2663
|
+
*/
|
|
2664
|
+
async removeBasketItem(request) {
|
|
2665
|
+
try {
|
|
2666
|
+
const removeBasketItemResponse = await this.httpClient.delete("/order/basket-item", request);
|
|
2667
|
+
return handleResponse(removeBasketItemResponse, "Remove basket item");
|
|
2668
|
+
}
|
|
2669
|
+
catch (error) {
|
|
2670
|
+
return handleError(error, "remove basket item");
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Update an existing item in an order basket
|
|
2675
|
+
*/
|
|
2676
|
+
async updateBasketItem(request) {
|
|
2677
|
+
try {
|
|
2678
|
+
const updateBasketItemResponse = await this.httpClient.patch("/order/basket-item", request);
|
|
2679
|
+
return handleResponse(updateBasketItemResponse, "Update basket item");
|
|
2680
|
+
}
|
|
2681
|
+
catch (error) {
|
|
2682
|
+
return handleError(error, "update basket item");
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Retrieve organization callback (webhook) settings
|
|
2687
|
+
*/
|
|
2688
|
+
async getOrganizationCallback() {
|
|
2689
|
+
try {
|
|
2690
|
+
const organizationCallbackResponse = await this.httpClient.get("/organization/callback");
|
|
2691
|
+
return handleResponse(organizationCallbackResponse, "Get organization callback");
|
|
2692
|
+
}
|
|
2693
|
+
catch (error) {
|
|
2694
|
+
return handleError(error, "get organization callback");
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
/**
|
|
2698
|
+
* Update organization callback (webhook) settings
|
|
2699
|
+
*/
|
|
2700
|
+
async updateOrganizationCallback(request) {
|
|
2701
|
+
try {
|
|
2702
|
+
const organizationCallbackResponse = await this.httpClient.patch("/organization/callback", request);
|
|
2703
|
+
return handleResponse(organizationCallbackResponse, "Update organization callback");
|
|
2704
|
+
}
|
|
2705
|
+
catch (error) {
|
|
2706
|
+
return handleError(error, "update organization callback");
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
/**
|
|
2710
|
+
* Create a new business entity within the organization
|
|
2711
|
+
*/
|
|
2712
|
+
async createOrganizationBusiness(request) {
|
|
2713
|
+
try {
|
|
2714
|
+
const organizationBusinessResponse = await this.httpClient.post("/organization/business/create", request);
|
|
2715
|
+
return handleResponse(organizationBusinessResponse, "Create organization business");
|
|
2716
|
+
}
|
|
2717
|
+
catch (error) {
|
|
2718
|
+
return handleError(error, "create organization business");
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* Retrieve supported currencies for the organization
|
|
2723
|
+
*/
|
|
2724
|
+
async getOrganizationCurrencies() {
|
|
2725
|
+
try {
|
|
2726
|
+
const organizationCurrenciesResponse = await this.httpClient.get("/organization/currencies");
|
|
2727
|
+
return handleResponse(organizationCurrenciesResponse, "Get organization currencies");
|
|
2728
|
+
}
|
|
2729
|
+
catch (error) {
|
|
2730
|
+
return handleError(error, "get organization currencies");
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* Retrieves organization currency presets.
|
|
2735
|
+
* Based on `get_organization_currency_presets` from Python SDK.
|
|
2736
|
+
*/
|
|
2737
|
+
async getOrganizationCurrencyPresets() {
|
|
2738
|
+
try {
|
|
2739
|
+
const response = await this.httpClient.get("/organization/currency-presets");
|
|
2740
|
+
return handleResponse(response, "Get organization currency presets");
|
|
2741
|
+
}
|
|
2742
|
+
catch (error) {
|
|
2743
|
+
return handleError(error, "get organization currency presets");
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Retrieves organization suborganization details.
|
|
2748
|
+
* Based on `get_organization_suborganization_details` from Python SDK.
|
|
2749
|
+
*/
|
|
2750
|
+
async getOrganizationSuborganizationDetails(id) {
|
|
2751
|
+
if (!isNonEmptyString(id))
|
|
2752
|
+
throw new TapsilatValidationError("ID is required and must be a non-empty string");
|
|
2753
|
+
try {
|
|
2754
|
+
const response = await this.httpClient.get(`/organization/suborganizations/${id}`);
|
|
2755
|
+
return handleResponse(response, "Get suborganization details");
|
|
2756
|
+
}
|
|
2757
|
+
catch (error) {
|
|
2758
|
+
return handleError(error, "get suborganization details");
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Retrieves organization suborganization submerchants.
|
|
2763
|
+
* Based on `get_organization_suborganization_submerchants` from Python SDK.
|
|
2764
|
+
*/
|
|
2765
|
+
async getOrganizationSuborganizationSubmerchants(id) {
|
|
2766
|
+
if (!isNonEmptyString(id))
|
|
2767
|
+
throw new TapsilatValidationError("ID is required and must be a non-empty string");
|
|
2768
|
+
try {
|
|
2769
|
+
const response = await this.httpClient.get(`/organization/suborganizations/${id}/submerchant`);
|
|
2770
|
+
return handleResponse(response, "Get suborganization submerchants");
|
|
2771
|
+
}
|
|
2772
|
+
catch (error) {
|
|
2773
|
+
return handleError(error, "get suborganization submerchants");
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Retrieve limit information for a specific organization user
|
|
2778
|
+
*/
|
|
2779
|
+
async getOrganizationLimitUser(request) {
|
|
2780
|
+
try {
|
|
2781
|
+
const organizationLimitUserResponse = await this.httpClient.get("/organization/limit/user", { params: request });
|
|
2782
|
+
return handleResponse(organizationLimitUserResponse, "Get organization user limit");
|
|
2783
|
+
}
|
|
2784
|
+
catch (error) {
|
|
2785
|
+
return handleError(error, "get organization user limit");
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
/**
|
|
2789
|
+
* Set limit for a specific organization user
|
|
2790
|
+
*/
|
|
2791
|
+
async setOrganizationLimitUser(request) {
|
|
2792
|
+
try {
|
|
2793
|
+
const organizationLimitUserResponse = await this.httpClient.post("/organization/limit/user", request);
|
|
2794
|
+
return handleResponse(organizationLimitUserResponse, "Set organization user limit");
|
|
2795
|
+
}
|
|
2796
|
+
catch (error) {
|
|
2797
|
+
return handleError(error, "set organization user limit");
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
/**
|
|
2801
|
+
* Retrieve organization overall limits
|
|
2802
|
+
*/
|
|
2803
|
+
async getOrganizationLimits() {
|
|
2804
|
+
try {
|
|
2805
|
+
const organizationLimitsResponse = await this.httpClient.get("/organization/limits");
|
|
2806
|
+
return handleResponse(organizationLimitsResponse, "Get organization limits");
|
|
2807
|
+
}
|
|
2808
|
+
catch (error) {
|
|
2809
|
+
return handleError(error, "get organization limits");
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
/**
|
|
2813
|
+
* Retrieve meta information for the organization
|
|
2814
|
+
*/
|
|
2815
|
+
async getOrganizationMeta(name) {
|
|
2816
|
+
if (!isNonEmptyString(name)) {
|
|
2817
|
+
throw new TapsilatValidationError("Meta name is required and must be a non-empty string");
|
|
2818
|
+
}
|
|
2819
|
+
try {
|
|
2820
|
+
const organizationMetaResponse = await this.httpClient.get(`/organization/meta/${name}`);
|
|
2821
|
+
return handleResponse(organizationMetaResponse, "Get organization meta");
|
|
2822
|
+
}
|
|
2823
|
+
catch (error) {
|
|
2824
|
+
return handleError(error, "get organization meta");
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Retrieve supported scopes for the organization
|
|
2829
|
+
*/
|
|
2830
|
+
async getOrganizationScopes() {
|
|
2831
|
+
try {
|
|
2832
|
+
const organizationScopesResponse = await this.httpClient.get("/organization/scopes");
|
|
2833
|
+
return handleResponse(organizationScopesResponse, "Get organization scopes");
|
|
2834
|
+
}
|
|
2835
|
+
catch (error) {
|
|
2836
|
+
return handleError(error, "get organization scopes");
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Retrieve list of sub-organizations
|
|
2841
|
+
*/
|
|
2842
|
+
async getOrganizationSuborganizations(params = {}) {
|
|
2843
|
+
if (params.page !== undefined) {
|
|
2844
|
+
if (!isInteger(params.page) || params.page < 1) {
|
|
2845
|
+
throw new TapsilatValidationError("Suborganization page must be a positive integer", { provided: params.page });
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
if (params.per_page !== undefined) {
|
|
2849
|
+
if (!isInteger(params.per_page) || params.per_page < 1) {
|
|
2850
|
+
throw new TapsilatValidationError("Suborganization per_page must be a positive integer", { provided: params.per_page });
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
try {
|
|
2854
|
+
const organizationSuborganizationsResponse = await this.httpClient.get("/organization/suborganizations", { params: params });
|
|
2855
|
+
return handleResponse(organizationSuborganizationsResponse, "Get organization suborganizations");
|
|
2856
|
+
}
|
|
2857
|
+
catch (error) {
|
|
2858
|
+
return handleError(error, "get organization suborganizations");
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
/**
|
|
2862
|
+
* Create a new user within the organization
|
|
2863
|
+
*/
|
|
2864
|
+
async createOrganizationUser(request) {
|
|
2865
|
+
try {
|
|
2866
|
+
const organizationUserResponse = await this.httpClient.post("/organization/user/create", request);
|
|
2867
|
+
return handleResponse(organizationUserResponse, "Create organization user");
|
|
2868
|
+
}
|
|
2869
|
+
catch (error) {
|
|
2870
|
+
return handleError(error, "create organization user");
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Verify an organization user
|
|
2875
|
+
*/
|
|
2876
|
+
async verifyOrganizationUser(request) {
|
|
2877
|
+
try {
|
|
2878
|
+
const organizationUserVerifyResponse = await this.httpClient.post("/organization/user/verify", request);
|
|
2879
|
+
return handleResponse(organizationUserVerifyResponse, "Verify organization user");
|
|
2880
|
+
}
|
|
2881
|
+
catch (error) {
|
|
2882
|
+
return handleError(error, "verify organization user");
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Verify an organization user via mobile
|
|
2887
|
+
*/
|
|
2888
|
+
async verifyOrganizationUserMobile(request) {
|
|
2889
|
+
try {
|
|
2890
|
+
const organizationUserMobileVerifyResponse = await this.httpClient.post("/organization/user/verify-mobile", request);
|
|
2891
|
+
return handleResponse(organizationUserMobileVerifyResponse, "Verify organization user mobile");
|
|
2892
|
+
}
|
|
2893
|
+
catch (error) {
|
|
2894
|
+
return handleError(error, "verify organization user mobile");
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* List virtual POS terminals for the organization
|
|
2899
|
+
*/
|
|
2900
|
+
async listOrganizationVpos(request) {
|
|
2901
|
+
try {
|
|
2902
|
+
const organizationVposResponse = await this.httpClient.post("/organization/list-vpos", request);
|
|
2903
|
+
return handleResponse(organizationVposResponse, "List organization VPOs");
|
|
2904
|
+
}
|
|
2905
|
+
catch (error) {
|
|
2906
|
+
return handleError(error, "list organization VPOs");
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2365
2909
|
async createSubscription(request) {
|
|
2366
2910
|
try {
|
|
2367
|
-
const
|
|
2368
|
-
return handleResponse(
|
|
2911
|
+
const subcriptionCreateResponse = await this.httpClient.post("/subscription/create", request);
|
|
2912
|
+
return handleResponse(subcriptionCreateResponse, "Create subscription");
|
|
2369
2913
|
}
|
|
2370
2914
|
catch (error) {
|
|
2371
2915
|
return handleError(error, "create subscription");
|
|
@@ -2373,8 +2917,8 @@ class TapsilatSDK {
|
|
|
2373
2917
|
}
|
|
2374
2918
|
async getSubscription(request) {
|
|
2375
2919
|
try {
|
|
2376
|
-
const
|
|
2377
|
-
const data = handleResponse(
|
|
2920
|
+
const subscriptionDetailResponse = await this.httpClient.post("/subscription", request);
|
|
2921
|
+
const data = handleResponse(subscriptionDetailResponse, "Get subscription");
|
|
2378
2922
|
if (data.orders) {
|
|
2379
2923
|
data.orders.forEach((order) => {
|
|
2380
2924
|
if (order.payment_url && !order.payment_url.startsWith("http")) {
|
|
@@ -2390,8 +2934,8 @@ class TapsilatSDK {
|
|
|
2390
2934
|
}
|
|
2391
2935
|
async listSubscriptions(params = {}) {
|
|
2392
2936
|
try {
|
|
2393
|
-
const
|
|
2394
|
-
return handleResponse(
|
|
2937
|
+
const listSubscriptionsResponse = await this.httpClient.get("/subscription/list", { params });
|
|
2938
|
+
return handleResponse(listSubscriptionsResponse, "List subscriptions");
|
|
2395
2939
|
}
|
|
2396
2940
|
catch (error) {
|
|
2397
2941
|
return handleError(error, "list subscriptions");
|
|
@@ -2399,8 +2943,8 @@ class TapsilatSDK {
|
|
|
2399
2943
|
}
|
|
2400
2944
|
async cancelSubscription(request) {
|
|
2401
2945
|
try {
|
|
2402
|
-
const
|
|
2403
|
-
return handleResponse(
|
|
2946
|
+
const subscriptionCancelResponse = await this.httpClient.post("/subscription/cancel", request);
|
|
2947
|
+
return handleResponse(subscriptionCancelResponse, "Cancel subscription");
|
|
2404
2948
|
}
|
|
2405
2949
|
catch (error) {
|
|
2406
2950
|
return handleError(error, "cancel subscription");
|
|
@@ -2408,8 +2952,8 @@ class TapsilatSDK {
|
|
|
2408
2952
|
}
|
|
2409
2953
|
async redirectSubscription(request) {
|
|
2410
2954
|
try {
|
|
2411
|
-
const
|
|
2412
|
-
const data = handleResponse(
|
|
2955
|
+
const subscriptionRedirectResponse = await this.httpClient.post("/subscription/redirect", request);
|
|
2956
|
+
const data = handleResponse(subscriptionRedirectResponse, "Redirect subscription");
|
|
2413
2957
|
if (data.url) {
|
|
2414
2958
|
// Extract subscription ID from the signed URL to create a clean link
|
|
2415
2959
|
// api returns: /token/subscription/{id}
|
|
@@ -2430,6 +2974,24 @@ class TapsilatSDK {
|
|
|
2430
2974
|
}
|
|
2431
2975
|
}
|
|
2432
2976
|
|
|
2977
|
+
/**
|
|
2978
|
+
* @module Types
|
|
2979
|
+
* @description Tapsilat SDK type definitions, interfaces, and API data structures
|
|
2980
|
+
*/
|
|
2981
|
+
/**
|
|
2982
|
+
* @category Organization
|
|
2983
|
+
* @summary Organization business types
|
|
2984
|
+
* @enum {number}
|
|
2985
|
+
*/
|
|
2986
|
+
exports.BusinessType = void 0;
|
|
2987
|
+
(function (BusinessType) {
|
|
2988
|
+
BusinessType[BusinessType["INDIVIDUAL"] = 0] = "INDIVIDUAL";
|
|
2989
|
+
BusinessType[BusinessType["CORPORATE"] = 1] = "CORPORATE";
|
|
2990
|
+
BusinessType[BusinessType["NON_PROFIT"] = 2] = "NON_PROFIT";
|
|
2991
|
+
BusinessType[BusinessType["GOVERNMENT"] = 3] = "GOVERNMENT";
|
|
2992
|
+
BusinessType[BusinessType["UNKNOWN"] = 4] = "UNKNOWN";
|
|
2993
|
+
})(exports.BusinessType || (exports.BusinessType = {}));
|
|
2994
|
+
|
|
2433
2995
|
exports.ConfigManager = ConfigManager;
|
|
2434
2996
|
exports.TapsilatAuthenticationError = TapsilatAuthenticationError;
|
|
2435
2997
|
exports.TapsilatError = TapsilatError;
|