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