paytr.js 0.0.1
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 +306 -0
- package/dist/constants.d.ts +46 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +49 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +455 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +310 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +56 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +148 -0
- package/dist/utils.js.map +1 -0
- package/package.json +42 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PayTR Node.js SDK
|
|
4
|
+
*
|
|
5
|
+
* PayTR ödeme geçidi için modüler Node.js/TypeScript SDK.
|
|
6
|
+
* React, Nuxt, Next.js ve Vue backend'lerinde kullanılabilir.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { PayTR } from 'paytr-node';
|
|
11
|
+
*
|
|
12
|
+
* const paytr = new PayTR({
|
|
13
|
+
* merchantId: 'YOUR_MERCHANT_ID',
|
|
14
|
+
* merchantKey: 'YOUR_MERCHANT_KEY',
|
|
15
|
+
* merchantSalt: 'YOUR_MERCHANT_SALT'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Ödeme formu hazırla
|
|
19
|
+
* const payment = paytr.preparePayment({
|
|
20
|
+
* merchantOid: 'ORDER-123',
|
|
21
|
+
* email: 'customer@example.com',
|
|
22
|
+
* paymentAmount: 100.99,
|
|
23
|
+
* currency: 'TL',
|
|
24
|
+
* basketItems: [{ name: 'Ürün', price: 100.99, quantity: 1 }],
|
|
25
|
+
* user: { name: 'Müşteri Adı', address: 'Adres', phone: '05551234567' },
|
|
26
|
+
* merchantOkUrl: 'https://site.com/basarili',
|
|
27
|
+
* merchantFailUrl: 'https://site.com/hata'
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
35
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(o, k2, desc);
|
|
38
|
+
}) : (function(o, m, k, k2) {
|
|
39
|
+
if (k2 === undefined) k2 = k;
|
|
40
|
+
o[k2] = m[k];
|
|
41
|
+
}));
|
|
42
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
43
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.DEFAULTS = exports.ENDPOINTS = exports.PayTR = void 0;
|
|
47
|
+
const constants_1 = require("./constants");
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
/**
|
|
50
|
+
* PayTR SDK ana sınıfı
|
|
51
|
+
*/
|
|
52
|
+
class PayTR {
|
|
53
|
+
config;
|
|
54
|
+
/**
|
|
55
|
+
* PayTR SDK'yı başlatır
|
|
56
|
+
* @param config - Mağaza yapılandırması
|
|
57
|
+
*/
|
|
58
|
+
constructor(config) {
|
|
59
|
+
this.config = {
|
|
60
|
+
merchantId: config.merchantId,
|
|
61
|
+
merchantKey: config.merchantKey,
|
|
62
|
+
merchantSalt: config.merchantSalt,
|
|
63
|
+
testMode: config.testMode ?? constants_1.DEFAULTS.TEST_MODE,
|
|
64
|
+
language: config.language ?? constants_1.DEFAULTS.LANGUAGE,
|
|
65
|
+
debugMode: config.debugMode ?? constants_1.DEFAULTS.DEBUG_MODE,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// PAYMENT FORM PREPARATION
|
|
70
|
+
// ============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* Direkt ödeme için form verilerini hazırlar
|
|
73
|
+
*
|
|
74
|
+
* @param options - Ödeme parametreleri
|
|
75
|
+
* @returns Form verileri ve token
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const payment = paytr.preparePayment({
|
|
80
|
+
* merchantOid: 'ORDER-123',
|
|
81
|
+
* email: 'customer@example.com',
|
|
82
|
+
* paymentAmount: 100.99,
|
|
83
|
+
* currency: 'TL',
|
|
84
|
+
* basketItems: [{ name: 'Ürün', price: 100.99, quantity: 1 }],
|
|
85
|
+
* user: { name: 'Ad Soyad', address: 'Adres', phone: '05551234567' },
|
|
86
|
+
* merchantOkUrl: 'https://site.com/basarili',
|
|
87
|
+
* merchantFailUrl: 'https://site.com/hata'
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // Frontend'de form oluştur ve gönder
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
preparePayment(options) {
|
|
94
|
+
const userIp = options.userIp ?? '';
|
|
95
|
+
const installmentCount = options.installmentCount ?? constants_1.DEFAULTS.INSTALLMENT_COUNT;
|
|
96
|
+
const non3d = options.non3d ?? constants_1.DEFAULTS.NON_3D;
|
|
97
|
+
const paymentType = constants_1.DEFAULTS.PAYMENT_TYPE;
|
|
98
|
+
const testMode = this.config.testMode;
|
|
99
|
+
const paymentAmount = (0, utils_1.formatAmount)(options.paymentAmount);
|
|
100
|
+
// Token hash string
|
|
101
|
+
const hashStr = [
|
|
102
|
+
this.config.merchantId,
|
|
103
|
+
userIp,
|
|
104
|
+
options.merchantOid,
|
|
105
|
+
options.email,
|
|
106
|
+
paymentAmount,
|
|
107
|
+
paymentType,
|
|
108
|
+
installmentCount.toString(),
|
|
109
|
+
options.currency,
|
|
110
|
+
(0, utils_1.boolToString)(testMode),
|
|
111
|
+
(0, utils_1.boolToString)(non3d),
|
|
112
|
+
].join('');
|
|
113
|
+
const tokenData = hashStr + this.config.merchantSalt;
|
|
114
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
115
|
+
const formData = {
|
|
116
|
+
merchant_id: this.config.merchantId,
|
|
117
|
+
user_ip: userIp,
|
|
118
|
+
merchant_oid: options.merchantOid,
|
|
119
|
+
email: options.email,
|
|
120
|
+
payment_type: paymentType,
|
|
121
|
+
payment_amount: paymentAmount,
|
|
122
|
+
currency: options.currency,
|
|
123
|
+
test_mode: (0, utils_1.boolToString)(testMode),
|
|
124
|
+
non_3d: (0, utils_1.boolToString)(non3d),
|
|
125
|
+
merchant_ok_url: options.merchantOkUrl,
|
|
126
|
+
merchant_fail_url: options.merchantFailUrl,
|
|
127
|
+
user_name: options.user.name,
|
|
128
|
+
user_address: options.user.address,
|
|
129
|
+
user_phone: options.user.phone,
|
|
130
|
+
user_basket: (0, utils_1.formatBasket)(options.basketItems),
|
|
131
|
+
debug_on: (0, utils_1.boolToString)(this.config.debugMode),
|
|
132
|
+
client_lang: this.config.language,
|
|
133
|
+
paytr_token: token,
|
|
134
|
+
installment_count: installmentCount.toString(),
|
|
135
|
+
card_type: options.cardType ?? '',
|
|
136
|
+
non3d_test_failed: (0, utils_1.boolToString)(options.non3dTestFailed ?? false),
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
formAction: constants_1.ENDPOINTS.PAYMENT_FORM,
|
|
140
|
+
formData,
|
|
141
|
+
token,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Kart saklayarak ödeme için form verilerini hazırlar
|
|
146
|
+
*
|
|
147
|
+
* @param options - Ödeme parametreleri (storeCard: true olmalı)
|
|
148
|
+
* @returns Form verileri ve token
|
|
149
|
+
*/
|
|
150
|
+
prepareSaveCardPayment(options) {
|
|
151
|
+
const basePayment = this.preparePayment(options);
|
|
152
|
+
// Kart saklama için ek alanlar
|
|
153
|
+
basePayment.formData.store_card = '1';
|
|
154
|
+
if (options.utoken) {
|
|
155
|
+
basePayment.formData.utoken = options.utoken;
|
|
156
|
+
}
|
|
157
|
+
return basePayment;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Kayıtlı kart ile ödeme için form verilerini hazırlar
|
|
161
|
+
*
|
|
162
|
+
* @param options - Kayıtlı kart ödeme parametreleri
|
|
163
|
+
* @returns Form verileri ve token
|
|
164
|
+
*/
|
|
165
|
+
prepareStoredCardPayment(options) {
|
|
166
|
+
const basePayment = this.preparePayment({
|
|
167
|
+
...options,
|
|
168
|
+
cardType: undefined,
|
|
169
|
+
});
|
|
170
|
+
// Kayıtlı kart için ek alanlar
|
|
171
|
+
basePayment.formData.utoken = options.utoken;
|
|
172
|
+
basePayment.formData.ctoken = options.ctoken;
|
|
173
|
+
if (options.requireCvv !== undefined) {
|
|
174
|
+
basePayment.formData.require_cvv = (0, utils_1.boolToString)(options.requireCvv);
|
|
175
|
+
}
|
|
176
|
+
return basePayment;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Tekrarlı ödeme için form verilerini hazırlar
|
|
180
|
+
*
|
|
181
|
+
* @param options - Tekrarlı ödeme parametreleri
|
|
182
|
+
* @returns Form verileri ve token
|
|
183
|
+
*/
|
|
184
|
+
prepareRecurringPayment(options) {
|
|
185
|
+
const basePayment = this.preparePayment(options);
|
|
186
|
+
// Tekrarlı ödeme için ek alanlar
|
|
187
|
+
basePayment.formData.recurring_payment = '1';
|
|
188
|
+
basePayment.formData.utoken = options.utoken;
|
|
189
|
+
basePayment.formData.ctoken = options.ctoken;
|
|
190
|
+
return basePayment;
|
|
191
|
+
}
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// CALLBACK VERIFICATION
|
|
194
|
+
// ============================================================================
|
|
195
|
+
/**
|
|
196
|
+
* PayTR ödeme bildirimini doğrular
|
|
197
|
+
*
|
|
198
|
+
* @param callback - PayTR'dan gelen callback verisi
|
|
199
|
+
* @returns Doğrulama başarılı mı?
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* // Express/Next.js API route
|
|
204
|
+
* app.post('/api/paytr/callback', (req, res) => {
|
|
205
|
+
* const isValid = paytr.verifyCallback(req.body);
|
|
206
|
+
*
|
|
207
|
+
* if (!isValid) {
|
|
208
|
+
* return res.status(400).send('Invalid hash');
|
|
209
|
+
* }
|
|
210
|
+
*
|
|
211
|
+
* if (req.body.status === 'success') {
|
|
212
|
+
* // Siparişi onayla
|
|
213
|
+
* }
|
|
214
|
+
*
|
|
215
|
+
* res.send('OK');
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
verifyCallback(callback) {
|
|
220
|
+
const tokenData = [
|
|
221
|
+
callback.merchant_oid,
|
|
222
|
+
this.config.merchantSalt,
|
|
223
|
+
callback.status,
|
|
224
|
+
callback.total_amount,
|
|
225
|
+
].join('');
|
|
226
|
+
const expectedHash = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
227
|
+
return expectedHash === callback.hash;
|
|
228
|
+
}
|
|
229
|
+
// ============================================================================
|
|
230
|
+
// BIN QUERY
|
|
231
|
+
// ============================================================================
|
|
232
|
+
/**
|
|
233
|
+
* Kart BIN numarasını sorgular
|
|
234
|
+
*
|
|
235
|
+
* @param binNumber - Kartın ilk 6 veya 8 hanesi
|
|
236
|
+
* @returns BIN sorgu sonucu
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const result = await paytr.queryBIN('979203');
|
|
241
|
+
* if (result.status === 'success') {
|
|
242
|
+
* console.log('Banka:', result.issuer_name);
|
|
243
|
+
* console.log('Kart Tipi:', result.card_type);
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
async queryBIN(binNumber) {
|
|
248
|
+
const tokenData = binNumber + this.config.merchantId + this.config.merchantSalt;
|
|
249
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
250
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.BIN_QUERY, {
|
|
251
|
+
merchant_id: this.config.merchantId,
|
|
252
|
+
bin_number: binNumber,
|
|
253
|
+
paytr_token: token,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
// ============================================================================
|
|
257
|
+
// REFUND
|
|
258
|
+
// ============================================================================
|
|
259
|
+
/**
|
|
260
|
+
* Ödeme iadesi yapar
|
|
261
|
+
*
|
|
262
|
+
* @param merchantOid - Sipariş numarası
|
|
263
|
+
* @param returnAmount - İade tutarı
|
|
264
|
+
* @param referenceNo - Referans numarası (isteğe bağlı)
|
|
265
|
+
* @returns İade sonucu
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const result = await paytr.refund('ORDER-123', 50.00);
|
|
270
|
+
* if (result.status === 'success') {
|
|
271
|
+
* console.log('İade başarılı');
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
async refund(merchantOid, returnAmount, referenceNo) {
|
|
276
|
+
const amountStr = returnAmount.toFixed(2);
|
|
277
|
+
const tokenData = [
|
|
278
|
+
this.config.merchantId,
|
|
279
|
+
merchantOid,
|
|
280
|
+
amountStr,
|
|
281
|
+
this.config.merchantSalt,
|
|
282
|
+
].join('');
|
|
283
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
284
|
+
const formData = {
|
|
285
|
+
merchant_id: this.config.merchantId,
|
|
286
|
+
merchant_oid: merchantOid,
|
|
287
|
+
return_amount: amountStr,
|
|
288
|
+
paytr_token: token,
|
|
289
|
+
};
|
|
290
|
+
if (referenceNo) {
|
|
291
|
+
formData.reference_no = referenceNo;
|
|
292
|
+
}
|
|
293
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.REFUND, formData);
|
|
294
|
+
}
|
|
295
|
+
// ============================================================================
|
|
296
|
+
// TRANSACTION LOG
|
|
297
|
+
// ============================================================================
|
|
298
|
+
/**
|
|
299
|
+
* İşlem dökümünü getirir (max 3 gün aralık)
|
|
300
|
+
*
|
|
301
|
+
* @param startDate - Başlangıç tarihi
|
|
302
|
+
* @param endDate - Bitiş tarihi
|
|
303
|
+
* @returns İşlem dökümü
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const start = new Date('2024-01-01');
|
|
308
|
+
* const end = new Date('2024-01-03');
|
|
309
|
+
* const result = await paytr.getTransactions(start, end);
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
async getTransactions(startDate, endDate) {
|
|
313
|
+
const startStr = (0, utils_1.formatDate)(startDate);
|
|
314
|
+
const endStr = (0, utils_1.formatDate)(endDate);
|
|
315
|
+
const tokenData = [
|
|
316
|
+
this.config.merchantId,
|
|
317
|
+
startStr,
|
|
318
|
+
endStr,
|
|
319
|
+
this.config.merchantSalt,
|
|
320
|
+
].join('');
|
|
321
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
322
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.TRANSACTION_LOG, {
|
|
323
|
+
merchant_id: this.config.merchantId,
|
|
324
|
+
start_date: startStr,
|
|
325
|
+
end_date: endStr,
|
|
326
|
+
paytr_token: token,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// ============================================================================
|
|
330
|
+
// CARD STORAGE
|
|
331
|
+
// ============================================================================
|
|
332
|
+
/**
|
|
333
|
+
* Kullanıcının kayıtlı kartlarını listeler
|
|
334
|
+
*
|
|
335
|
+
* @param utoken - Kullanıcı token'ı
|
|
336
|
+
* @returns Kart listesi
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const result = await paytr.listCards('user-token-xxx');
|
|
341
|
+
* if (result.status === 'success' && result.cards) {
|
|
342
|
+
* result.cards.forEach(card => {
|
|
343
|
+
* console.log(`${card.bank_name} - ****${card.c_last_four}`);
|
|
344
|
+
* });
|
|
345
|
+
* }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
async listCards(utoken) {
|
|
349
|
+
const tokenData = utoken + this.config.merchantSalt;
|
|
350
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
351
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.CARD_LIST, {
|
|
352
|
+
merchant_id: this.config.merchantId,
|
|
353
|
+
utoken: utoken,
|
|
354
|
+
paytr_token: token,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Kayıtlı kartı siler
|
|
359
|
+
*
|
|
360
|
+
* @param utoken - Kullanıcı token'ı
|
|
361
|
+
* @param ctoken - Kart token'ı
|
|
362
|
+
* @returns Silme sonucu
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const result = await paytr.deleteCard('user-token', 'card-token');
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
async deleteCard(utoken, ctoken) {
|
|
370
|
+
const tokenData = ctoken + utoken + this.config.merchantSalt;
|
|
371
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
372
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.CARD_DELETE, {
|
|
373
|
+
merchant_id: this.config.merchantId,
|
|
374
|
+
ctoken: ctoken,
|
|
375
|
+
utoken: utoken,
|
|
376
|
+
paytr_token: token,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
// ============================================================================
|
|
380
|
+
// ORDER STATUS
|
|
381
|
+
// ============================================================================
|
|
382
|
+
/**
|
|
383
|
+
* Sipariş durumunu sorgular
|
|
384
|
+
*
|
|
385
|
+
* @param merchantOid - Sipariş numarası
|
|
386
|
+
* @returns Sipariş durumu
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```typescript
|
|
390
|
+
* const result = await paytr.getOrderStatus('ORDER-123');
|
|
391
|
+
* console.log('Durum:', result.payment_status);
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
async getOrderStatus(merchantOid) {
|
|
395
|
+
const tokenData = [
|
|
396
|
+
this.config.merchantId,
|
|
397
|
+
merchantOid,
|
|
398
|
+
this.config.merchantSalt,
|
|
399
|
+
].join('');
|
|
400
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
401
|
+
return (0, utils_1.apiRequest)(constants_1.ENDPOINTS.ORDER_STATUS, {
|
|
402
|
+
merchant_id: this.config.merchantId,
|
|
403
|
+
merchant_oid: merchantOid,
|
|
404
|
+
paytr_token: token,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
// ============================================================================
|
|
408
|
+
// INSTALLMENT RATES
|
|
409
|
+
// ============================================================================
|
|
410
|
+
/**
|
|
411
|
+
* Taksit oranlarını getirir
|
|
412
|
+
*
|
|
413
|
+
* @returns Taksit oranları
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* const result = await paytr.getInstallmentRates();
|
|
418
|
+
* if (result.status === 'success') {
|
|
419
|
+
* console.log('Taksit oranları:', result.raw);
|
|
420
|
+
* }
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
async getInstallmentRates() {
|
|
424
|
+
const requestId = (0, utils_1.generateRequestId)();
|
|
425
|
+
const tokenData = [
|
|
426
|
+
this.config.merchantId,
|
|
427
|
+
requestId,
|
|
428
|
+
this.config.merchantSalt,
|
|
429
|
+
].join('');
|
|
430
|
+
const token = (0, utils_1.generateToken)(this.config.merchantKey, tokenData);
|
|
431
|
+
const response = await (0, utils_1.apiRequest)(constants_1.ENDPOINTS.INSTALLMENT_RATES, {
|
|
432
|
+
merchant_id: this.config.merchantId,
|
|
433
|
+
request_id: requestId,
|
|
434
|
+
paytr_token: token,
|
|
435
|
+
});
|
|
436
|
+
// API ham veri döndürür, bunu dönüştür
|
|
437
|
+
if (response.status === 'success') {
|
|
438
|
+
return {
|
|
439
|
+
status: 'success',
|
|
440
|
+
raw: response,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
status: 'error',
|
|
445
|
+
err_msg: response.err_msg ?? 'Unknown error',
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
exports.PayTR = PayTR;
|
|
450
|
+
// Export types
|
|
451
|
+
__exportStar(require("./types"), exports);
|
|
452
|
+
var constants_2 = require("./constants");
|
|
453
|
+
Object.defineProperty(exports, "ENDPOINTS", { enumerable: true, get: function () { return constants_2.ENDPOINTS; } });
|
|
454
|
+
Object.defineProperty(exports, "DEFAULTS", { enumerable: true, get: function () { return constants_2.DEFAULTS; } });
|
|
455
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;;;;;;;;;;;;;;;AAEH,2CAAkD;AAClD,mCAQiB;AAmBjB;;GAEG;AACH,MAAa,KAAK;IACC,MAAM,CAAwB;IAE/C;;;OAGG;IACH,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,oBAAQ,CAAC,SAAS;YAC/C,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,oBAAQ,CAAC,QAAQ;YAC9C,SAAS,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