@tapsilat/tapsilat-js 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +6 -12
- package/dist/TapsilatSDK.d.ts +202 -173
- package/dist/TapsilatSDK.d.ts.map +1 -1
- package/dist/config/ConfigManager.d.ts +77 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/errors/TapsilatError.d.ts +84 -1
- package/dist/errors/TapsilatError.d.ts.map +1 -1
- package/dist/http/HttpClient.d.ts +126 -27
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/interceptors.d.ts +117 -1
- package/dist/http/interceptors.d.ts.map +1 -1
- package/dist/index.d.ts +880 -228
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +948 -294
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +948 -293
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +545 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +47 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/validators.d.ts +74 -1
- package/dist/utils/validators.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types.d.ts +0 -401
- package/dist/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.4] - 2025-06-16
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Standardized and improved code documentation across the SDK
|
|
14
|
+
- Migrated all type/interface/type alias definitions from src/types.ts to src/types/index.ts
|
|
15
|
+
- Improved error handling in refund methods for clarity
|
|
16
|
+
- Organized type definitions with proper JSDoc annotations (@category, @summary, @description)
|
|
17
|
+
- Deduplicated and consolidated type definitions
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
- src/types.ts file (contents migrated to src/types/index.ts)
|
|
21
|
+
|
|
22
|
+
## [1.0.3]
|
|
23
|
+
|
|
10
24
|
### Added
|
|
11
25
|
- Initial SDK implementation
|
|
12
26
|
- Payment operations (create, get, list, cancel)
|
package/README.md
CHANGED
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://tapsilat.dev)
|
|
6
6
|
|
|
7
7
|
**Enterprise-grade TypeScript SDK for Tapsilat Payment Processing Platform**
|
|
8
8
|
|
|
9
|
-
[](https://www.npmjs.com/package/tapsilat-js)
|
|
10
|
-
[](https://www.typescriptlang.org/)
|
|
11
|
-
[](LICENSE)
|
|
12
|
-
|
|
13
9
|
</div>
|
|
14
10
|
|
|
15
11
|
## 🏢 About Tapsilat
|
|
@@ -50,7 +46,7 @@ const order = await tapsilat.createOrder({
|
|
|
50
46
|
name: "John",
|
|
51
47
|
surname: "Doe",
|
|
52
48
|
email: "john.doe@example.com",
|
|
53
|
-
phone: "+
|
|
49
|
+
phone: "+9099999999",
|
|
54
50
|
},
|
|
55
51
|
description: "Premium subscription - Monthly plan",
|
|
56
52
|
});
|
|
@@ -76,10 +72,10 @@ const order = await tapsilat.createOrder({
|
|
|
76
72
|
currency: 'TRY',
|
|
77
73
|
locale: 'tr',
|
|
78
74
|
buyer: {
|
|
79
|
-
name: '
|
|
80
|
-
surname: '
|
|
81
|
-
email: '
|
|
82
|
-
phone: '+
|
|
75
|
+
name: 'John',
|
|
76
|
+
surname: 'Doe',
|
|
77
|
+
email: 'john-doe@example.com',
|
|
78
|
+
phone: '+9099999999'
|
|
83
79
|
},
|
|
84
80
|
description: 'Product purchase',
|
|
85
81
|
callbackUrl: 'https://mystore.com/success',
|
|
@@ -244,8 +240,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
244
240
|
## 🔗 Resources
|
|
245
241
|
|
|
246
242
|
- 🌐 **Website**: [https://tapsilat.dev](https://tapsilat.dev)
|
|
247
|
-
- 📚 **API Documentation**: [https://docs.tapsilat.dev](https://docs.tapsilat.dev)
|
|
248
|
-
- 📞 **Support**: [support@tapsilat.dev](mailto:support@tapsilat.dev)
|
|
249
243
|
- 🐛 **Issues**: [GitHub Issues](https://github.com/tapsilat/tapsilat-js/issues)
|
|
250
244
|
|
|
251
245
|
---
|
package/dist/TapsilatSDK.d.ts
CHANGED
|
@@ -1,171 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Supported locales for the Tapsilat API.
|
|
4
|
-
*/
|
|
5
|
-
export type Locale = "tr" | "en";
|
|
6
|
-
/**
|
|
7
|
-
* Represents the buyer information.
|
|
8
|
-
* Based on BuyerDTO from the Python SDK.
|
|
9
|
-
*/
|
|
10
|
-
export interface Buyer {
|
|
11
|
-
name: string;
|
|
12
|
-
surname: string;
|
|
13
|
-
email: string;
|
|
14
|
-
phone?: string;
|
|
15
|
-
identityNumber?: string;
|
|
16
|
-
shippingAddress?: Address;
|
|
17
|
-
billingAddress?: Address;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Represents the data required to create a new order.
|
|
21
|
-
* Based on OrderCreateDTO from the Python SDK.
|
|
22
|
-
*/
|
|
23
|
-
export interface OrderCreateRequest {
|
|
24
|
-
amount: number;
|
|
25
|
-
currency: Currency;
|
|
26
|
-
locale: Locale;
|
|
27
|
-
buyer: Buyer;
|
|
28
|
-
description?: string;
|
|
29
|
-
callbackUrl?: string;
|
|
30
|
-
conversationId?: string;
|
|
31
|
-
metadata?: Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Represents the response received after creating an order.
|
|
35
|
-
*/
|
|
36
|
-
export interface OrderCreateResponse {
|
|
37
|
-
referenceId: string;
|
|
38
|
-
conversationId: string;
|
|
39
|
-
checkoutUrl: string;
|
|
40
|
-
status: string;
|
|
41
|
-
qrCodeUrl?: string;
|
|
42
|
-
}
|
|
1
|
+
import { ConfigManager } from "./config/ConfigManager";
|
|
2
|
+
import { TapsilatConfig, PaginatedResponse, Order, OrderRefundRequest, OrderRefundResponse, OrderStatusResponse, OrderPaymentDetail, OrderCreateRequest, OrderCreateResponse } from "./types/index";
|
|
43
3
|
/**
|
|
44
4
|
* Main SDK class for Tapsilat payment operations
|
|
45
5
|
*
|
|
46
|
-
* @
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
6
|
+
* @summary Enterprise-grade TypeScript SDK for Tapsilat Payment Processing Platform
|
|
7
|
+
* @description
|
|
8
|
+
* The TapsilatSDK class provides a comprehensive interface for integrating with the Tapsilat payment platform.
|
|
9
|
+
* It offers secure, efficient, and type-safe methods for managing orders, payments, refunds, and other
|
|
10
|
+
* payment-related operations. The SDK includes built-in error handling, request validation, retry logic,
|
|
11
|
+
* and comprehensive logging capabilities.
|
|
52
12
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
13
|
+
* Key features:
|
|
14
|
+
* - Type-safe API with TypeScript support
|
|
15
|
+
* - Built-in error handling with custom error types
|
|
16
|
+
* - Automatic request/response validation
|
|
17
|
+
* - Configurable retry mechanism
|
|
18
|
+
* - Full compliance with Tapsilat API specifications
|
|
59
19
|
*/
|
|
60
20
|
export declare class TapsilatSDK {
|
|
61
21
|
private readonly httpClient;
|
|
62
|
-
private readonly
|
|
22
|
+
private readonly configManager;
|
|
63
23
|
/**
|
|
64
24
|
* Creates a new TapsilatSDK instance
|
|
65
25
|
*
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
26
|
+
* @summary Initializes the Tapsilat SDK with configuration options
|
|
27
|
+
* @description
|
|
28
|
+
* Creates and configures a new instance of the TapsilatSDK with the provided configuration.
|
|
29
|
+
* The constructor validates the bearer token, sets up the HTTP client with proper headers,
|
|
30
|
+
* configures retry mechanisms, and initializes internal state for API communication.
|
|
31
|
+
*
|
|
32
|
+
* The SDK instance is immutable after creation - configuration cannot be changed without
|
|
33
|
+
* creating a new instance. This ensures thread safety and predictable behavior.
|
|
34
|
+
*
|
|
35
|
+
* @param {TapsilatConfig} config - SDK configuration options
|
|
36
|
+
* @param {string} config.bearerToken - API authentication token (required)
|
|
37
|
+
* @param {string} [config.baseURL='https://api.tapsilat.com/v1'] - API base URL
|
|
38
|
+
* @param {number} [config.timeout=30000] - Request timeout in milliseconds
|
|
39
|
+
* @param {number} [config.maxRetries=3] - Maximum number of retry attempts
|
|
40
|
+
* @param {number} [config.retryDelay=1000] - Delay between retries in milliseconds
|
|
41
|
+
* @param {string} [config.version='v1'] - API version to use
|
|
42
|
+
* @param {boolean} [config.debug=false] - Enable debug logging
|
|
43
|
+
*
|
|
44
|
+
* @throws {TapsilatValidationError} When bearer token is invalid, missing, or malformed
|
|
45
|
+
* @throws {TypeError} When config parameter is not an object or missing required fields
|
|
68
46
|
*/
|
|
69
47
|
constructor(config: TapsilatConfig);
|
|
70
48
|
/**
|
|
71
|
-
* Creates a new order and returns a checkout URL
|
|
49
|
+
* Creates a new order and returns a checkout URL
|
|
72
50
|
*
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
51
|
+
* @summary Initiates a new payment order with buyer information and generates checkout URL
|
|
52
|
+
* @description
|
|
53
|
+
* Creates a new payment order in the Tapsilat system with the provided order details.
|
|
54
|
+
* This method performs comprehensive validation of all input parameters, creates the order
|
|
55
|
+
* on the payment platform, and returns a checkout URL that customers can use to complete
|
|
56
|
+
* their payment. The method supports multiple currencies, locales, and comprehensive
|
|
57
|
+
* buyer information for compliance and fraud prevention.
|
|
78
58
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* const orderResponse = await tapsilat.createOrder({
|
|
83
|
-
* amount: 100.50,
|
|
84
|
-
* currency: 'TRY',
|
|
85
|
-
* locale: 'en',
|
|
86
|
-
* buyer: {
|
|
87
|
-
* name: 'John',
|
|
88
|
-
* surname: 'Doe',
|
|
89
|
-
* email: 'john.doe@example.com'
|
|
90
|
-
* }
|
|
91
|
-
* });
|
|
92
|
-
* console.log(`Checkout URL: ${orderResponse.checkoutUrl}`);
|
|
93
|
-
* } catch (error) {
|
|
94
|
-
* console.error(`Order creation failed: ${error.message}`);
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
createOrder(orderRequest: OrderCreateRequest): Promise<OrderCreateResponse>;
|
|
99
|
-
/**
|
|
100
|
-
* Validates an order request object
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private validateOrderRequest;
|
|
104
|
-
/**
|
|
105
|
-
* Basic email validation
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
private isValidEmail;
|
|
109
|
-
/**
|
|
110
|
-
* Generic response handler - consistent way to handle API responses across SDK methods
|
|
111
|
-
* @private
|
|
59
|
+
* The returned checkout URL is valid for a limited time (typically 24 hours) and should
|
|
60
|
+
* be presented to the customer immediately. The order status can be tracked using the
|
|
61
|
+
* returned reference ID through the getOrderStatus method.
|
|
112
62
|
*
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @
|
|
116
|
-
* @
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
63
|
+
* @param {OrderCreateRequest} orderRequest - Complete order information
|
|
64
|
+
* @param {number} orderRequest.amount - Payment amount (must be positive, max 2 decimal places)
|
|
65
|
+
* @param {Currency} orderRequest.currency - Payment currency ('TRY', 'USD', 'EUR', 'GBP')
|
|
66
|
+
* @param {Locale} orderRequest.locale - Display language ('tr' for Turkish, 'en' for English)
|
|
67
|
+
* @param {Buyer} orderRequest.buyer - Customer information for payment processing
|
|
68
|
+
* @param {string} orderRequest.buyer.name - Customer's first name (required)
|
|
69
|
+
* @param {string} orderRequest.buyer.surname - Customer's last name (required)
|
|
70
|
+
* @param {string} orderRequest.buyer.email - Customer's email address (required, validated)
|
|
71
|
+
* @param {string} [orderRequest.buyer.phone] - Customer's phone number
|
|
72
|
+
* @param {string} [orderRequest.buyer.identityNumber] - National ID or tax number
|
|
73
|
+
* @param {Address} [orderRequest.buyer.shippingAddress] - Shipping address for physical goods
|
|
74
|
+
* @param {Address} [orderRequest.buyer.billingAddress] - Billing address for invoicing
|
|
75
|
+
* @param {string} [orderRequest.description] - Order description for customer reference
|
|
76
|
+
* @param {string} [orderRequest.callbackUrl] - URL to redirect after payment completion
|
|
77
|
+
* @param {string} [orderRequest.conversationId] - Custom tracking ID for your system
|
|
78
|
+
* @param {Record<string, unknown>} [orderRequest.metadata] - Additional custom data
|
|
122
79
|
*
|
|
123
|
-
* @
|
|
124
|
-
* @
|
|
125
|
-
* @
|
|
80
|
+
* @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
|
|
81
|
+
* @returns {string} OrderCreateResponse.referenceId - Unique order identifier for tracking
|
|
82
|
+
* @returns {string} OrderCreateResponse.conversationId - Echo of provided conversation ID
|
|
83
|
+
* @returns {string} OrderCreateResponse.checkoutUrl - Payment page URL for customer
|
|
84
|
+
* @returns {string} OrderCreateResponse.status - Initial order status (typically 'CREATED')
|
|
85
|
+
* @returns {string} [OrderCreateResponse.qrCodeUrl] - QR code URL for mobile payments
|
|
86
|
+
*
|
|
87
|
+
* @throws {TapsilatValidationError} When input validation fails:
|
|
88
|
+
* - Amount is not positive or has more than 2 decimal places
|
|
89
|
+
* - Currency is not supported
|
|
90
|
+
* - Buyer information is incomplete or invalid
|
|
91
|
+
* - Email format is invalid
|
|
92
|
+
* - Required fields are missing
|
|
93
|
+
* @throws {TapsilatNetworkError} When network request fails:
|
|
94
|
+
* - Connection timeout
|
|
95
|
+
* - DNS resolution failure
|
|
96
|
+
* - Network connectivity issues
|
|
97
|
+
* @throws {TapsilatError} When API returns business logic errors:
|
|
98
|
+
* - Insufficient merchant balance
|
|
99
|
+
* - Currency not enabled for merchant
|
|
100
|
+
* - Buyer blocked due to fraud detection
|
|
101
|
+
* - Rate limiting exceeded
|
|
126
102
|
*/
|
|
127
|
-
|
|
103
|
+
createOrder(orderRequest: OrderCreateRequest): Promise<OrderCreateResponse>;
|
|
128
104
|
/**
|
|
129
105
|
* Gets an order by reference ID.
|
|
130
106
|
*
|
|
107
|
+
* @summary Retrieve complete order details and information
|
|
108
|
+
* @description Gets complete order data including buyer info, amounts, and current status using the unique reference ID.
|
|
109
|
+
*
|
|
131
110
|
* @param referenceId - The unique reference ID of the order
|
|
132
111
|
* @returns Promise resolving to the complete order details
|
|
133
112
|
* @throws {TapsilatValidationError} When referenceId is invalid
|
|
134
113
|
* @throws {TapsilatNetworkError} When API request fails due to network issues
|
|
135
114
|
* @throws {TapsilatError} When API returns an error response
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* try {
|
|
140
|
-
* const order = await tapsilat.getOrder("ord_123456789");
|
|
141
|
-
* console.log(`Order amount: ${order.amount} ${order.currency}`);
|
|
142
|
-
* } catch (error) {
|
|
143
|
-
* console.error(`Failed to get order: ${error.message}`);
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
115
|
*/
|
|
147
116
|
getOrder(referenceId: string): Promise<Order>;
|
|
148
117
|
/**
|
|
149
118
|
* Lists orders with pagination support.
|
|
150
119
|
*
|
|
120
|
+
* @summary Retrieve paginated list of merchant orders
|
|
121
|
+
* @description Gets orders with pagination support, filtering, and sorting options.
|
|
122
|
+
*
|
|
151
123
|
* @param params - Optional pagination parameters (page number and items per page)
|
|
152
124
|
* @returns Promise resolving to paginated list of orders
|
|
153
125
|
* @throws {TapsilatNetworkError} When API request fails due to network issues
|
|
154
126
|
* @throws {TapsilatError} When API returns an error response
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* try {
|
|
159
|
-
* // Get the second page with 20 items per page
|
|
160
|
-
* const orderList = await tapsilat.getOrders({ page: 2, per_page: 20 });
|
|
161
|
-
* console.log(`Total orders: ${orderList.total}`);
|
|
162
|
-
* orderList.rows.forEach(order => {
|
|
163
|
-
* console.log(`Order ${order.referenceId}: ${order.amount} ${order.currency}`);
|
|
164
|
-
* });
|
|
165
|
-
* } catch (error) {
|
|
166
|
-
* console.error(`Failed to list orders: ${error.message}`);
|
|
167
|
-
* }
|
|
168
|
-
* ```
|
|
169
127
|
*/
|
|
170
128
|
getOrders(params?: {
|
|
171
129
|
page?: number;
|
|
@@ -173,70 +131,127 @@ export declare class TapsilatSDK {
|
|
|
173
131
|
}): Promise<PaginatedResponse<Order>>;
|
|
174
132
|
/**
|
|
175
133
|
* Cancels an order by reference_id.
|
|
134
|
+
*
|
|
135
|
+
* @summary Cancel a pending order before payment completion
|
|
136
|
+
* @description Cancels unpaid order and prevents further payment processing.
|
|
137
|
+
*
|
|
138
|
+
* @param referenceId - The unique reference ID of the order to cancel
|
|
139
|
+
* @returns Promise resolving to the canceled order details
|
|
140
|
+
* @throws {TapsilatValidationError} When referenceId is invalid
|
|
141
|
+
* @throws {TapsilatError} When API returns an error response or order cannot be canceled
|
|
176
142
|
*/
|
|
177
143
|
cancelOrder(referenceId: string): Promise<Order>;
|
|
178
144
|
/**
|
|
179
|
-
* Gets the status of an order by reference ID
|
|
145
|
+
* Gets the current status of an order by reference ID
|
|
180
146
|
*
|
|
181
|
-
* @
|
|
182
|
-
* @
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
147
|
+
* @summary Retrieves real-time payment status and tracking information for a specific order
|
|
148
|
+
* @description
|
|
149
|
+
* Queries the Tapsilat payment platform to retrieve the current status of an order using its
|
|
150
|
+
* unique reference ID. This method provides real-time information about payment progress,
|
|
151
|
+
* completion status, and last update timestamp. It's essential for tracking payment flow
|
|
152
|
+
* and implementing proper order state management in your application.
|
|
186
153
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* }
|
|
199
|
-
*
|
|
154
|
+
* The status information includes payment state (CREATED, PENDING_PAYMENT, COMPLETED, CANCELLED),
|
|
155
|
+
* last update timestamp, and any relevant status metadata. This method should be used to:
|
|
156
|
+
* - Check if a payment has been completed after redirecting from checkout
|
|
157
|
+
* - Monitor payment status for pending transactions
|
|
158
|
+
* - Verify order state before fulfilling goods/services
|
|
159
|
+
* - Implement webhook verification and status synchronization
|
|
160
|
+
*
|
|
161
|
+
* @param {string} referenceId - Unique order reference identifier from order creation
|
|
162
|
+
*
|
|
163
|
+
* @returns {Promise<OrderStatusResponse>} Promise resolving to current order status information
|
|
164
|
+
* @returns {string} OrderStatusResponse.referenceId - Echo of the provided reference ID
|
|
165
|
+
* @returns {string} OrderStatusResponse.status - Current payment status (CREATED, PENDING_PAYMENT, COMPLETED, CANCELLED, FAILED)
|
|
166
|
+
* @returns {string} OrderStatusResponse.lastUpdatedAt - ISO 8601 timestamp of last status change
|
|
167
|
+
*
|
|
168
|
+
* @throws {TapsilatValidationError} When input validation fails:
|
|
169
|
+
* - Reference ID is null, undefined, or empty string
|
|
170
|
+
* - Reference ID format is invalid (should match order ID pattern)
|
|
171
|
+
* @throws {TapsilatNetworkError} When network request fails:
|
|
172
|
+
* - Connection timeout during status check
|
|
173
|
+
* - DNS resolution failure
|
|
174
|
+
* - Network connectivity issues
|
|
175
|
+
* @throws {TapsilatError} When API returns business logic errors:
|
|
176
|
+
* - ORDER_NOT_FOUND: Order with given reference ID doesn't exist
|
|
177
|
+
* - ACCESS_DENIED: Order belongs to different merchant
|
|
178
|
+
* - RATE_LIMIT_EXCEEDED: Too many status check requests
|
|
200
179
|
*/
|
|
201
180
|
getOrderStatus(referenceId: string): Promise<OrderStatusResponse>;
|
|
202
181
|
/**
|
|
203
182
|
* Partially refunds an order.
|
|
204
183
|
* Based on `refund_order` from the Python SDK.
|
|
205
184
|
*
|
|
185
|
+
* @summary Process partial refund for a completed order
|
|
186
|
+
* @description Refunds specified amount from a paid order and returns transaction details.
|
|
187
|
+
*
|
|
206
188
|
* @param refundData - The refund details, including referenceId and amount.
|
|
207
189
|
* @returns Promise resolving to the refund transaction details.
|
|
190
|
+
* @throws {TapsilatError} When API returns an error response or refund fails
|
|
208
191
|
*/
|
|
209
192
|
refundOrder(refundData: OrderRefundRequest): Promise<OrderRefundResponse>;
|
|
210
193
|
/**
|
|
211
194
|
* Fully refunds an order by its reference ID.
|
|
212
195
|
* Based on `refund_all_order` from the Python SDK.
|
|
213
196
|
*
|
|
197
|
+
* @summary Process full refund for a completed order
|
|
198
|
+
* @description Refunds entire order amount and returns transaction details.
|
|
199
|
+
*
|
|
214
200
|
* @param referenceId - The unique identifier of the order to fully refund.
|
|
215
201
|
* @returns Promise resolving to the refund transaction details.
|
|
202
|
+
* @throws {TapsilatError} When API returns an error response or full refund fails
|
|
216
203
|
*/
|
|
217
204
|
refundAllOrder(referenceId: string): Promise<OrderRefundResponse>;
|
|
218
205
|
/**
|
|
219
206
|
* Retrieves the payment details for an order.
|
|
220
207
|
* Based on `get_order_payment_details` from the Python SDK.
|
|
221
208
|
*
|
|
209
|
+
* @summary Retrieve detailed payment transaction information for an order
|
|
210
|
+
* @description Gets payment method, amount, status, and card info for order transactions.
|
|
211
|
+
*
|
|
222
212
|
* @param referenceId - The unique identifier of the order.
|
|
223
213
|
* @param conversationId - Optional conversation ID for more specific querying.
|
|
224
214
|
* @returns Promise resolving to a list of payment details.
|
|
215
|
+
* @throws {TapsilatValidationError} When referenceId is invalid
|
|
216
|
+
* @throws {TapsilatError} When API returns an error response or payment details are missing
|
|
225
217
|
*/
|
|
226
218
|
getOrderPaymentDetails(referenceId: string, conversationId?: string): Promise<OrderPaymentDetail[]>;
|
|
227
219
|
/**
|
|
228
220
|
* Gets an order by conversation_id.
|
|
229
221
|
* Based on `get_order_by_conversation_id` from the Python SDK.
|
|
222
|
+
*
|
|
223
|
+
* @summary Find order using conversation ID instead of reference ID
|
|
224
|
+
* @description Alternative lookup method for orders using custom conversation identifier.
|
|
225
|
+
*
|
|
226
|
+
* @param conversationId - The custom conversation identifier used when creating the order
|
|
227
|
+
* @returns Promise resolving to the complete order details
|
|
228
|
+
* @throws {TapsilatValidationError} When conversationId is invalid
|
|
229
|
+
* @throws {TapsilatError} When API returns an error response
|
|
230
230
|
*/
|
|
231
231
|
getOrderByConversationId(conversationId: string): Promise<Order>;
|
|
232
232
|
/**
|
|
233
233
|
* Gets order transactions by reference_id.
|
|
234
234
|
* Based on `get_order_transactions` from the Python SDK.
|
|
235
|
+
*
|
|
236
|
+
* @summary Retrieve transaction history for an order
|
|
237
|
+
* @description Gets detailed transaction records and payment attempts for a specific order.
|
|
238
|
+
*
|
|
239
|
+
* @param referenceId - The unique reference ID of the order
|
|
240
|
+
* @returns Promise resolving to array of transaction records
|
|
241
|
+
* @throws {TapsilatValidationError} When referenceId is invalid
|
|
242
|
+
* @throws {TapsilatError} When API returns an error response
|
|
235
243
|
*/
|
|
236
244
|
getOrderTransactions(referenceId: string): Promise<any[]>;
|
|
237
245
|
/**
|
|
238
246
|
* Gets order submerchants with pagination.
|
|
239
247
|
* Based on `get_order_submerchants` from the Python SDK.
|
|
248
|
+
*
|
|
249
|
+
* @summary Retrieve paginated list of submerchants for orders
|
|
250
|
+
* @description Gets submerchant information with pagination support for order management.
|
|
251
|
+
*
|
|
252
|
+
* @param params - Optional pagination parameters (page number and items per page)
|
|
253
|
+
* @returns Promise resolving to paginated list of submerchants
|
|
254
|
+
* @throws {TapsilatError} When API returns an error response
|
|
240
255
|
*/
|
|
241
256
|
getOrderSubmerchants(params?: {
|
|
242
257
|
page?: number;
|
|
@@ -245,49 +260,63 @@ export declare class TapsilatSDK {
|
|
|
245
260
|
/**
|
|
246
261
|
* Gets checkout URL for an order.
|
|
247
262
|
* Based on `get_checkout_url` from the Python SDK.
|
|
263
|
+
*
|
|
264
|
+
* @summary Retrieve checkout URL for existing order
|
|
265
|
+
* @description Gets the payment checkout URL for an existing order using reference ID.
|
|
266
|
+
*
|
|
267
|
+
* @param referenceId - The unique reference ID of the order
|
|
268
|
+
* @returns Promise resolving to the checkout URL string
|
|
269
|
+
* @throws {TapsilatError} When checkout URL is not found in order response
|
|
248
270
|
*/
|
|
249
271
|
getCheckoutUrl(referenceId: string): Promise<string>;
|
|
250
272
|
/**
|
|
251
273
|
* Verifies webhook signature for security
|
|
252
274
|
*
|
|
275
|
+
* @summary Validate webhook signature for security verification
|
|
276
|
+
* @description Verifies the authenticity of webhook payloads using HMAC signature validation.
|
|
277
|
+
*
|
|
253
278
|
* @param payload - Raw webhook payload string
|
|
254
279
|
* @param signature - Webhook signature from headers
|
|
255
280
|
* @param secret - Your webhook secret key
|
|
256
281
|
* @returns Promise resolving to true if signature is valid
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* ```typescript
|
|
260
|
-
* const isValid = await sdk.verifyWebhook(
|
|
261
|
-
* JSON.stringify(req.body),
|
|
262
|
-
* req.headers['x-tapsilat-signature'],
|
|
263
|
-
* 'your-webhook-secret'
|
|
264
|
-
* );
|
|
265
|
-
* ```
|
|
282
|
+
* @throws {TapsilatValidationError} When input validation fails for payload, signature or secret
|
|
266
283
|
*/
|
|
267
284
|
verifyWebhook(payload: string, signature: string, secret: string): Promise<boolean>;
|
|
268
285
|
/**
|
|
269
286
|
* Checks API service health and availability
|
|
270
287
|
*
|
|
271
|
-
* @
|
|
288
|
+
* @summary Check API service health and availability
|
|
289
|
+
* @description Verifies that the Tapsilat API service is operational and accessible.
|
|
290
|
+
*
|
|
291
|
+
* @returns Promise resolving to service status with status string and timestamp
|
|
292
|
+
* @throws {TapsilatError} When API health check fails or returns invalid data
|
|
272
293
|
*/
|
|
273
294
|
healthCheck(): Promise<{
|
|
274
295
|
status: string;
|
|
275
296
|
timestamp: string;
|
|
276
297
|
}>;
|
|
277
298
|
/**
|
|
278
|
-
* Gets
|
|
299
|
+
* Gets the configuration manager instance
|
|
279
300
|
*
|
|
280
|
-
* @
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
*
|
|
301
|
+
* @summary Access to the configuration manager for advanced configuration management
|
|
302
|
+
* @description
|
|
303
|
+
* Provides direct access to the ConfigManager instance for configuration operations.
|
|
304
|
+
* Use this to get, update, or manage SDK configuration settings.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* const sdk = new TapsilatSDK(config);
|
|
309
|
+
* const configManager = sdk.getConfigManager();
|
|
310
|
+
*
|
|
311
|
+
* // Get config (without sensitive data)
|
|
312
|
+
* console.log(configManager.getConfig());
|
|
313
|
+
*
|
|
314
|
+
* // Update config
|
|
315
|
+
* configManager.updateConfig({ timeout: 60000 });
|
|
316
|
+
* ```
|
|
287
317
|
*
|
|
288
|
-
* @
|
|
289
|
-
* @throws {TapsilatValidationError} When Bearer token is invalid
|
|
318
|
+
* @returns ConfigManager instance for configuration operations
|
|
290
319
|
*/
|
|
291
|
-
|
|
320
|
+
getConfigManager(): ConfigManager;
|
|
292
321
|
}
|
|
293
322
|
//# sourceMappingURL=TapsilatSDK.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TapsilatSDK.d.ts","sourceRoot":"","sources":["../src/TapsilatSDK.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TapsilatSDK.d.ts","sourceRoot":"","sources":["../src/TapsilatSDK.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAcvD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAGvB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAK9C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;gBACS,MAAM,EAAE,cAAc;IASlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsDG;IACG,WAAW,CACf,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,mBAAmB,CAAC;IAwF/B;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IA0BnD;;;;;;;;;;OAUG;IACG,SAAS,CACb,MAAM,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAwDpC;;;;;;;;;;OAUG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAuCtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2BvE;;;;;;;;;;OAUG;IACG,WAAW,CACf,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;IA0B/B;;;;;;;;;;OAUG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA0BvE;;;;;;;;;;;;OAYG;IACG,sBAAsB,CAC1B,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAqChC;;;;;;;;;;;OAWG;IACG,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAgCtE;;;;;;;;;;;OAWG;IACG,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IA+B/D;;;;;;;;;;OAUG;IACG,oBAAoB,CACxB,MAAM,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,GAAG,CAAC;IA2Bf;;;;;;;;;;OAUG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc1D;;;;;;;;;;;OAWG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;IAoBnB;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAwBnE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,gBAAgB,IAAI,aAAa;CAGlC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Configuration
|
|
3
|
+
* @module ConfigManager
|
|
4
|
+
*/
|
|
5
|
+
import { TapsilatConfig } from "../types/index";
|
|
6
|
+
/**
|
|
7
|
+
* @category Configuration
|
|
8
|
+
* @summary Configuration management for Tapsilat SDK
|
|
9
|
+
* @description Handles SDK configuration updates, validation, and secure access to configuration data
|
|
10
|
+
* @class ConfigManager
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConfigManager {
|
|
13
|
+
private config;
|
|
14
|
+
/**
|
|
15
|
+
* @summary Creates a new configuration manager
|
|
16
|
+
* @description Initializes the configuration manager with the provided configuration options
|
|
17
|
+
*
|
|
18
|
+
* @param config - Initial SDK configuration
|
|
19
|
+
*/
|
|
20
|
+
constructor(config: TapsilatConfig);
|
|
21
|
+
/**
|
|
22
|
+
* @category Configuration Access
|
|
23
|
+
* @summary Get current SDK configuration without sensitive information
|
|
24
|
+
* @description Returns a copy of the current configuration with sensitive data (like bearer token) excluded
|
|
25
|
+
*
|
|
26
|
+
* @returns Copy of current configuration without bearer token
|
|
27
|
+
*/
|
|
28
|
+
getConfig(): Omit<TapsilatConfig, "bearerToken"> & {
|
|
29
|
+
hasBearerToken: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @category Configuration Management
|
|
33
|
+
* @summary Update SDK configuration with new values
|
|
34
|
+
* @description Updates the SDK configuration with provided values, validating bearer token if changed
|
|
35
|
+
*
|
|
36
|
+
* @param newConfig - Partial configuration to update
|
|
37
|
+
* @throws {TapsilatValidationError} When Bearer token is invalid
|
|
38
|
+
*/
|
|
39
|
+
updateConfig(newConfig: Partial<TapsilatConfig>): void;
|
|
40
|
+
/**
|
|
41
|
+
* @category Internal
|
|
42
|
+
* @summary Gets the internal configuration for SDK use
|
|
43
|
+
* @description Returns a full copy of the configuration for internal SDK operations
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
* @returns Full configuration including sensitive data
|
|
47
|
+
*/
|
|
48
|
+
getInternalConfig(): TapsilatConfig;
|
|
49
|
+
/**
|
|
50
|
+
* @category Authentication
|
|
51
|
+
* @summary Gets the bearer token for authentication
|
|
52
|
+
* @description Retrieves the configured bearer token for API authentication
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
* @returns Bearer token
|
|
56
|
+
*/
|
|
57
|
+
getBearerToken(): string;
|
|
58
|
+
/**
|
|
59
|
+
* @category Endpoints
|
|
60
|
+
* @summary Gets the base URL for API requests
|
|
61
|
+
* @description Retrieves the configured base URL for API endpoints
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
* @returns API base URL
|
|
65
|
+
*/
|
|
66
|
+
getBaseUrl(): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* @category Networking
|
|
69
|
+
* @summary Gets the request timeout value
|
|
70
|
+
* @description Retrieves the configured timeout value for API requests
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
* @returns Request timeout in milliseconds
|
|
74
|
+
*/
|
|
75
|
+
getTimeout(): number | undefined;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ConfigManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../../src/config/ConfigManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;IAE/B;;;;;OAKG;gBACS,MAAM,EAAE,cAAc;IAIlC;;;;;;OAMG;IACH,SAAS,IAAI,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG;QACjD,cAAc,EAAE,OAAO,CAAC;KACzB;IAQD;;;;;;;OAOG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAOtD;;;;;;;OAOG;IACH,iBAAiB,IAAI,cAAc;IAInC;;;;;;;OAOG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;;;;OAOG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;IAIhC;;;;;;;OAOG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;CAGjC"}
|