@tapsilat/tapsilat-js 2026.4.2 → 2026.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -361,7 +361,7 @@ class HttpClient {
361
361
  let lastError = null;
362
362
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
363
363
  try {
364
- const response = await this.makeRequest(interceptedUrl, interceptedOptions, config?.timeout);
364
+ const response = await this.makeRequest(interceptedUrl, interceptedOptions, config?.timeout, config?.responseType);
365
365
  // Execute response interceptors
366
366
  const interceptedResponse = await this.interceptors.executeResponseInterceptors(response, {
367
367
  url: interceptedUrl,
@@ -399,7 +399,7 @@ class HttpClient {
399
399
  * @param timeout - Optional timeout in milliseconds
400
400
  * @returns Promise resolving to API response
401
401
  */
402
- async makeRequest(url, options, timeout) {
402
+ async makeRequest(url, options, timeout, responseType) {
403
403
  const controller = new AbortController();
404
404
  const timeoutId = timeout
405
405
  ? setTimeout(() => controller.abort(), timeout)
@@ -413,7 +413,7 @@ class HttpClient {
413
413
  if (timeoutId) {
414
414
  clearTimeout(timeoutId);
415
415
  }
416
- return await this.processResponse(response);
416
+ return await this.processResponse(response, responseType);
417
417
  }
418
418
  catch (error) {
419
419
  if (timeoutId) {
@@ -436,12 +436,21 @@ class HttpClient {
436
436
  * @param response - The raw fetch Response object
437
437
  * @returns Processed API response
438
438
  */
439
- async processResponse(response) {
439
+ async processResponse(response, responseType) {
440
440
  const contentType = response.headers.get("content-type");
441
441
  const isJson = contentType?.includes("application/json");
442
442
  let responseData;
443
443
  try {
444
- if (isJson) {
444
+ if (responseType === "blob") {
445
+ responseData = await response.blob();
446
+ }
447
+ else if (responseType === "arraybuffer") {
448
+ responseData = await response.arrayBuffer();
449
+ }
450
+ else if (responseType === "text") {
451
+ responseData = await response.text();
452
+ }
453
+ else if (isJson || responseType === "json") {
445
454
  responseData = await response.json();
446
455
  }
447
456
  else {
@@ -1436,7 +1445,12 @@ class TapsilatSDK {
1436
1445
  status: (referenceId) => this.getOrderStatus(referenceId),
1437
1446
  refund: (request) => this.refundOrder(request),
1438
1447
  refundAll: (referenceId) => this.refundAllOrder(referenceId),
1439
- paymentDetails: (referenceId, conversationId) => this.getOrderPaymentDetails(referenceId, conversationId),
1448
+ paymentDetails: (request) => this.getOrderPaymentDetails(request),
1449
+ paymentDetailsById: (referenceId) => this.getOrderPaymentDetailsById(referenceId),
1450
+ callback: (id) => this.orderCallback(id),
1451
+ updatePaymentOptions: (request) => this.updatePaymentOptions(request),
1452
+ splitItemPayment: (request) => this.splitOrderItemPayment(request),
1453
+ vposQuery: (id) => this.orderVposQuery(id),
1440
1454
  byConversationId: (conversationId) => this.getOrderByConversationId(conversationId),
1441
1455
  transactions: (referenceId) => this.getOrderTransactions(referenceId),
1442
1456
  submerchants: (params) => this.getOrderSubmerchants(params),
@@ -1455,6 +1469,11 @@ class TapsilatSDK {
1455
1469
  getTerm: (termReferenceId) => this.getOrderTerm(termReferenceId),
1456
1470
  terminateTerm: (request) => this.terminateOrderTerm(request),
1457
1471
  terminate: (request) => this.terminateOrder(request),
1472
+ getPayments: (request) => this.getOrderPayments(request),
1473
+ getPdf: (id) => this.getOrderPdf(id),
1474
+ getExcel: (id) => this.getOrderExcel(id),
1475
+ createRefundRequest: (request) => this.createOrderRefundRequest(request),
1476
+ addOip: (request) => this.addOrderOip(request),
1458
1477
  };
1459
1478
  }
1460
1479
  /**
@@ -1484,13 +1503,48 @@ class TapsilatSDK {
1484
1503
  getLimitUser: (request) => this.getOrganizationLimitUser(request),
1485
1504
  setLimitUser: (request) => this.setOrganizationLimitUser(request),
1486
1505
  limits: () => this.getOrganizationLimits(),
1487
- meta: () => this.getOrganizationMeta(),
1506
+ meta: (name) => this.getOrganizationMeta(name),
1488
1507
  scopes: () => this.getOrganizationScopes(),
1489
- suborganizations: () => this.getOrganizationSuborganizations(),
1508
+ suborganizations: (params) => this.getOrganizationSuborganizations(params),
1490
1509
  createUser: (request) => this.createOrganizationUser(request),
1491
1510
  verifyUser: (request) => this.verifyOrganizationUser(request),
1492
1511
  verifyUserMobile: (request) => this.verifyOrganizationUserMobile(request),
1493
1512
  listVpos: (request) => this.listOrganizationVpos(request),
1513
+ currencyPresets: () => this.getOrganizationCurrencyPresets(),
1514
+ suborganizationDetails: (id) => this.getOrganizationSuborganizationDetails(id),
1515
+ suborganizationSubmerchants: (id) => this.getOrganizationSuborganizationSubmerchants(id),
1516
+ createUserToken: (request) => this.createOrganizationUserToken(request),
1517
+ };
1518
+ }
1519
+ /**
1520
+ * Access to submerchant operations
1521
+ */
1522
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1523
+ get submerchant() {
1524
+ return {
1525
+ create: (request) => this.createSubmerchant(request),
1526
+ get: (id) => this.getSubmerchant(id),
1527
+ getSuborganization: (id) => this.getSuborganizationBySubmerchant(id),
1528
+ update: (id, request) => this.updateSubmerchant(id, request),
1529
+ delete: (id) => this.deleteSubmerchant(id),
1530
+ list: (page, perPage) => this.listSubmerchants(page, perPage),
1531
+ };
1532
+ }
1533
+ /**
1534
+ * Access to system operations
1535
+ */
1536
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1537
+ get system() {
1538
+ return {
1539
+ orderStatuses: () => this.getSystemOrderStatuses(),
1540
+ basketItemTypes: () => this.getSystemBasketItemTypes(),
1541
+ errorCodes: () => this.getSystemErrorCodes(),
1542
+ paymentTermStatuses: () => this.getSystemPaymentTermStatuses(),
1543
+ productTypes: () => this.getSystemProductTypes(),
1544
+ shortcutTypes: () => this.getSystemShortcutTypes(),
1545
+ transactionPaymentTypes: () => this.getSystemTransactionPaymentTypes(),
1546
+ transactionPurposes: () => this.getSystemTransactionPurposes(),
1547
+ transactionStatuses: () => this.getSystemTransactionStatuses(),
1494
1548
  };
1495
1549
  }
1496
1550
  /**
@@ -1536,10 +1590,10 @@ class TapsilatSDK {
1536
1590
  * @param {string} [orderRequest.payment_success_url] - URL to redirect after successful payment
1537
1591
  * @param {string} [orderRequest.payment_failure_url] - URL to redirect after failed payment
1538
1592
  * @param {number[]} [orderRequest.enabled_installments] - Allowed installment counts
1539
- * @param {Record<string, unknown>} [orderRequest.metadata] - Additional custom data
1593
+ * @param {OrderMetadata[]} [orderRequest.metadata] - Additional custom key/value data
1540
1594
  *
1541
1595
  * @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
1542
- * @returns {string} OrderCreateResponse.order_id - Internal order identifier
1596
+ * @returns {string} [OrderCreateResponse.id] - Internal order identifier
1543
1597
  * @returns {string} OrderCreateResponse.reference_id - Unique order reference for tracking
1544
1598
  * @returns {string} [OrderCreateResponse.checkout_url] - Payment page URL for customer
1545
1599
  * @returns {string} [OrderCreateResponse.conversation_id] - Echo of provided conversation ID
@@ -1595,7 +1649,6 @@ class TapsilatSDK {
1595
1649
  if (!isValidEmail(buyer.email)) {
1596
1650
  throw new TapsilatValidationError("Buyer email must be a valid email address", { provided: buyer.email });
1597
1651
  }
1598
- // Basket items and billing address are optional in Python ref and Swagger
1599
1652
  try {
1600
1653
  // Make the API request
1601
1654
  const createOrderResponse = await this.httpClient.post("/order/create", orderRequest);
@@ -1617,7 +1670,7 @@ class TapsilatSDK {
1617
1670
  * @description Handles accounting operations for a specific order using its reference ID.
1618
1671
  *
1619
1672
  * @param {OrderAccountingRequest} request - Accounting request details
1620
- * @returns {Promise<APIResponse<unknown>>} Promise resolving to the accounting response
1673
+ * @returns {Promise<OrderAccountingResponse>} Promise resolving to the accounting response
1621
1674
  * @throws {TapsilatValidationError} When input validation fails
1622
1675
  * @throws {TapsilatError} When API returns an error response
1623
1676
  */
@@ -1626,8 +1679,8 @@ class TapsilatSDK {
1626
1679
  throw new TapsilatValidationError("Order reference ID is required and must be a non-empty string", { provided: request.order_reference_id });
1627
1680
  }
1628
1681
  try {
1629
- const response = await this.httpClient.post("/order/accounting", request);
1630
- return handleResponse(response, "Order accounting");
1682
+ const orderAccountingResponse = await this.httpClient.post("/order/accounting", request);
1683
+ return handleResponse(orderAccountingResponse, "Order accounting");
1631
1684
  }
1632
1685
  catch (error) {
1633
1686
  return handleError(error, "order accounting");
@@ -1643,7 +1696,7 @@ class TapsilatSDK {
1643
1696
  * @description Handles post-authorization operations for a specific order.
1644
1697
  *
1645
1698
  * @param {OrderPostAuthRequest} request - Post-authorization request details
1646
- * @returns {Promise<APIResponse<unknown>>} Promise resolving to the post-auth response
1699
+ * @returns {Promise<OrderPostAuthResponse>} Promise resolving to the post-auth response
1647
1700
  * @throws {TapsilatValidationError} When input validation fails
1648
1701
  * @throws {TapsilatError} When API returns an error response
1649
1702
  */
@@ -1657,8 +1710,8 @@ class TapsilatSDK {
1657
1710
  });
1658
1711
  }
1659
1712
  try {
1660
- const response = await this.httpClient.post("/order/postauth", request);
1661
- return handleResponse(response, "Order post-auth");
1713
+ const orderPostAuthResponse = await this.httpClient.post("/order/postauth", request);
1714
+ return handleResponse(orderPostAuthResponse, "Order post-auth");
1662
1715
  }
1663
1716
  catch (error) {
1664
1717
  return handleError(error, "order post-auth");
@@ -1673,18 +1726,122 @@ class TapsilatSDK {
1673
1726
  * @summary Retrieve system order statuses
1674
1727
  * @description Gets a list of all possible order statuses in the system.
1675
1728
  *
1676
- * @returns {Promise<APIResponse<unknown>>} Promise resolving to system order statuses
1729
+ * @returns {Promise<GetSystemOrderStatusesResponse>} Promise resolving to system order statuses
1677
1730
  * @throws {TapsilatError} When API returns an error response
1678
1731
  */
1679
1732
  async getSystemOrderStatuses() {
1680
1733
  try {
1681
- const response = await this.httpClient.get("/system/order-statuses");
1682
- return handleResponse(response, "Get system order statuses");
1734
+ const getSystemOrderStatusesResponse = await this.httpClient.get("/system/order-statuses");
1735
+ return handleResponse(getSystemOrderStatusesResponse, "Get system order statuses");
1683
1736
  }
1684
1737
  catch (error) {
1685
1738
  return handleError(error, "get system order statuses");
1686
1739
  }
1687
1740
  }
1741
+ /**
1742
+ * Retrieves system basket item types.
1743
+ * Based on `get_system_basket_item_types` from Python SDK.
1744
+ */
1745
+ async getSystemBasketItemTypes() {
1746
+ try {
1747
+ const response = await this.httpClient.get("/system/basket-item-types");
1748
+ return handleResponse(response, "Get system basket item types");
1749
+ }
1750
+ catch (error) {
1751
+ return handleError(error, "get system basket item types");
1752
+ }
1753
+ }
1754
+ /**
1755
+ * Retrieves system error codes.
1756
+ * Based on `get_system_error_codes` from Python SDK.
1757
+ */
1758
+ async getSystemErrorCodes() {
1759
+ try {
1760
+ const response = await this.httpClient.get("/system/error-codes");
1761
+ return handleResponse(response, "Get system error codes");
1762
+ }
1763
+ catch (error) {
1764
+ return handleError(error, "get system error codes");
1765
+ }
1766
+ }
1767
+ /**
1768
+ * Retrieves system payment term statuses.
1769
+ * Based on `get_system_payment_term_statuses` from Python SDK.
1770
+ */
1771
+ async getSystemPaymentTermStatuses() {
1772
+ try {
1773
+ const response = await this.httpClient.get("/system/payment-term-statuses");
1774
+ return handleResponse(response, "Get system payment term statuses");
1775
+ }
1776
+ catch (error) {
1777
+ return handleError(error, "get system payment term statuses");
1778
+ }
1779
+ }
1780
+ /**
1781
+ * Retrieves system product types.
1782
+ * Based on `get_system_product_types` from Python SDK.
1783
+ */
1784
+ async getSystemProductTypes() {
1785
+ try {
1786
+ const response = await this.httpClient.get("/system/product-types");
1787
+ return handleResponse(response, "Get system product types");
1788
+ }
1789
+ catch (error) {
1790
+ return handleError(error, "get system product types");
1791
+ }
1792
+ }
1793
+ /**
1794
+ * Retrieves system shortcut types.
1795
+ * Based on `get_system_shortcut_types` from Python SDK.
1796
+ */
1797
+ async getSystemShortcutTypes() {
1798
+ try {
1799
+ const response = await this.httpClient.get("/system/shortcut-types");
1800
+ return handleResponse(response, "Get system shortcut types");
1801
+ }
1802
+ catch (error) {
1803
+ return handleError(error, "get system shortcut types");
1804
+ }
1805
+ }
1806
+ /**
1807
+ * Retrieves system transaction payment types.
1808
+ * Based on `get_system_transaction_payment_types` from Python SDK.
1809
+ */
1810
+ async getSystemTransactionPaymentTypes() {
1811
+ try {
1812
+ const response = await this.httpClient.get("/system/transaction-payment-types");
1813
+ return handleResponse(response, "Get system transaction payment types");
1814
+ }
1815
+ catch (error) {
1816
+ return handleError(error, "get system transaction payment types");
1817
+ }
1818
+ }
1819
+ /**
1820
+ * Retrieves system transaction purposes.
1821
+ * Based on `get_system_transaction_purposes` from Python SDK.
1822
+ */
1823
+ async getSystemTransactionPurposes() {
1824
+ try {
1825
+ const response = await this.httpClient.get("/system/transaction-purposes");
1826
+ return handleResponse(response, "Get system transaction purposes");
1827
+ }
1828
+ catch (error) {
1829
+ return handleError(error, "get system transaction purposes");
1830
+ }
1831
+ }
1832
+ /**
1833
+ * Retrieves system transaction statuses.
1834
+ * Based on `get_system_transaction_statuses` from Python SDK.
1835
+ */
1836
+ async getSystemTransactionStatuses() {
1837
+ try {
1838
+ const response = await this.httpClient.get("/system/transaction-statuses");
1839
+ return handleResponse(response, "Get system transaction statuses");
1840
+ }
1841
+ catch (error) {
1842
+ return handleError(error, "get system transaction statuses");
1843
+ }
1844
+ }
1688
1845
  // ORDER RETRIEVAL BY REFERENCE ID
1689
1846
  // Summary: Get complete order details and information
1690
1847
  // Description: Retrieves full order data including buyer info, amounts, and current status
@@ -1757,6 +1914,10 @@ class TapsilatSDK {
1757
1914
  throw new TapsilatValidationError("Items per page must be greater than 0", { provided: params.per_page });
1758
1915
  }
1759
1916
  }
1917
+ // Check if status is defined
1918
+ if (params.status !== undefined && !isInteger(params.status)) {
1919
+ throw new TapsilatValidationError("Status must be an integer", { provided: params.status });
1920
+ }
1760
1921
  // Make the API request
1761
1922
  const getOrdersResponse = await this.httpClient.get("/order/list", { params: params });
1762
1923
  // Use our generic response handler
@@ -1782,23 +1943,28 @@ class TapsilatSDK {
1782
1943
  * @throws {TapsilatError} When API returns an error response or order cannot be canceled
1783
1944
  */
1784
1945
  async cancelOrder(referenceId) {
1785
- // Validate referenceId
1786
1946
  if (!isNonEmptyString(referenceId)) {
1787
1947
  throw new TapsilatValidationError("Order referenceId is required and must be a non-empty string", { provided: referenceId });
1788
1948
  }
1789
- const cancelOrderResponse = await this.httpClient.post("/order/cancel", {
1790
- reference_id: referenceId,
1791
- });
1792
- // Check if API call was successful
1793
- if (!cancelOrderResponse.success) {
1794
- throw new TapsilatError(cancelOrderResponse.error?.message ||
1795
- "Order cancellation API call failed", cancelOrderResponse.error?.code || "CANCELLATION_API_FAILED");
1949
+ try {
1950
+ const cancelOrderPayload = {
1951
+ reference_id: referenceId,
1952
+ };
1953
+ const cancelOrderResponse = await this.httpClient.post("/order/cancel", cancelOrderPayload);
1954
+ // Check if API call was successful
1955
+ if (!cancelOrderResponse.success) {
1956
+ throw new TapsilatError(cancelOrderResponse.error?.message ||
1957
+ "Order cancellation API call failed", cancelOrderResponse.error?.code || "CANCELLATION_API_FAILED");
1958
+ }
1959
+ // Check if response data exists
1960
+ if (!cancelOrderResponse.data) {
1961
+ throw new TapsilatError("Order cancellation response data is missing", "CANCELLATION_DATA_MISSING");
1962
+ }
1963
+ return cancelOrderResponse.data;
1796
1964
  }
1797
- // Check if response data exists
1798
- if (!cancelOrderResponse.data) {
1799
- throw new TapsilatError("Order cancellation response data is missing", "CANCELLATION_DATA_MISSING");
1965
+ catch (error) {
1966
+ return handleError(error, "order cancellation");
1800
1967
  }
1801
- return cancelOrderResponse.data;
1802
1968
  }
1803
1969
  // ORDER STATUS RETRIEVAL
1804
1970
  // Summary: Retrieves real-time payment status and tracking information for a specific order
@@ -1809,12 +1975,12 @@ class TapsilatSDK {
1809
1975
  * @summary Retrieves real-time payment status and tracking information for a specific order
1810
1976
  * @description
1811
1977
  * Queries the Tapsilat payment platform to retrieve the current status of an order using its
1812
- * unique reference ID. This method provides real-time information about payment progress,
1813
- * completion status, and last update timestamp. It's essential for tracking payment flow
1978
+ * unique reference ID. This method provides real-time information about payment processing
1979
+ * status and error code (if returned by the API). It's essential for tracking payment flow
1814
1980
  * and implementing proper order state management in your application.
1815
1981
  *
1816
- * The status information includes payment state (CREATED, PENDING_PAYMENT, COMPLETED, CANCELLED),
1817
- * last update timestamp, and any relevant status metadata. This method should be used to:
1982
+ * The status information includes payment state and API-level error code metadata.
1983
+ * This method should be used to:
1818
1984
  * - Check if a payment has been completed after redirecting from checkout
1819
1985
  * - Monitor payment status for pending transactions
1820
1986
  * - Verify order state before fulfilling goods/services
@@ -1823,13 +1989,11 @@ class TapsilatSDK {
1823
1989
  * @param {string} referenceId - Unique order reference identifier from order creation
1824
1990
  *
1825
1991
  * @returns {Promise<OrderStatusResponse>} Promise resolving to current order status information
1826
- * @returns {string} OrderStatusResponse.referenceId - Echo of the provided reference ID
1827
- * @returns {string} OrderStatusResponse.status - Current payment status (CREATED, PENDING_PAYMENT, COMPLETED, CANCELLED, FAILED)
1828
- * @returns {string} OrderStatusResponse.lastUpdatedAt - ISO 8601 timestamp of last status change
1992
+ * @returns {string} [OrderStatusResponse.error_code] - API-level error code when present
1993
+ * @returns {string} [OrderStatusResponse.status] - Current payment processing status
1829
1994
  *
1830
1995
  * @throws {TapsilatValidationError} When input validation fails:
1831
1996
  * - Reference ID is null, undefined, or empty string
1832
- * - Reference ID format is invalid (should match order ID pattern)
1833
1997
  * @throws {TapsilatNetworkError} When network request fails:
1834
1998
  * - Connection timeout during status check
1835
1999
  * - DNS resolution failure
@@ -1870,14 +2034,19 @@ class TapsilatSDK {
1870
2034
  * @throws {TapsilatError} When API returns an error response or refund fails
1871
2035
  */
1872
2036
  async refundOrder(refundData) {
1873
- const refundOrderResponse = await this.httpClient.post("/order/refund", refundData);
1874
- if (!refundOrderResponse.success) {
1875
- throw new TapsilatError(refundOrderResponse.error?.message || "Order refund failed", refundOrderResponse.error?.code || "REFUND_FAILED");
2037
+ try {
2038
+ const refundOrderResponse = await this.httpClient.post("/order/refund", refundData);
2039
+ if (!refundOrderResponse.success) {
2040
+ throw new TapsilatError(refundOrderResponse.error?.message || "Order refund failed", refundOrderResponse.error?.code || "REFUND_FAILED");
2041
+ }
2042
+ if (!refundOrderResponse.data) {
2043
+ throw new TapsilatError("Order refund response data is missing", "REFUND_DATA_MISSING");
2044
+ }
2045
+ return refundOrderResponse.data;
1876
2046
  }
1877
- if (!refundOrderResponse.data) {
1878
- throw new TapsilatError("Order refund response data is missing", "REFUND_DATA_MISSING");
2047
+ catch (error) {
2048
+ return handleError(error, "order refund");
1879
2049
  }
1880
- return refundOrderResponse.data;
1881
2050
  }
1882
2051
  // ORDER FULL REFUND OPERATIONS
1883
2052
  // Summary: Process full refund for a completed order
@@ -1894,48 +2063,109 @@ class TapsilatSDK {
1894
2063
  * @throws {TapsilatError} When API returns an error response or full refund fails
1895
2064
  */
1896
2065
  async refundAllOrder(referenceId) {
1897
- const refundAllOrderResponse = await this.httpClient.post("/order/refund-all", {
1898
- reference_id: referenceId,
1899
- });
1900
- if (!refundAllOrderResponse.success) {
1901
- throw new TapsilatError(refundAllOrderResponse.error?.message || "Full order refund failed", refundAllOrderResponse.error?.code || "FULL_REFUND_FAILED");
2066
+ try {
2067
+ const refundAllPayload = {
2068
+ reference_id: referenceId,
2069
+ };
2070
+ const refundAllOrderResponse = await this.httpClient.post("/order/refund-all", refundAllPayload);
2071
+ if (!refundAllOrderResponse.success) {
2072
+ throw new TapsilatError(refundAllOrderResponse.error?.message || "Full order refund failed", refundAllOrderResponse.error?.code || "FULL_REFUND_FAILED");
2073
+ }
2074
+ if (!refundAllOrderResponse.data) {
2075
+ throw new TapsilatError("Full order refund response data is missing", "FULL_REFUND_DATA_MISSING");
2076
+ }
2077
+ return refundAllOrderResponse.data;
1902
2078
  }
1903
- if (!refundAllOrderResponse.data) {
1904
- throw new TapsilatError("Full order refund response data is missing", "FULL_REFUND_DATA_MISSING");
2079
+ catch (error) {
2080
+ return handleError(error, "full order refund");
1905
2081
  }
1906
- return refundAllOrderResponse.data;
1907
2082
  }
1908
2083
  // ORDER PAYMENT DETAILS
1909
2084
  // Summary: Retrieve detailed payment transaction information for an order
1910
2085
  // Description: Gets payment method, amount, status, and card info for order transactions
1911
2086
  /**
1912
- * Retrieves the payment details for an order.
2087
+ * Retrieves the payment details for an order via POST request.
1913
2088
  * Based on `get_order_payment_details` from the Python SDK.
1914
- *
1915
- * @summary Retrieve detailed payment transaction information for an order
1916
- * @description Gets payment method, amount, status, and card info for order transactions.
1917
- *
1918
- * @param referenceId - The unique identifier of the order.
1919
- * @param conversationId - Optional conversation ID for more specific querying.
1920
- * @returns Promise resolving to a list of payment details.
1921
- * @throws {TapsilatValidationError} When referenceId is invalid
1922
- * @throws {TapsilatError} When API returns an error response or payment details are missing
1923
2089
  */
1924
- async getOrderPaymentDetails(referenceId, conversationId) {
2090
+ async getOrderPaymentDetails(request) {
2091
+ try {
2092
+ const getOrderPaymentDetailsResponse = await this.httpClient.post("/order/payment-details", request);
2093
+ return handleResponse(getOrderPaymentDetailsResponse, "Order payment details");
2094
+ }
2095
+ catch (error) {
2096
+ return handleError(error, "order payment details");
2097
+ }
2098
+ }
2099
+ /**
2100
+ * Retrieves the payment details for an order by ID.
2101
+ * Based on `get_order_payment_details_by_id` from the Python SDK.
2102
+ */
2103
+ async getOrderPaymentDetailsById(referenceId) {
1925
2104
  if (!isNonEmptyString(referenceId))
1926
2105
  throw new TapsilatValidationError("Reference ID is required and must be a non-empty string");
1927
- const getOrderPaymentDetailsResponse = conversationId
1928
- ? await this.httpClient.post("/order/payment-details", {
1929
- conversation_id: conversationId,
1930
- })
1931
- : await this.httpClient.get(`/order/${referenceId}/payment-details`);
1932
- if (!getOrderPaymentDetailsResponse.success)
1933
- throw new TapsilatError(getOrderPaymentDetailsResponse.error?.message ||
1934
- "Payment details API call failed", getOrderPaymentDetailsResponse.error?.code ||
1935
- "PAYMENT_DETAILS_API_FAILED");
1936
- if (!getOrderPaymentDetailsResponse.data)
1937
- throw new TapsilatError("Payment details response data is missing", "PAYMENT_DETAILS_DATA_MISSING");
1938
- return getOrderPaymentDetailsResponse.data;
2106
+ try {
2107
+ const getOrderPaymentDetailsResponse = await this.httpClient.get(`/order/${referenceId}/payment-details`);
2108
+ return handleResponse(getOrderPaymentDetailsResponse, "Order payment details by id");
2109
+ }
2110
+ catch (error) {
2111
+ return handleError(error, "order payment details by id");
2112
+ }
2113
+ }
2114
+ /**
2115
+ * Retrieves the order callback via GET request.
2116
+ * Based on `order_callback` from the Python SDK.
2117
+ */
2118
+ async orderCallback(id) {
2119
+ if (!isNonEmptyString(id))
2120
+ throw new TapsilatValidationError("ID is required and must be a non-empty string");
2121
+ try {
2122
+ const response = await this.httpClient.get(`/orders/${id}/callback`);
2123
+ return handleResponse(response, "Order callback");
2124
+ }
2125
+ catch (error) {
2126
+ return handleError(error, "order callback");
2127
+ }
2128
+ }
2129
+ /**
2130
+ * Updates payment options for an order.
2131
+ * Based on `update_payment_options` from the Python SDK.
2132
+ */
2133
+ async updatePaymentOptions(request) {
2134
+ try {
2135
+ const response = await this.httpClient.patch("/order/payment-options", request);
2136
+ return handleResponse(response, "Update payment options");
2137
+ }
2138
+ catch (error) {
2139
+ return handleError(error, "update payment options");
2140
+ }
2141
+ }
2142
+ /**
2143
+ * Splits order item payment.
2144
+ * Based on `split_order_item_payment` from the Python SDK.
2145
+ */
2146
+ async splitOrderItemPayment(request) {
2147
+ try {
2148
+ const response = await this.httpClient.post("/order/split", request);
2149
+ return handleResponse(response, "Split order item payment");
2150
+ }
2151
+ catch (error) {
2152
+ return handleError(error, "split order item payment");
2153
+ }
2154
+ }
2155
+ /**
2156
+ * Queries vpos for an order.
2157
+ * Based on `order_vpos_query` from the Python SDK.
2158
+ */
2159
+ async orderVposQuery(id) {
2160
+ if (!isNonEmptyString(id))
2161
+ throw new TapsilatValidationError("ID is required and must be a non-empty string");
2162
+ try {
2163
+ const response = await this.httpClient.get(`/orders/${id}/vpos-query`);
2164
+ return handleResponse(response, "Order vpos query");
2165
+ }
2166
+ catch (error) {
2167
+ return handleError(error, "order vpos query");
2168
+ }
1939
2169
  }
1940
2170
  // ORDER LOOKUP BY CONVERSATION ID
1941
2171
  // Summary: Find order using conversation ID instead of reference ID
@@ -1957,13 +2187,18 @@ class TapsilatSDK {
1957
2187
  if (!isNonEmptyString(conversationId)) {
1958
2188
  throw new TapsilatValidationError("Order conversationId is required and must be a non-empty string", { provided: conversationId });
1959
2189
  }
1960
- const getOrderByConversationIdResponse = await this.httpClient.get(`/order/conversation/${conversationId}`);
1961
- if (!getOrderByConversationIdResponse.success)
1962
- throw new TapsilatError(getOrderByConversationIdResponse.error?.message ||
1963
- "Order retrieval by conversation ID failed", getOrderByConversationIdResponse.error?.code || "ORDER_RETRIEVAL_FAILED");
1964
- if (!getOrderByConversationIdResponse.data)
1965
- throw new TapsilatError("Order response data is missing", "ORDER_DATA_MISSING");
1966
- return getOrderByConversationIdResponse.data;
2190
+ try {
2191
+ const getOrderByConversationIdResponse = await this.httpClient.get(`/order/conversation/${conversationId}`);
2192
+ if (!getOrderByConversationIdResponse.success)
2193
+ throw new TapsilatError(getOrderByConversationIdResponse.error?.message ||
2194
+ "Order retrieval by conversation ID failed", getOrderByConversationIdResponse.error?.code || "ORDER_RETRIEVAL_FAILED");
2195
+ if (!getOrderByConversationIdResponse.data)
2196
+ throw new TapsilatError("Order response data is missing", "ORDER_DATA_MISSING");
2197
+ return getOrderByConversationIdResponse.data;
2198
+ }
2199
+ catch (error) {
2200
+ return handleError(error, "order retrieval by conversation ID");
2201
+ }
1967
2202
  }
1968
2203
  // ORDER TRANSACTION HISTORY
1969
2204
  // Summary: Retrieve transaction history for an order
@@ -1985,14 +2220,19 @@ class TapsilatSDK {
1985
2220
  if (!isNonEmptyString(referenceId)) {
1986
2221
  throw new TapsilatValidationError("Order referenceId is required and must be a non-empty string", { provided: referenceId });
1987
2222
  }
1988
- const getOrderTransactionsResponse = await this.httpClient.get(`/order/${referenceId}/transactions`);
1989
- if (!getOrderTransactionsResponse.success)
1990
- throw new TapsilatError(getOrderTransactionsResponse.error?.message ||
1991
- "Order transactions retrieval failed", getOrderTransactionsResponse.error?.code ||
1992
- "TRANSACTIONS_RETRIEVAL_FAILED");
1993
- if (!getOrderTransactionsResponse.data)
1994
- throw new TapsilatError("Order transactions response data is missing", "TRANSACTIONS_DATA_MISSING");
1995
- return getOrderTransactionsResponse.data;
2223
+ try {
2224
+ const getOrderTransactionsResponse = await this.httpClient.get(`/order/${referenceId}/transactions`);
2225
+ if (!getOrderTransactionsResponse.success)
2226
+ throw new TapsilatError(getOrderTransactionsResponse.error?.message ||
2227
+ "Order transactions retrieval failed", getOrderTransactionsResponse.error?.code ||
2228
+ "TRANSACTIONS_RETRIEVAL_FAILED");
2229
+ if (!getOrderTransactionsResponse.data)
2230
+ throw new TapsilatError("Order transactions response data is missing", "TRANSACTIONS_DATA_MISSING");
2231
+ return getOrderTransactionsResponse.data;
2232
+ }
2233
+ catch (error) {
2234
+ return handleError(error, "order transactions retrieval");
2235
+ }
1996
2236
  }
1997
2237
  // ORDER SUBMERCHANT LISTING
1998
2238
  // Summary: Retrieve paginated list of submerchants for orders
@@ -2009,16 +2249,15 @@ class TapsilatSDK {
2009
2249
  * @throws {TapsilatError} When API returns an error response
2010
2250
  */
2011
2251
  async getOrderSubmerchants(params = {}) {
2012
- const getOrderSubmerchantsResponse = await this.httpClient.get("/order/submerchants", {
2013
- params: params,
2014
- });
2015
- if (!getOrderSubmerchantsResponse.success)
2016
- throw new TapsilatError(getOrderSubmerchantsResponse.error?.message ||
2017
- "Order submerchants retrieval failed", getOrderSubmerchantsResponse.error?.code ||
2018
- "SUBMERCHANTS_RETRIEVAL_FAILED");
2019
- if (!getOrderSubmerchantsResponse.data)
2020
- throw new TapsilatError("Order submerchants response data is missing", "SUBMERCHANTS_DATA_MISSING");
2021
- return getOrderSubmerchantsResponse.data;
2252
+ try {
2253
+ const getOrderSubmerchantsResponse = await this.httpClient.get("/order/submerchants", {
2254
+ params: params,
2255
+ });
2256
+ return handleResponse(getOrderSubmerchantsResponse, "Order submerchants retrieval");
2257
+ }
2258
+ catch (error) {
2259
+ return handleError(error, "order submerchants retrieval");
2260
+ }
2022
2261
  }
2023
2262
  // ORDER CHECKOUT URL RETRIEVAL
2024
2263
  // Summary: Retrieve checkout URL for existing order
@@ -2078,19 +2317,22 @@ class TapsilatSDK {
2078
2317
  * @throws {TapsilatError} When API health check fails or returns invalid data
2079
2318
  */
2080
2319
  async healthCheck() {
2081
- // We use the direct /health endpoint which returns plain string "OK"
2082
- const healthCheckResponse = await this.httpClient.get("/health");
2083
- if (!healthCheckResponse.success) {
2084
- throw new TapsilatError(healthCheckResponse.error?.message || "Health check failed", healthCheckResponse.error?.code || "HEALTH_CHECK_FAILED");
2320
+ try {
2321
+ // We use the direct /health endpoint which returns plain string "OK"
2322
+ const healthCheckResponse = await this.httpClient.get("/health");
2323
+ const healthData = handleResponse(healthCheckResponse, "Health check");
2324
+ // The API returns "OK" string, verify consistency
2325
+ if (healthData !== "OK") {
2326
+ throw new TapsilatError(`Unexpected health check response: ${healthData}`, "HEALTH_CHECK_INVALID_RESPONSE");
2327
+ }
2328
+ return {
2329
+ status: "UP",
2330
+ timestamp: new Date().toISOString(),
2331
+ };
2085
2332
  }
2086
- // The API returns "OK" string, verify consistency
2087
- if (healthCheckResponse.data !== "OK") {
2088
- throw new TapsilatError(`Unexpected health check response: ${healthCheckResponse.data}`, "HEALTH_CHECK_INVALID_RESPONSE");
2333
+ catch (error) {
2334
+ return handleError(error, "health check");
2089
2335
  }
2090
- return {
2091
- status: "UP",
2092
- timestamp: new Date().toISOString(),
2093
- };
2094
2336
  }
2095
2337
  // CONFIGURATION MANAGEMENT
2096
2338
  // Summary: Access to the configuration manager for advanced configuration management
@@ -2383,8 +2625,8 @@ class TapsilatSDK {
2383
2625
  payload.conversation_id = conversationId;
2384
2626
  }
2385
2627
  try {
2386
- const response = await this.httpClient.post("/order/manual-callback", payload);
2387
- return handleResponse(response, "Order manual callback");
2628
+ const orderManualCallbackResponse = await this.httpClient.post("/order/callback", payload);
2629
+ return handleResponse(orderManualCallbackResponse, "Order manual callback");
2388
2630
  }
2389
2631
  catch (error) {
2390
2632
  return handleError(error, "order manual callback");
@@ -2398,11 +2640,12 @@ class TapsilatSDK {
2398
2640
  throw new TapsilatValidationError("Related Reference ID is required and must be a non-empty string");
2399
2641
  }
2400
2642
  try {
2401
- const response = await this.httpClient.post("/order/related-update", {
2643
+ const payload = {
2402
2644
  reference_id: referenceId,
2403
2645
  related_reference_id: relatedReferenceId,
2404
- });
2405
- return handleResponse(response, "Order related update");
2646
+ };
2647
+ const orderRelatedUpdateResponse = await this.httpClient.patch("/order/releated", payload);
2648
+ return handleResponse(orderRelatedUpdateResponse, "Order related update");
2406
2649
  }
2407
2650
  catch (error) {
2408
2651
  return handleError(error, "order related update");
@@ -2410,8 +2653,8 @@ class TapsilatSDK {
2410
2653
  }
2411
2654
  async getOrganizationSettings() {
2412
2655
  try {
2413
- const response = await this.httpClient.get("/organization/settings");
2414
- return handleResponse(response, "Get organization settings");
2656
+ const organizationSettingsResponse = await this.httpClient.get("/organization/settings");
2657
+ return handleResponse(organizationSettingsResponse, "Get organization settings");
2415
2658
  }
2416
2659
  catch (error) {
2417
2660
  return handleError(error, "get organization settings");
@@ -2422,10 +2665,10 @@ class TapsilatSDK {
2422
2665
  throw new TapsilatValidationError("Term Reference ID is required and must be a non-empty string");
2423
2666
  }
2424
2667
  try {
2425
- const response = await this.httpClient.get(`/order/term`, {
2668
+ const orderTermResponse = await this.httpClient.get(`/order/term`, {
2426
2669
  params: { term_reference_id: termReferenceId },
2427
2670
  });
2428
- return handleResponse(response, "Get order term");
2671
+ return handleResponse(orderTermResponse, "Get order term");
2429
2672
  }
2430
2673
  catch (error) {
2431
2674
  return handleError(error, "get order term");
@@ -2437,8 +2680,8 @@ class TapsilatSDK {
2437
2680
  */
2438
2681
  async addBasketItem(request) {
2439
2682
  try {
2440
- const response = await this.httpClient.post("/order/basket-item", request);
2441
- return handleResponse(response, "Add basket item");
2683
+ const addBasketItemResponse = await this.httpClient.post("/order/basket-item", request);
2684
+ return handleResponse(addBasketItemResponse, "Add basket item");
2442
2685
  }
2443
2686
  catch (error) {
2444
2687
  return handleError(error, "add basket item");
@@ -2449,8 +2692,8 @@ class TapsilatSDK {
2449
2692
  */
2450
2693
  async removeBasketItem(request) {
2451
2694
  try {
2452
- const response = await this.httpClient.delete("/order/basket-item", request);
2453
- return handleResponse(response, "Remove basket item");
2695
+ const removeBasketItemResponse = await this.httpClient.delete("/order/basket-item", request);
2696
+ return handleResponse(removeBasketItemResponse, "Remove basket item");
2454
2697
  }
2455
2698
  catch (error) {
2456
2699
  return handleError(error, "remove basket item");
@@ -2461,8 +2704,8 @@ class TapsilatSDK {
2461
2704
  */
2462
2705
  async updateBasketItem(request) {
2463
2706
  try {
2464
- const response = await this.httpClient.patch("/order/basket-item", request);
2465
- return handleResponse(response, "Update basket item");
2707
+ const updateBasketItemResponse = await this.httpClient.patch("/order/basket-item", request);
2708
+ return handleResponse(updateBasketItemResponse, "Update basket item");
2466
2709
  }
2467
2710
  catch (error) {
2468
2711
  return handleError(error, "update basket item");
@@ -2473,8 +2716,8 @@ class TapsilatSDK {
2473
2716
  */
2474
2717
  async getOrganizationCallback() {
2475
2718
  try {
2476
- const response = await this.httpClient.get("/organization/callback");
2477
- return handleResponse(response, "Get organization callback");
2719
+ const organizationCallbackResponse = await this.httpClient.get("/organization/callback");
2720
+ return handleResponse(organizationCallbackResponse, "Get organization callback");
2478
2721
  }
2479
2722
  catch (error) {
2480
2723
  return handleError(error, "get organization callback");
@@ -2485,8 +2728,8 @@ class TapsilatSDK {
2485
2728
  */
2486
2729
  async updateOrganizationCallback(request) {
2487
2730
  try {
2488
- const response = await this.httpClient.patch("/organization/callback", request);
2489
- return handleResponse(response, "Update organization callback");
2731
+ const organizationCallbackResponse = await this.httpClient.patch("/organization/callback", request);
2732
+ return handleResponse(organizationCallbackResponse, "Update organization callback");
2490
2733
  }
2491
2734
  catch (error) {
2492
2735
  return handleError(error, "update organization callback");
@@ -2497,8 +2740,8 @@ class TapsilatSDK {
2497
2740
  */
2498
2741
  async createOrganizationBusiness(request) {
2499
2742
  try {
2500
- const response = await this.httpClient.post("/organization/business/create", request);
2501
- return handleResponse(response, "Create organization business");
2743
+ const organizationBusinessResponse = await this.httpClient.post("/organization/business/create", request);
2744
+ return handleResponse(organizationBusinessResponse, "Create organization business");
2502
2745
  }
2503
2746
  catch (error) {
2504
2747
  return handleError(error, "create organization business");
@@ -2509,20 +2752,63 @@ class TapsilatSDK {
2509
2752
  */
2510
2753
  async getOrganizationCurrencies() {
2511
2754
  try {
2512
- const response = await this.httpClient.get("/organization/currencies");
2513
- return handleResponse(response, "Get organization currencies");
2755
+ const organizationCurrenciesResponse = await this.httpClient.get("/organization/currencies");
2756
+ return handleResponse(organizationCurrenciesResponse, "Get organization currencies");
2514
2757
  }
2515
2758
  catch (error) {
2516
2759
  return handleError(error, "get organization currencies");
2517
2760
  }
2518
2761
  }
2762
+ /**
2763
+ * Retrieves organization currency presets.
2764
+ * Based on `get_organization_currency_presets` from Python SDK.
2765
+ */
2766
+ async getOrganizationCurrencyPresets() {
2767
+ try {
2768
+ const response = await this.httpClient.get("/organization/currency-presets");
2769
+ return handleResponse(response, "Get organization currency presets");
2770
+ }
2771
+ catch (error) {
2772
+ return handleError(error, "get organization currency presets");
2773
+ }
2774
+ }
2775
+ /**
2776
+ * Retrieves organization suborganization details.
2777
+ * Based on `get_organization_suborganization_details` from Python SDK.
2778
+ */
2779
+ async getOrganizationSuborganizationDetails(id) {
2780
+ if (!isNonEmptyString(id))
2781
+ throw new TapsilatValidationError("ID is required and must be a non-empty string");
2782
+ try {
2783
+ const response = await this.httpClient.get(`/organization/suborganizations/${id}`);
2784
+ return handleResponse(response, "Get suborganization details");
2785
+ }
2786
+ catch (error) {
2787
+ return handleError(error, "get suborganization details");
2788
+ }
2789
+ }
2790
+ /**
2791
+ * Retrieves organization suborganization submerchants.
2792
+ * Based on `get_organization_suborganization_submerchants` from Python SDK.
2793
+ */
2794
+ async getOrganizationSuborganizationSubmerchants(id) {
2795
+ if (!isNonEmptyString(id))
2796
+ throw new TapsilatValidationError("ID is required and must be a non-empty string");
2797
+ try {
2798
+ const response = await this.httpClient.get(`/organization/suborganizations/${id}/submerchant`);
2799
+ return handleResponse(response, "Get suborganization submerchants");
2800
+ }
2801
+ catch (error) {
2802
+ return handleError(error, "get suborganization submerchants");
2803
+ }
2804
+ }
2519
2805
  /**
2520
2806
  * Retrieve limit information for a specific organization user
2521
2807
  */
2522
2808
  async getOrganizationLimitUser(request) {
2523
2809
  try {
2524
- const response = await this.httpClient.get("/organization/limit/user", { params: request });
2525
- return handleResponse(response, "Get organization user limit");
2810
+ const organizationLimitUserResponse = await this.httpClient.get("/organization/limit/user", { params: request });
2811
+ return handleResponse(organizationLimitUserResponse, "Get organization user limit");
2526
2812
  }
2527
2813
  catch (error) {
2528
2814
  return handleError(error, "get organization user limit");
@@ -2533,8 +2819,8 @@ class TapsilatSDK {
2533
2819
  */
2534
2820
  async setOrganizationLimitUser(request) {
2535
2821
  try {
2536
- const response = await this.httpClient.post("/organization/limit/user", request);
2537
- return handleResponse(response, "Set organization user limit");
2822
+ const organizationLimitUserResponse = await this.httpClient.post("/organization/limit/user", request);
2823
+ return handleResponse(organizationLimitUserResponse, "Set organization user limit");
2538
2824
  }
2539
2825
  catch (error) {
2540
2826
  return handleError(error, "set organization user limit");
@@ -2545,8 +2831,8 @@ class TapsilatSDK {
2545
2831
  */
2546
2832
  async getOrganizationLimits() {
2547
2833
  try {
2548
- const response = await this.httpClient.get("/organization/limits");
2549
- return handleResponse(response, "Get organization limits");
2834
+ const organizationLimitsResponse = await this.httpClient.get("/organization/limits");
2835
+ return handleResponse(organizationLimitsResponse, "Get organization limits");
2550
2836
  }
2551
2837
  catch (error) {
2552
2838
  return handleError(error, "get organization limits");
@@ -2555,10 +2841,13 @@ class TapsilatSDK {
2555
2841
  /**
2556
2842
  * Retrieve meta information for the organization
2557
2843
  */
2558
- async getOrganizationMeta() {
2844
+ async getOrganizationMeta(name) {
2845
+ if (!isNonEmptyString(name)) {
2846
+ throw new TapsilatValidationError("Meta name is required and must be a non-empty string");
2847
+ }
2559
2848
  try {
2560
- const response = await this.httpClient.get("/organization/meta");
2561
- return handleResponse(response, "Get organization meta");
2849
+ const organizationMetaResponse = await this.httpClient.get(`/organization/metas/${name}`);
2850
+ return handleResponse(organizationMetaResponse, "Get organization meta");
2562
2851
  }
2563
2852
  catch (error) {
2564
2853
  return handleError(error, "get organization meta");
@@ -2569,8 +2858,8 @@ class TapsilatSDK {
2569
2858
  */
2570
2859
  async getOrganizationScopes() {
2571
2860
  try {
2572
- const response = await this.httpClient.get("/organization/scopes");
2573
- return handleResponse(response, "Get organization scopes");
2861
+ const organizationScopesResponse = await this.httpClient.get("/organization/scopes");
2862
+ return handleResponse(organizationScopesResponse, "Get organization scopes");
2574
2863
  }
2575
2864
  catch (error) {
2576
2865
  return handleError(error, "get organization scopes");
@@ -2579,10 +2868,20 @@ class TapsilatSDK {
2579
2868
  /**
2580
2869
  * Retrieve list of sub-organizations
2581
2870
  */
2582
- async getOrganizationSuborganizations() {
2871
+ async getOrganizationSuborganizations(params = {}) {
2872
+ if (params.page !== undefined) {
2873
+ if (!isInteger(params.page) || params.page < 1) {
2874
+ throw new TapsilatValidationError("Suborganization page must be a positive integer", { provided: params.page });
2875
+ }
2876
+ }
2877
+ if (params.per_page !== undefined) {
2878
+ if (!isInteger(params.per_page) || params.per_page < 1) {
2879
+ throw new TapsilatValidationError("Suborganization per_page must be a positive integer", { provided: params.per_page });
2880
+ }
2881
+ }
2583
2882
  try {
2584
- const response = await this.httpClient.get("/organization/suborganizations");
2585
- return handleResponse(response, "Get organization suborganizations");
2883
+ const organizationSuborganizationsResponse = await this.httpClient.get("/organization/suborganizations", { params: params });
2884
+ return handleResponse(organizationSuborganizationsResponse, "Get organization suborganizations");
2586
2885
  }
2587
2886
  catch (error) {
2588
2887
  return handleError(error, "get organization suborganizations");
@@ -2593,8 +2892,8 @@ class TapsilatSDK {
2593
2892
  */
2594
2893
  async createOrganizationUser(request) {
2595
2894
  try {
2596
- const response = await this.httpClient.post("/organization/user/create", request);
2597
- return handleResponse(response, "Create organization user");
2895
+ const organizationUserResponse = await this.httpClient.post("/organization/user/create", request);
2896
+ return handleResponse(organizationUserResponse, "Create organization user");
2598
2897
  }
2599
2898
  catch (error) {
2600
2899
  return handleError(error, "create organization user");
@@ -2605,8 +2904,8 @@ class TapsilatSDK {
2605
2904
  */
2606
2905
  async verifyOrganizationUser(request) {
2607
2906
  try {
2608
- const response = await this.httpClient.post("/organization/user/verify", request);
2609
- return handleResponse(response, "Verify organization user");
2907
+ const organizationUserVerifyResponse = await this.httpClient.post("/organization/user/verify", request);
2908
+ return handleResponse(organizationUserVerifyResponse, "Verify organization user");
2610
2909
  }
2611
2910
  catch (error) {
2612
2911
  return handleError(error, "verify organization user");
@@ -2617,8 +2916,8 @@ class TapsilatSDK {
2617
2916
  */
2618
2917
  async verifyOrganizationUserMobile(request) {
2619
2918
  try {
2620
- const response = await this.httpClient.post("/organization/user/verify-mobile", request);
2621
- return handleResponse(response, "Verify organization user mobile");
2919
+ const organizationUserMobileVerifyResponse = await this.httpClient.post("/organization/user/verify-mobile", request);
2920
+ return handleResponse(organizationUserMobileVerifyResponse, "Verify organization user mobile");
2622
2921
  }
2623
2922
  catch (error) {
2624
2923
  return handleError(error, "verify organization user mobile");
@@ -2629,8 +2928,8 @@ class TapsilatSDK {
2629
2928
  */
2630
2929
  async listOrganizationVpos(request) {
2631
2930
  try {
2632
- const response = await this.httpClient.post("/organization/list-vpos", request);
2633
- return handleResponse(response, "List organization VPOs");
2931
+ const organizationVposResponse = await this.httpClient.post("/organization/list-vpos", request);
2932
+ return handleResponse(organizationVposResponse, "List organization VPOs");
2634
2933
  }
2635
2934
  catch (error) {
2636
2935
  return handleError(error, "list organization VPOs");
@@ -2638,8 +2937,8 @@ class TapsilatSDK {
2638
2937
  }
2639
2938
  async createSubscription(request) {
2640
2939
  try {
2641
- const response = await this.httpClient.post("/subscription/create", request);
2642
- return handleResponse(response, "Create subscription");
2940
+ const subcriptionCreateResponse = await this.httpClient.post("/subscription/create", request);
2941
+ return handleResponse(subcriptionCreateResponse, "Create subscription");
2643
2942
  }
2644
2943
  catch (error) {
2645
2944
  return handleError(error, "create subscription");
@@ -2647,8 +2946,8 @@ class TapsilatSDK {
2647
2946
  }
2648
2947
  async getSubscription(request) {
2649
2948
  try {
2650
- const response = await this.httpClient.post("/subscription", request);
2651
- const data = handleResponse(response, "Get subscription");
2949
+ const subscriptionDetailResponse = await this.httpClient.post("/subscription", request);
2950
+ const data = handleResponse(subscriptionDetailResponse, "Get subscription");
2652
2951
  if (data.orders) {
2653
2952
  data.orders.forEach((order) => {
2654
2953
  if (order.payment_url && !order.payment_url.startsWith("http")) {
@@ -2664,8 +2963,8 @@ class TapsilatSDK {
2664
2963
  }
2665
2964
  async listSubscriptions(params = {}) {
2666
2965
  try {
2667
- const response = await this.httpClient.get("/subscription/list", { params });
2668
- return handleResponse(response, "List subscriptions");
2966
+ const listSubscriptionsResponse = await this.httpClient.get("/subscription/list", { params });
2967
+ return handleResponse(listSubscriptionsResponse, "List subscriptions");
2669
2968
  }
2670
2969
  catch (error) {
2671
2970
  return handleError(error, "list subscriptions");
@@ -2673,8 +2972,8 @@ class TapsilatSDK {
2673
2972
  }
2674
2973
  async cancelSubscription(request) {
2675
2974
  try {
2676
- const response = await this.httpClient.post("/subscription/cancel", request);
2677
- return handleResponse(response, "Cancel subscription");
2975
+ const subscriptionCancelResponse = await this.httpClient.post("/subscription/cancel", request);
2976
+ return handleResponse(subscriptionCancelResponse, "Cancel subscription");
2678
2977
  }
2679
2978
  catch (error) {
2680
2979
  return handleError(error, "cancel subscription");
@@ -2682,8 +2981,8 @@ class TapsilatSDK {
2682
2981
  }
2683
2982
  async redirectSubscription(request) {
2684
2983
  try {
2685
- const response = await this.httpClient.post("/subscription/redirect", request);
2686
- const data = handleResponse(response, "Redirect subscription");
2984
+ const subscriptionRedirectResponse = await this.httpClient.post("/subscription/redirect", request);
2985
+ const data = handleResponse(subscriptionRedirectResponse, "Redirect subscription");
2687
2986
  if (data.url) {
2688
2987
  // Extract subscription ID from the signed URL to create a clean link
2689
2988
  // api returns: /token/subscription/{id}
@@ -2702,8 +3001,295 @@ class TapsilatSDK {
2702
3001
  return handleError(error, "redirect subscription");
2703
3002
  }
2704
3003
  }
3004
+ // ORDER PAYMENTS
3005
+ // Summary: Get payments for an order
3006
+ // Description: Retrieve a list of payments made for a specific order.
3007
+ /**
3008
+ * Gets payments for an order.
3009
+ * Based on `get_order_payments` from the Python SDK.
3010
+ *
3011
+ * @summary Get order payments
3012
+ * @description Retrieve a list of payments made for a specific order.
3013
+ *
3014
+ * @param request - Order payments request containing order_id
3015
+ * @returns Promise resolving to order payments
3016
+ */
3017
+ async getOrderPayments(request) {
3018
+ try {
3019
+ const response = await this.httpClient.get(`/order/${request.order_id}/payment`);
3020
+ return handleResponse(response, "Get order payments");
3021
+ }
3022
+ catch (error) {
3023
+ return handleError(error, "get order payments");
3024
+ }
3025
+ }
3026
+ // ORDER PDF
3027
+ // Summary: Download order PDF
3028
+ // Description: Download order as a PDF file.
3029
+ /**
3030
+ * Downloads order PDF.
3031
+ * Based on `get_order_pdf` from the Python SDK.
3032
+ *
3033
+ * @summary Download order PDF
3034
+ * @description Download order as a PDF file.
3035
+ *
3036
+ * @param id - Order reference ID
3037
+ * @returns Promise resolving to a Blob representing the PDF
3038
+ */
3039
+ async getOrderPdf(id) {
3040
+ const response = await this.httpClient.get(`/order/${id}/pdf`, { responseType: 'blob' });
3041
+ if (!response.success) {
3042
+ handleError(response.error, "get order pdf");
3043
+ }
3044
+ return response.data;
3045
+ }
3046
+ // ORDER EXCEL
3047
+ // Summary: Download order Excel
3048
+ // Description: Download order as an Excel file.
3049
+ /**
3050
+ * Downloads order Excel.
3051
+ * Based on `get_order_excel` from the Python SDK.
3052
+ *
3053
+ * @summary Download order Excel
3054
+ * @description Download order as an Excel file.
3055
+ *
3056
+ * @param id - Order reference ID
3057
+ * @returns Promise resolving to a Blob representing the Excel file
3058
+ */
3059
+ async getOrderExcel(id) {
3060
+ const response = await this.httpClient.get(`/order/${id}/excel`, { responseType: 'blob' });
3061
+ if (!response.success) {
3062
+ handleError(response.error, "get order excel");
3063
+ }
3064
+ return response.data;
3065
+ }
3066
+ // ORDER REFUND REQUEST
3067
+ // Summary: Create order refund request
3068
+ // Description: Request a refund for an order.
3069
+ /**
3070
+ * Creates an order refund request.
3071
+ * Based on `create_order_refund_request` from the Python SDK.
3072
+ *
3073
+ * @summary Create order refund request
3074
+ * @description Request a refund for an order.
3075
+ *
3076
+ * @param request - Order refund request payload
3077
+ * @returns Promise resolving to refund response
3078
+ */
3079
+ async createOrderRefundRequest(request) {
3080
+ try {
3081
+ const { reference_id, ...data } = request;
3082
+ const response = await this.httpClient.post(`/order/${reference_id}/refund/request`, data);
3083
+ return handleResponse(response, "Create order refund request");
3084
+ }
3085
+ catch (error) {
3086
+ return handleError(error, "create order refund request");
3087
+ }
3088
+ }
3089
+ // ADD ORDER OIP
3090
+ // Summary: Add Order Item Payment
3091
+ // Description: Adds an order item payment to a specific order.
3092
+ /**
3093
+ * Adds an order item payment.
3094
+ * Based on `add_order_oip` from the Python SDK.
3095
+ *
3096
+ * @summary Add Order OIP
3097
+ * @description Adds an order item payment to a specific order.
3098
+ *
3099
+ * @param request - Order OIP request payload containing order_id and other details
3100
+ * @returns Promise resolving to OIP response
3101
+ */
3102
+ async addOrderOip(request) {
3103
+ try {
3104
+ const { order_id, ...data } = request;
3105
+ const response = await this.httpClient.post(`/order/${order_id}/oip`, data);
3106
+ return handleResponse(response, "Add order OIP");
3107
+ }
3108
+ catch (error) {
3109
+ return handleError(error, "add order oip");
3110
+ }
3111
+ }
3112
+ // CREATE SUBMERCHANT
3113
+ // Summary: Create a submerchant
3114
+ // Description: Creates a new submerchant in the system.
3115
+ /**
3116
+ * Creates a submerchant.
3117
+ * Based on `create_submerchant` from the Python SDK.
3118
+ *
3119
+ * @summary Create submerchant
3120
+ * @description Creates a new submerchant.
3121
+ *
3122
+ * @param request - Submerchant creation payload
3123
+ * @returns Promise resolving to the created submerchant details
3124
+ */
3125
+ async createSubmerchant(request) {
3126
+ try {
3127
+ const response = await this.httpClient.post(`/submerchants`, request);
3128
+ return handleResponse(response, "Create submerchant");
3129
+ }
3130
+ catch (error) {
3131
+ return handleError(error, "create submerchant");
3132
+ }
3133
+ }
3134
+ // GET SUBMERCHANT
3135
+ // Summary: Get submerchant details
3136
+ // Description: Retrieves information about a specific submerchant by ID.
3137
+ /**
3138
+ * Gets a submerchant.
3139
+ * Based on `get_submerchant` from the Python SDK.
3140
+ *
3141
+ * @summary Get submerchant
3142
+ * @description Retrieves submerchant details.
3143
+ *
3144
+ * @param id - Submerchant ID
3145
+ * @returns Promise resolving to submerchant details
3146
+ */
3147
+ async getSubmerchant(id) {
3148
+ try {
3149
+ const response = await this.httpClient.get(`/submerchants/${id}`);
3150
+ return handleResponse(response, "Get submerchant");
3151
+ }
3152
+ catch (error) {
3153
+ return handleError(error, "get submerchant");
3154
+ }
3155
+ }
3156
+ // GET SUBORGANIZATION BY SUBMERCHANT
3157
+ // Summary: Get suborganization by submerchant
3158
+ // Description: Retrieves the suborganization details associated with a submerchant.
3159
+ /**
3160
+ * Gets suborganization by submerchant.
3161
+ * Based on `get_suborganization_by_submerchant` from the Python SDK.
3162
+ *
3163
+ * @summary Get suborganization by submerchant
3164
+ * @description Retrieves the suborganization details associated with a submerchant.
3165
+ *
3166
+ * @param id - Submerchant ID
3167
+ * @returns Promise resolving to suborganization details
3168
+ */
3169
+ async getSuborganizationBySubmerchant(id) {
3170
+ try {
3171
+ const response = await this.httpClient.get(`/submerchants/${id}/suborganization`);
3172
+ return handleResponse(response, "Get suborganization by submerchant");
3173
+ }
3174
+ catch (error) {
3175
+ return handleError(error, "get suborganization by submerchant");
3176
+ }
3177
+ }
3178
+ // UPDATE SUBMERCHANT
3179
+ // Summary: Update submerchant
3180
+ // Description: Updates an existing submerchant.
3181
+ /**
3182
+ * Updates a submerchant.
3183
+ * Based on `update_submerchant` from the Python SDK.
3184
+ *
3185
+ * @summary Update submerchant
3186
+ * @description Updates submerchant details.
3187
+ *
3188
+ * @param id - Submerchant ID
3189
+ * @param request - Update payload
3190
+ * @returns Promise resolving to updated submerchant details
3191
+ */
3192
+ async updateSubmerchant(id, request) {
3193
+ try {
3194
+ const response = await this.httpClient.put(`/submerchants/${id}`, request);
3195
+ return handleResponse(response, "Update submerchant");
3196
+ }
3197
+ catch (error) {
3198
+ return handleError(error, "update submerchant");
3199
+ }
3200
+ }
3201
+ // DELETE SUBMERCHANT
3202
+ // Summary: Delete submerchant
3203
+ // Description: Deletes a submerchant from the system.
3204
+ /**
3205
+ * Deletes a submerchant.
3206
+ * Based on `delete_submerchant` from the Python SDK.
3207
+ *
3208
+ * @summary Delete submerchant
3209
+ * @description Deletes a submerchant.
3210
+ *
3211
+ * @param id - Submerchant ID
3212
+ * @returns Promise resolving to deletion status
3213
+ */
3214
+ async deleteSubmerchant(id) {
3215
+ try {
3216
+ const response = await this.httpClient.delete(`/submerchants/${id}`);
3217
+ return handleResponse(response, "Delete submerchant");
3218
+ }
3219
+ catch (error) {
3220
+ return handleError(error, "delete submerchant");
3221
+ }
3222
+ }
3223
+ // LIST SUBMERCHANTS
3224
+ // Summary: List submerchants
3225
+ // Description: Retrieves a paginated list of submerchants.
3226
+ /**
3227
+ * Lists submerchants.
3228
+ * Based on `list_submerchants` from the Python SDK.
3229
+ *
3230
+ * @summary List submerchants
3231
+ * @description Retrieves a paginated list of submerchants.
3232
+ *
3233
+ * @param page - Page number
3234
+ * @param perPage - Items per page
3235
+ * @returns Promise resolving to list of submerchants
3236
+ */
3237
+ async listSubmerchants(page, perPage) {
3238
+ try {
3239
+ const params = {};
3240
+ if (page)
3241
+ params.page = page;
3242
+ if (perPage)
3243
+ params.per_page = perPage;
3244
+ const response = await this.httpClient.get(`/submerchants`, { params });
3245
+ return handleResponse(response, "List submerchants");
3246
+ }
3247
+ catch (error) {
3248
+ return handleError(error, "list submerchants");
3249
+ }
3250
+ }
3251
+ // CREATE ORGANIZATION USER TOKEN
3252
+ // Summary: Create organization user token
3253
+ // Description: Creates a token for an organization user.
3254
+ /**
3255
+ * Creates an organization user token.
3256
+ * Based on `create_organization_user_token` from the Python SDK.
3257
+ *
3258
+ * @summary Create organization user token
3259
+ * @description Creates a token for an organization user.
3260
+ *
3261
+ * @param request - Token creation payload
3262
+ * @returns Promise resolving to the created token details
3263
+ */
3264
+ async createOrganizationUserToken(request) {
3265
+ try {
3266
+ const response = await this.httpClient.post(`/organization/user/token`, request);
3267
+ return handleResponse(response, "Create organization user token");
3268
+ }
3269
+ catch (error) {
3270
+ return handleError(error, "create organization user token");
3271
+ }
3272
+ }
2705
3273
  }
2706
3274
 
3275
+ /**
3276
+ * @module Types
3277
+ * @description Tapsilat SDK type definitions, interfaces, and API data structures
3278
+ */
3279
+ /**
3280
+ * @category Organization
3281
+ * @summary Organization business types
3282
+ * @enum {number}
3283
+ */
3284
+ exports.BusinessType = void 0;
3285
+ (function (BusinessType) {
3286
+ BusinessType[BusinessType["INDIVIDUAL"] = 0] = "INDIVIDUAL";
3287
+ BusinessType[BusinessType["CORPORATE"] = 1] = "CORPORATE";
3288
+ BusinessType[BusinessType["NON_PROFIT"] = 2] = "NON_PROFIT";
3289
+ BusinessType[BusinessType["GOVERNMENT"] = 3] = "GOVERNMENT";
3290
+ BusinessType[BusinessType["UNKNOWN"] = 4] = "UNKNOWN";
3291
+ })(exports.BusinessType || (exports.BusinessType = {}));
3292
+
2707
3293
  exports.ConfigManager = ConfigManager;
2708
3294
  exports.TapsilatAuthenticationError = TapsilatAuthenticationError;
2709
3295
  exports.TapsilatError = TapsilatError;