@tapsilat/tapsilat-js 2025.8.19 → 2025.11.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/TapsilatSDK.d.ts +29 -33
- package/dist/TapsilatSDK.d.ts.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/index.d.ts +101 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +51 -51
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -51
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +71 -16
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -332,15 +332,15 @@ import { validateGsmNumber } from "@tapsilat/tapsilat-js";
|
|
|
332
332
|
|
|
333
333
|
const gsmResult = validateGsmNumber('+90 555 123 45 67');
|
|
334
334
|
if (gsmResult.isValid) {
|
|
335
|
-
console.log('Cleaned number:', gsmResult.cleanedNumber); // +
|
|
335
|
+
console.log('Cleaned number:', gsmResult.cleanedNumber); // +90000000000
|
|
336
336
|
} else {
|
|
337
337
|
console.error('Invalid GSM:', gsmResult.error);
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
// Supports multiple formats
|
|
341
|
-
validateGsmNumber('
|
|
342
|
-
validateGsmNumber('
|
|
343
|
-
validateGsmNumber('
|
|
341
|
+
validateGsmNumber('0999 123 45 67'); // National format
|
|
342
|
+
validateGsmNumber('999 123 45 67'); // Local format
|
|
343
|
+
validateGsmNumber('9991234567'); // No formatting
|
|
344
344
|
```
|
|
345
345
|
|
|
346
346
|
#### Installments Validation
|
package/dist/TapsilatSDK.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class TapsilatSDK {
|
|
|
34
34
|
*
|
|
35
35
|
* @param {TapsilatConfig} config - SDK configuration options
|
|
36
36
|
* @param {string} config.bearerToken - API authentication token (required)
|
|
37
|
-
* @param {string} [config.baseURL='https://
|
|
37
|
+
* @param {string} [config.baseURL='https://panel.tapsilat.dev/v1'] - API base URL
|
|
38
38
|
* @param {number} [config.timeout=30000] - Request timeout in milliseconds
|
|
39
39
|
* @param {number} [config.maxRetries=3] - Maximum number of retry attempts
|
|
40
40
|
* @param {number} [config.retryDelay=1000] - Delay between retries in milliseconds
|
|
@@ -48,57 +48,53 @@ export declare class TapsilatSDK {
|
|
|
48
48
|
/**
|
|
49
49
|
* Creates a new order and returns a checkout URL
|
|
50
50
|
*
|
|
51
|
-
* @summary Initiates a new payment order with
|
|
51
|
+
* @summary Initiates a new payment order with comprehensive order details
|
|
52
52
|
* @description
|
|
53
53
|
* Creates a new payment order in the Tapsilat system with the provided order details.
|
|
54
54
|
* This method performs comprehensive validation of all input parameters, creates the order
|
|
55
|
-
* on the payment platform, and returns
|
|
56
|
-
*
|
|
57
|
-
* buyer information for compliance and fraud prevention.
|
|
55
|
+
* on the payment platform, and returns order identifiers including reference_id and order_id.
|
|
56
|
+
* The method supports multiple currencies, locales, payment options, basket items,
|
|
57
|
+
* and comprehensive buyer information for compliance and fraud prevention.
|
|
58
58
|
*
|
|
59
|
-
* The returned
|
|
60
|
-
*
|
|
61
|
-
* returned reference ID through the getOrderStatus method.
|
|
59
|
+
* The returned order_id and reference_id can be used to track order status through
|
|
60
|
+
* the getOrderStatus method.
|
|
62
61
|
*
|
|
63
62
|
* @param {OrderCreateRequest} orderRequest - Complete order information
|
|
64
63
|
* @param {number} orderRequest.amount - Payment amount (must be positive, max 2 decimal places)
|
|
64
|
+
* @param {number} [orderRequest.tax_amount] - Tax amount included in total
|
|
65
65
|
* @param {Currency} orderRequest.currency - Payment currency ('TRY', 'USD', 'EUR', 'GBP')
|
|
66
66
|
* @param {Locale} orderRequest.locale - Display language ('tr' for Turkish, 'en' for English)
|
|
67
|
+
* @param {boolean} [orderRequest.three_d_force] - Force 3D Secure authentication
|
|
68
|
+
* @param {Address} [orderRequest.shipping_address] - Shipping address for delivery
|
|
69
|
+
* @param {BasketItem[]} orderRequest.basket_items - Array of items in the order
|
|
70
|
+
* @param {BillingAddress} orderRequest.billing_address - Billing address with tax information
|
|
67
71
|
* @param {Buyer} orderRequest.buyer - Customer information for payment processing
|
|
68
|
-
* @param {string} orderRequest.
|
|
69
|
-
* @param {
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {string} [orderRequest.
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {
|
|
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
|
|
72
|
+
* @param {string} [orderRequest.conversation_id] - Custom tracking ID for your system
|
|
73
|
+
* @param {boolean} [orderRequest.partial_payment] - Enable partial payment
|
|
74
|
+
* @param {boolean} [orderRequest.payment_methods] - Enable payment method selection
|
|
75
|
+
* @param {PaymentOption[]} [orderRequest.payment_options] - Available payment options
|
|
76
|
+
* @param {string} [orderRequest.payment_success_url] - URL to redirect after successful payment
|
|
77
|
+
* @param {string} [orderRequest.payment_failure_url] - URL to redirect after failed payment
|
|
78
|
+
* @param {number[]} [orderRequest.enabled_installments] - Allowed installment counts
|
|
78
79
|
* @param {Record<string, unknown>} [orderRequest.metadata] - Additional custom data
|
|
79
80
|
*
|
|
80
81
|
* @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
|
|
81
|
-
* @returns {string} OrderCreateResponse.
|
|
82
|
-
* @returns {string} OrderCreateResponse.
|
|
83
|
-
* @returns {string} OrderCreateResponse.
|
|
84
|
-
* @returns {string} OrderCreateResponse.
|
|
85
|
-
* @returns {string} [OrderCreateResponse.
|
|
82
|
+
* @returns {string} OrderCreateResponse.order_id - Internal order identifier
|
|
83
|
+
* @returns {string} OrderCreateResponse.reference_id - Unique order reference for tracking
|
|
84
|
+
* @returns {string} [OrderCreateResponse.checkout_url] - Payment page URL for customer
|
|
85
|
+
* @returns {string} [OrderCreateResponse.conversation_id] - Echo of provided conversation ID
|
|
86
|
+
* @returns {string} [OrderCreateResponse.status] - Initial order status
|
|
87
|
+
* @returns {string} [OrderCreateResponse.qr_code_url] - QR code URL for mobile payments
|
|
86
88
|
*
|
|
87
89
|
* @throws {TapsilatValidationError} When input validation fails:
|
|
88
90
|
* - Amount is not positive or has more than 2 decimal places
|
|
89
91
|
* - Currency is not supported
|
|
90
92
|
* - Buyer information is incomplete or invalid
|
|
91
|
-
* -
|
|
93
|
+
* - Basket items are missing or invalid
|
|
94
|
+
* - Billing address is missing
|
|
92
95
|
* - Required fields are missing
|
|
93
|
-
* @throws {TapsilatNetworkError} When network request fails
|
|
94
|
-
*
|
|
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
|
|
96
|
+
* @throws {TapsilatNetworkError} When network request fails
|
|
97
|
+
* @throws {TapsilatError} When API returns business logic errors
|
|
102
98
|
*/
|
|
103
99
|
createOrder(orderRequest: OrderCreateRequest): Promise<OrderCreateResponse>;
|
|
104
100
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TapsilatSDK.d.ts","sourceRoot":"","sources":["../src/TapsilatSDK.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AASvD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACvB,MAAM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IACzD,MAAM,CAAC,CAAC,GAAG,OAAO,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAQ1B;;;;;;;;;;OAUG;YACW,OAAO;IA4DrB;;;;;;;;;OASG;YACW,WAAW;IA0CzB;;;;;;;OAOG;YACW,eAAe;IAuC7B;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA8D/B;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ;IAoChB;;;;;;;;;OASG;YACW,mBAAmB;IAuCjC;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAStB;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;IAMb;;;;;;OAMG;IACH,eAAe,IAAI,kBAAkB;IAIrC;;;;;;;OAOG;IACH,qBAAqB,CACnB,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,GACtE,MAAM;IAIT;;;;;;;OAOG;IACH,sBAAsB,CACpB,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,GACvE,MAAM;IAIT;;;;;;;OAOG;IACH,mBAAmB,CACjB,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,GACpE,MAAM;CAGV"}
|
package/dist/index.d.ts
CHANGED
|
@@ -94,12 +94,51 @@ interface Customer {
|
|
|
94
94
|
* @interface Address
|
|
95
95
|
*/
|
|
96
96
|
interface Address {
|
|
97
|
-
|
|
97
|
+
address: string;
|
|
98
98
|
city: string;
|
|
99
|
-
|
|
100
|
-
postalCode: string;
|
|
99
|
+
contact_name: string;
|
|
101
100
|
country: string;
|
|
101
|
+
zip_code: string;
|
|
102
|
+
district?: string;
|
|
103
|
+
contact_phone?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @category Customer Data
|
|
107
|
+
* @summary Billing address with tax information
|
|
108
|
+
* @description Extended address structure for billing with tax and company details
|
|
109
|
+
* @interface BillingAddress
|
|
110
|
+
*/
|
|
111
|
+
interface BillingAddress extends Address {
|
|
112
|
+
billing_type: 'PERSONAL' | 'CORPORATE';
|
|
113
|
+
vat_number?: string;
|
|
114
|
+
tax_office?: string;
|
|
115
|
+
title?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @category Order Management
|
|
119
|
+
* @summary Item in the order basket
|
|
120
|
+
* @description Represents a product or service in the order with pricing and categorization
|
|
121
|
+
* @interface BasketItem
|
|
122
|
+
*/
|
|
123
|
+
interface BasketItem {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
category1: string;
|
|
127
|
+
category2?: string;
|
|
128
|
+
item_type: string;
|
|
129
|
+
price: number;
|
|
130
|
+
quantity: number;
|
|
131
|
+
coupon_discount?: number;
|
|
132
|
+
data?: string;
|
|
133
|
+
quantity_unit?: string;
|
|
102
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* @category Payment Processing
|
|
137
|
+
* @summary Available payment options for customers
|
|
138
|
+
* @description Different payment methods that can be enabled for an order
|
|
139
|
+
* @typedef {string} PaymentOption
|
|
140
|
+
*/
|
|
141
|
+
type PaymentOption = 'PAY_WITH_WALLET' | 'PAY_WITH_CARD' | 'PAY_WITH_LOAN' | 'PAY_WITH_CASH' | 'PAY_WITH_BANK';
|
|
103
142
|
/**
|
|
104
143
|
* @category Refunds
|
|
105
144
|
* @summary Information needed to process a refund
|
|
@@ -206,13 +245,19 @@ type Locale = "tr" | "en";
|
|
|
206
245
|
* @interface Buyer
|
|
207
246
|
*/
|
|
208
247
|
interface Buyer {
|
|
248
|
+
id?: string;
|
|
209
249
|
name: string;
|
|
210
250
|
surname: string;
|
|
211
251
|
email: string;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
252
|
+
gsm_number?: string;
|
|
253
|
+
identity_number?: string;
|
|
254
|
+
registration_address?: string;
|
|
255
|
+
city?: string;
|
|
256
|
+
country?: string;
|
|
257
|
+
zip_code?: string;
|
|
258
|
+
ip?: string;
|
|
259
|
+
registration_date?: string;
|
|
260
|
+
last_login_date?: string;
|
|
216
261
|
}
|
|
217
262
|
/**
|
|
218
263
|
* @category Order Management
|
|
@@ -222,12 +267,21 @@ interface Buyer {
|
|
|
222
267
|
*/
|
|
223
268
|
interface OrderCreateRequest {
|
|
224
269
|
amount: number;
|
|
225
|
-
|
|
270
|
+
tax_amount?: number;
|
|
226
271
|
locale: Locale;
|
|
272
|
+
three_d_force?: boolean;
|
|
273
|
+
currency: Currency;
|
|
274
|
+
shipping_address?: Address;
|
|
275
|
+
basket_items: BasketItem[];
|
|
276
|
+
billing_address: BillingAddress;
|
|
227
277
|
buyer: Buyer;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
278
|
+
conversation_id?: string;
|
|
279
|
+
partial_payment?: boolean;
|
|
280
|
+
payment_methods?: boolean;
|
|
281
|
+
payment_options?: PaymentOption[];
|
|
282
|
+
payment_success_url?: string;
|
|
283
|
+
payment_failure_url?: string;
|
|
284
|
+
enabled_installments?: number[];
|
|
231
285
|
metadata?: Record<string, unknown>;
|
|
232
286
|
}
|
|
233
287
|
/**
|
|
@@ -237,11 +291,12 @@ interface OrderCreateRequest {
|
|
|
237
291
|
* @interface OrderCreateResponse
|
|
238
292
|
*/
|
|
239
293
|
interface OrderCreateResponse {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
294
|
+
order_id: string;
|
|
295
|
+
reference_id: string;
|
|
296
|
+
checkout_url?: string;
|
|
297
|
+
conversation_id?: string;
|
|
298
|
+
status?: string;
|
|
299
|
+
qr_code_url?: string;
|
|
245
300
|
}
|
|
246
301
|
/**
|
|
247
302
|
* @category Order Management
|
|
@@ -835,7 +890,7 @@ declare class TapsilatSDK {
|
|
|
835
890
|
*
|
|
836
891
|
* @param {TapsilatConfig} config - SDK configuration options
|
|
837
892
|
* @param {string} config.bearerToken - API authentication token (required)
|
|
838
|
-
* @param {string} [config.baseURL='https://
|
|
893
|
+
* @param {string} [config.baseURL='https://panel.tapsilat.dev/v1'] - API base URL
|
|
839
894
|
* @param {number} [config.timeout=30000] - Request timeout in milliseconds
|
|
840
895
|
* @param {number} [config.maxRetries=3] - Maximum number of retry attempts
|
|
841
896
|
* @param {number} [config.retryDelay=1000] - Delay between retries in milliseconds
|
|
@@ -849,57 +904,53 @@ declare class TapsilatSDK {
|
|
|
849
904
|
/**
|
|
850
905
|
* Creates a new order and returns a checkout URL
|
|
851
906
|
*
|
|
852
|
-
* @summary Initiates a new payment order with
|
|
907
|
+
* @summary Initiates a new payment order with comprehensive order details
|
|
853
908
|
* @description
|
|
854
909
|
* Creates a new payment order in the Tapsilat system with the provided order details.
|
|
855
910
|
* This method performs comprehensive validation of all input parameters, creates the order
|
|
856
|
-
* on the payment platform, and returns
|
|
857
|
-
*
|
|
858
|
-
* buyer information for compliance and fraud prevention.
|
|
911
|
+
* on the payment platform, and returns order identifiers including reference_id and order_id.
|
|
912
|
+
* The method supports multiple currencies, locales, payment options, basket items,
|
|
913
|
+
* and comprehensive buyer information for compliance and fraud prevention.
|
|
859
914
|
*
|
|
860
|
-
* The returned
|
|
861
|
-
*
|
|
862
|
-
* returned reference ID through the getOrderStatus method.
|
|
915
|
+
* The returned order_id and reference_id can be used to track order status through
|
|
916
|
+
* the getOrderStatus method.
|
|
863
917
|
*
|
|
864
918
|
* @param {OrderCreateRequest} orderRequest - Complete order information
|
|
865
919
|
* @param {number} orderRequest.amount - Payment amount (must be positive, max 2 decimal places)
|
|
920
|
+
* @param {number} [orderRequest.tax_amount] - Tax amount included in total
|
|
866
921
|
* @param {Currency} orderRequest.currency - Payment currency ('TRY', 'USD', 'EUR', 'GBP')
|
|
867
922
|
* @param {Locale} orderRequest.locale - Display language ('tr' for Turkish, 'en' for English)
|
|
923
|
+
* @param {boolean} [orderRequest.three_d_force] - Force 3D Secure authentication
|
|
924
|
+
* @param {Address} [orderRequest.shipping_address] - Shipping address for delivery
|
|
925
|
+
* @param {BasketItem[]} orderRequest.basket_items - Array of items in the order
|
|
926
|
+
* @param {BillingAddress} orderRequest.billing_address - Billing address with tax information
|
|
868
927
|
* @param {Buyer} orderRequest.buyer - Customer information for payment processing
|
|
869
|
-
* @param {string} orderRequest.
|
|
870
|
-
* @param {
|
|
871
|
-
* @param {
|
|
872
|
-
* @param {
|
|
873
|
-
* @param {string} [orderRequest.
|
|
874
|
-
* @param {
|
|
875
|
-
* @param {
|
|
876
|
-
* @param {string} [orderRequest.description] - Order description for customer reference
|
|
877
|
-
* @param {string} [orderRequest.callbackUrl] - URL to redirect after payment completion
|
|
878
|
-
* @param {string} [orderRequest.conversationId] - Custom tracking ID for your system
|
|
928
|
+
* @param {string} [orderRequest.conversation_id] - Custom tracking ID for your system
|
|
929
|
+
* @param {boolean} [orderRequest.partial_payment] - Enable partial payment
|
|
930
|
+
* @param {boolean} [orderRequest.payment_methods] - Enable payment method selection
|
|
931
|
+
* @param {PaymentOption[]} [orderRequest.payment_options] - Available payment options
|
|
932
|
+
* @param {string} [orderRequest.payment_success_url] - URL to redirect after successful payment
|
|
933
|
+
* @param {string} [orderRequest.payment_failure_url] - URL to redirect after failed payment
|
|
934
|
+
* @param {number[]} [orderRequest.enabled_installments] - Allowed installment counts
|
|
879
935
|
* @param {Record<string, unknown>} [orderRequest.metadata] - Additional custom data
|
|
880
936
|
*
|
|
881
937
|
* @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
|
|
882
|
-
* @returns {string} OrderCreateResponse.
|
|
883
|
-
* @returns {string} OrderCreateResponse.
|
|
884
|
-
* @returns {string} OrderCreateResponse.
|
|
885
|
-
* @returns {string} OrderCreateResponse.
|
|
886
|
-
* @returns {string} [OrderCreateResponse.
|
|
938
|
+
* @returns {string} OrderCreateResponse.order_id - Internal order identifier
|
|
939
|
+
* @returns {string} OrderCreateResponse.reference_id - Unique order reference for tracking
|
|
940
|
+
* @returns {string} [OrderCreateResponse.checkout_url] - Payment page URL for customer
|
|
941
|
+
* @returns {string} [OrderCreateResponse.conversation_id] - Echo of provided conversation ID
|
|
942
|
+
* @returns {string} [OrderCreateResponse.status] - Initial order status
|
|
943
|
+
* @returns {string} [OrderCreateResponse.qr_code_url] - QR code URL for mobile payments
|
|
887
944
|
*
|
|
888
945
|
* @throws {TapsilatValidationError} When input validation fails:
|
|
889
946
|
* - Amount is not positive or has more than 2 decimal places
|
|
890
947
|
* - Currency is not supported
|
|
891
948
|
* - Buyer information is incomplete or invalid
|
|
892
|
-
* -
|
|
949
|
+
* - Basket items are missing or invalid
|
|
950
|
+
* - Billing address is missing
|
|
893
951
|
* - Required fields are missing
|
|
894
|
-
* @throws {TapsilatNetworkError} When network request fails
|
|
895
|
-
*
|
|
896
|
-
* - DNS resolution failure
|
|
897
|
-
* - Network connectivity issues
|
|
898
|
-
* @throws {TapsilatError} When API returns business logic errors:
|
|
899
|
-
* - Insufficient merchant balance
|
|
900
|
-
* - Currency not enabled for merchant
|
|
901
|
-
* - Buyer blocked due to fraud detection
|
|
902
|
-
* - Rate limiting exceeded
|
|
952
|
+
* @throws {TapsilatNetworkError} When network request fails
|
|
953
|
+
* @throws {TapsilatError} When API returns business logic errors
|
|
903
954
|
*/
|
|
904
955
|
createOrder(orderRequest: OrderCreateRequest): Promise<OrderCreateResponse>;
|
|
905
956
|
/**
|
|
@@ -1444,4 +1495,4 @@ declare function validateGsmNumber(gsmNumber: string | number): GsmValidationRes
|
|
|
1444
1495
|
declare function validateInstallments(installments: string | number | number[]): InstallmentsValidationResult;
|
|
1445
1496
|
|
|
1446
1497
|
export { ConfigManager, TapsilatAuthenticationError, TapsilatError, TapsilatNetworkError, TapsilatRateLimitError, TapsilatSDK, TapsilatValidationError, isValidCurrency, isValidPaymentMethod, isValidUrl, sanitizeMetadata, validateEmail, validateGsmNumber, validateInstallments, validatePaymentRequest };
|
|
1447
|
-
export type { APIError, APIResponse, Address, BasketItemDTO, BasketItemPayerDTO, BillingAddressDTO, Buyer, BuyerDTO, CheckoutDesignDTO, Currency, Customer, GsmValidationResult, InstallmentsValidationResult, Locale, MetadataDTO, Order, OrderCardDTO, OrderCreateDTO, OrderCreateRequest, OrderCreateResponse, OrderPFSubMerchantDTO, OrderPaymentDetail, OrderPaymentTermCreateDTO, OrderPaymentTermUpdateDTO, OrderRefundRequest, OrderRefundResponse, OrderResponse, OrderStatusResponse, OrderTermRefundRequest, OrderTerminateRequest, OrderTerminateResponse, PaginatedResponse, PaginationParams, PaymentMethod, PaymentRequest, PaymentResponse, PaymentStatus, PaymentTermDTO, PaymentTermDeleteRequest, PaymentTermRefundResponse, PaymentTermResponse, PaymentTermTerminateRequest, RefundOrderDTO, RefundRequest, RefundResponse, ShippingAddressDTO, SubOrganizationDTO, SubmerchantDTO, TapsilatConfig, WebhookEvent };
|
|
1498
|
+
export type { APIError, APIResponse, Address, BasketItem, BasketItemDTO, BasketItemPayerDTO, BillingAddress, BillingAddressDTO, Buyer, BuyerDTO, CheckoutDesignDTO, Currency, Customer, GsmValidationResult, InstallmentsValidationResult, Locale, MetadataDTO, Order, OrderCardDTO, OrderCreateDTO, OrderCreateRequest, OrderCreateResponse, OrderPFSubMerchantDTO, OrderPaymentDetail, OrderPaymentTermCreateDTO, OrderPaymentTermUpdateDTO, OrderRefundRequest, OrderRefundResponse, OrderResponse, OrderStatusResponse, OrderTermRefundRequest, OrderTerminateRequest, OrderTerminateResponse, PaginatedResponse, PaginationParams, PaymentMethod, PaymentOption, PaymentRequest, PaymentResponse, PaymentStatus, PaymentTermDTO, PaymentTermDeleteRequest, PaymentTermRefundResponse, PaymentTermResponse, PaymentTermTerminateRequest, RefundOrderDTO, RefundRequest, RefundResponse, ShippingAddressDTO, SubOrganizationDTO, SubmerchantDTO, TapsilatConfig, WebhookEvent };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,EACR,OAAO,EACP,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,EACR,OAAO,EACP,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -258,7 +258,7 @@ class InterceptorManager {
|
|
|
258
258
|
try {
|
|
259
259
|
return await interceptor(error, request);
|
|
260
260
|
}
|
|
261
|
-
catch
|
|
261
|
+
catch {
|
|
262
262
|
// Continue to next interceptor if this one fails
|
|
263
263
|
continue;
|
|
264
264
|
}
|
|
@@ -365,15 +365,10 @@ class HttpClient {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
// Execute error interceptors as last resort
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
catch (finalError) {
|
|
375
|
-
throw finalError;
|
|
376
|
-
}
|
|
368
|
+
return this.interceptors.executeErrorInterceptors(lastError, {
|
|
369
|
+
url: interceptedUrl,
|
|
370
|
+
options: interceptedOptions,
|
|
371
|
+
});
|
|
377
372
|
}
|
|
378
373
|
/**
|
|
379
374
|
* @category HTTP Client Internals
|
|
@@ -434,7 +429,7 @@ class HttpClient {
|
|
|
434
429
|
responseData = await response.text();
|
|
435
430
|
}
|
|
436
431
|
}
|
|
437
|
-
catch
|
|
432
|
+
catch {
|
|
438
433
|
throw new TapsilatError("Failed to parse response body", "PARSE_ERROR");
|
|
439
434
|
}
|
|
440
435
|
// Handle successful responses
|
|
@@ -476,11 +471,12 @@ class HttpClient {
|
|
|
476
471
|
return new TapsilatValidationError(errorMessage || "Invalid request data");
|
|
477
472
|
case 422:
|
|
478
473
|
return new TapsilatValidationError(errorMessage || "Validation failed", this.extractValidationDetails(data));
|
|
479
|
-
case 429:
|
|
474
|
+
case 429: {
|
|
480
475
|
const rateLimitInfo = this.extractRateLimitInfo(response);
|
|
481
476
|
return new TapsilatRateLimitError(errorMessage || "Rate limit exceeded", rateLimitInfo.resetTime
|
|
482
477
|
? Math.floor((rateLimitInfo.resetTime.getTime() - Date.now()) / 1000)
|
|
483
478
|
: undefined);
|
|
479
|
+
}
|
|
484
480
|
case 404:
|
|
485
481
|
return new TapsilatError(errorMessage || "Resource not found", "NOT_FOUND");
|
|
486
482
|
case 500:
|
|
@@ -1393,7 +1389,7 @@ class TapsilatSDK {
|
|
|
1393
1389
|
*
|
|
1394
1390
|
* @param {TapsilatConfig} config - SDK configuration options
|
|
1395
1391
|
* @param {string} config.bearerToken - API authentication token (required)
|
|
1396
|
-
* @param {string} [config.baseURL='https://
|
|
1392
|
+
* @param {string} [config.baseURL='https://panel.tapsilat.dev/v1'] - API base URL
|
|
1397
1393
|
* @param {number} [config.timeout=30000] - Request timeout in milliseconds
|
|
1398
1394
|
* @param {number} [config.maxRetries=3] - Maximum number of retry attempts
|
|
1399
1395
|
* @param {number} [config.retryDelay=1000] - Delay between retries in milliseconds
|
|
@@ -1414,71 +1410,65 @@ class TapsilatSDK {
|
|
|
1414
1410
|
/**
|
|
1415
1411
|
* Creates a new order and returns a checkout URL
|
|
1416
1412
|
*
|
|
1417
|
-
* @summary Initiates a new payment order with
|
|
1413
|
+
* @summary Initiates a new payment order with comprehensive order details
|
|
1418
1414
|
* @description
|
|
1419
1415
|
* Creates a new payment order in the Tapsilat system with the provided order details.
|
|
1420
1416
|
* This method performs comprehensive validation of all input parameters, creates the order
|
|
1421
|
-
* on the payment platform, and returns
|
|
1422
|
-
*
|
|
1423
|
-
* buyer information for compliance and fraud prevention.
|
|
1417
|
+
* on the payment platform, and returns order identifiers including reference_id and order_id.
|
|
1418
|
+
* The method supports multiple currencies, locales, payment options, basket items,
|
|
1419
|
+
* and comprehensive buyer information for compliance and fraud prevention.
|
|
1424
1420
|
*
|
|
1425
|
-
* The returned
|
|
1426
|
-
*
|
|
1427
|
-
* returned reference ID through the getOrderStatus method.
|
|
1421
|
+
* The returned order_id and reference_id can be used to track order status through
|
|
1422
|
+
* the getOrderStatus method.
|
|
1428
1423
|
*
|
|
1429
1424
|
* @param {OrderCreateRequest} orderRequest - Complete order information
|
|
1430
1425
|
* @param {number} orderRequest.amount - Payment amount (must be positive, max 2 decimal places)
|
|
1426
|
+
* @param {number} [orderRequest.tax_amount] - Tax amount included in total
|
|
1431
1427
|
* @param {Currency} orderRequest.currency - Payment currency ('TRY', 'USD', 'EUR', 'GBP')
|
|
1432
1428
|
* @param {Locale} orderRequest.locale - Display language ('tr' for Turkish, 'en' for English)
|
|
1429
|
+
* @param {boolean} [orderRequest.three_d_force] - Force 3D Secure authentication
|
|
1430
|
+
* @param {Address} [orderRequest.shipping_address] - Shipping address for delivery
|
|
1431
|
+
* @param {BasketItem[]} orderRequest.basket_items - Array of items in the order
|
|
1432
|
+
* @param {BillingAddress} orderRequest.billing_address - Billing address with tax information
|
|
1433
1433
|
* @param {Buyer} orderRequest.buyer - Customer information for payment processing
|
|
1434
|
-
* @param {string} orderRequest.
|
|
1435
|
-
* @param {
|
|
1436
|
-
* @param {
|
|
1437
|
-
* @param {
|
|
1438
|
-
* @param {string} [orderRequest.
|
|
1439
|
-
* @param {
|
|
1440
|
-
* @param {
|
|
1441
|
-
* @param {string} [orderRequest.description] - Order description for customer reference
|
|
1442
|
-
* @param {string} [orderRequest.callbackUrl] - URL to redirect after payment completion
|
|
1443
|
-
* @param {string} [orderRequest.conversationId] - Custom tracking ID for your system
|
|
1434
|
+
* @param {string} [orderRequest.conversation_id] - Custom tracking ID for your system
|
|
1435
|
+
* @param {boolean} [orderRequest.partial_payment] - Enable partial payment
|
|
1436
|
+
* @param {boolean} [orderRequest.payment_methods] - Enable payment method selection
|
|
1437
|
+
* @param {PaymentOption[]} [orderRequest.payment_options] - Available payment options
|
|
1438
|
+
* @param {string} [orderRequest.payment_success_url] - URL to redirect after successful payment
|
|
1439
|
+
* @param {string} [orderRequest.payment_failure_url] - URL to redirect after failed payment
|
|
1440
|
+
* @param {number[]} [orderRequest.enabled_installments] - Allowed installment counts
|
|
1444
1441
|
* @param {Record<string, unknown>} [orderRequest.metadata] - Additional custom data
|
|
1445
1442
|
*
|
|
1446
1443
|
* @returns {Promise<OrderCreateResponse>} Promise resolving to order creation response
|
|
1447
|
-
* @returns {string} OrderCreateResponse.
|
|
1448
|
-
* @returns {string} OrderCreateResponse.
|
|
1449
|
-
* @returns {string} OrderCreateResponse.
|
|
1450
|
-
* @returns {string} OrderCreateResponse.
|
|
1451
|
-
* @returns {string} [OrderCreateResponse.
|
|
1444
|
+
* @returns {string} OrderCreateResponse.order_id - Internal order identifier
|
|
1445
|
+
* @returns {string} OrderCreateResponse.reference_id - Unique order reference for tracking
|
|
1446
|
+
* @returns {string} [OrderCreateResponse.checkout_url] - Payment page URL for customer
|
|
1447
|
+
* @returns {string} [OrderCreateResponse.conversation_id] - Echo of provided conversation ID
|
|
1448
|
+
* @returns {string} [OrderCreateResponse.status] - Initial order status
|
|
1449
|
+
* @returns {string} [OrderCreateResponse.qr_code_url] - QR code URL for mobile payments
|
|
1452
1450
|
*
|
|
1453
1451
|
* @throws {TapsilatValidationError} When input validation fails:
|
|
1454
1452
|
* - Amount is not positive or has more than 2 decimal places
|
|
1455
1453
|
* - Currency is not supported
|
|
1456
1454
|
* - Buyer information is incomplete or invalid
|
|
1457
|
-
* -
|
|
1455
|
+
* - Basket items are missing or invalid
|
|
1456
|
+
* - Billing address is missing
|
|
1458
1457
|
* - Required fields are missing
|
|
1459
|
-
* @throws {TapsilatNetworkError} When network request fails
|
|
1460
|
-
*
|
|
1461
|
-
* - DNS resolution failure
|
|
1462
|
-
* - Network connectivity issues
|
|
1463
|
-
* @throws {TapsilatError} When API returns business logic errors:
|
|
1464
|
-
* - Insufficient merchant balance
|
|
1465
|
-
* - Currency not enabled for merchant
|
|
1466
|
-
* - Buyer blocked due to fraud detection
|
|
1467
|
-
* - Rate limiting exceeded
|
|
1458
|
+
* @throws {TapsilatNetworkError} When network request fails
|
|
1459
|
+
* @throws {TapsilatError} When API returns business logic errors
|
|
1468
1460
|
*/
|
|
1469
1461
|
async createOrder(orderRequest) {
|
|
1470
|
-
// Validate the order request
|
|
1471
|
-
// Check if request is null/undefined
|
|
1462
|
+
// Validate the order request
|
|
1472
1463
|
if (!orderRequest) {
|
|
1473
1464
|
throw new TapsilatValidationError("Order request cannot be null or undefined");
|
|
1474
1465
|
}
|
|
1475
|
-
// Validate amount
|
|
1466
|
+
// Validate amount
|
|
1476
1467
|
if (!isPositiveNumber(orderRequest.amount)) {
|
|
1477
1468
|
throw new TapsilatValidationError("Amount must be a positive number", {
|
|
1478
1469
|
provided: orderRequest.amount,
|
|
1479
1470
|
});
|
|
1480
1471
|
}
|
|
1481
|
-
// Validate amount - check decimal places
|
|
1482
1472
|
if (!hasValidDecimalPlaces(orderRequest.amount)) {
|
|
1483
1473
|
throw new TapsilatValidationError("Amount must have maximum 2 decimal places", { provided: orderRequest.amount });
|
|
1484
1474
|
}
|
|
@@ -1486,6 +1476,10 @@ class TapsilatSDK {
|
|
|
1486
1476
|
if (!isNonEmptyString(orderRequest.currency)) {
|
|
1487
1477
|
throw new TapsilatValidationError("Currency is required and must be a non-empty string", { provided: orderRequest.currency });
|
|
1488
1478
|
}
|
|
1479
|
+
// Validate locale
|
|
1480
|
+
if (!isNonEmptyString(orderRequest.locale)) {
|
|
1481
|
+
throw new TapsilatValidationError("Locale is required and must be a non-empty string", { provided: orderRequest.locale });
|
|
1482
|
+
}
|
|
1489
1483
|
// Validate buyer information
|
|
1490
1484
|
if (!orderRequest.buyer) {
|
|
1491
1485
|
throw new TapsilatValidationError("Buyer information is required");
|
|
@@ -1497,14 +1491,20 @@ class TapsilatSDK {
|
|
|
1497
1491
|
if (!isNonEmptyString(buyer.surname)) {
|
|
1498
1492
|
throw new TapsilatValidationError("Buyer surname is required and must be a non-empty string", { provided: buyer.surname });
|
|
1499
1493
|
}
|
|
1500
|
-
// Validate buyer email - check if provided
|
|
1501
1494
|
if (!isNonEmptyString(buyer.email)) {
|
|
1502
1495
|
throw new TapsilatValidationError("Buyer email is required and must be a non-empty string", { provided: buyer.email });
|
|
1503
1496
|
}
|
|
1504
|
-
// Validate buyer email - check format
|
|
1505
1497
|
if (!isValidEmail(buyer.email)) {
|
|
1506
1498
|
throw new TapsilatValidationError("Buyer email must be a valid email address", { provided: buyer.email });
|
|
1507
1499
|
}
|
|
1500
|
+
// Validate basket items
|
|
1501
|
+
if (!orderRequest.basket_items || !Array.isArray(orderRequest.basket_items) || orderRequest.basket_items.length === 0) {
|
|
1502
|
+
throw new TapsilatValidationError("Basket items are required and must be a non-empty array");
|
|
1503
|
+
}
|
|
1504
|
+
// Validate billing address
|
|
1505
|
+
if (!orderRequest.billing_address) {
|
|
1506
|
+
throw new TapsilatValidationError("Billing address is required");
|
|
1507
|
+
}
|
|
1508
1508
|
try {
|
|
1509
1509
|
// Make the API request
|
|
1510
1510
|
const createOrderResponse = await this.httpClient.post("/order/create", orderRequest);
|