-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
492 lines (423 loc) · 13.9 KB
/
test.js
File metadata and controls
492 lines (423 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
/**
* QuickPos Payment Gateway Test Suite
*
* Bu dosya tüm ödeme sağlayıcılarının temel fonksiyonlarını test eder.
* Not: Gerçek testler için her provider'ın sandbox/test API anahtarları gereklidir.
*/
const QuickPos = require('./app');
// Test konfigürasyonu
const testConfig = {
providers: {
// Midtrans Test
midtrans: {
serverKey: 'SB-Mid-server-YOUR_SERVER_KEY',
clientKey: 'SB-Mid-client-YOUR_CLIENT_KEY',
isProduction: false
},
// Plisio Test
plisio: {
apiKey: 'your-test-api-key'
},
// Tripay Test
tripay: {
apiKey: 'your-test-api-key',
privateKey: 'your-test-private-key',
merchantCode: 'T1234',
isProduction: false
},
// ToyyibPay Test
toyyibpay: {
secretKey: 'your-test-secret-key',
categoryCode: 'your-test-category-code'
},
// Zarinpal Test
zarinpal: {
merchantId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
sandbox: true
},
// CoinPayments Test
coinpayments: {
publicKey: 'your-test-public-key',
privateKey: 'your-test-private-key',
ipnSecret: 'your-test-ipn-secret'
},
// Checkout.com Test
checkout: {
secretKey: 'sk_test_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
publicKey: 'pk_test_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
sandbox: true
},
// Paytm Test
paytm: {
merchantId: 'YOUR_MERCHANT_ID',
merchantKey: 'YOUR_MERCHANT_KEY',
websiteName: 'WEBSTAGING',
sandbox: true
},
// Cardcom Test
cardcom: {
terminalNumber: 'your-terminal-number',
userName: 'your-username'
},
// Paycom Test
paycom: {
merchantId: 'your-merchant-id',
secretKey: 'your-secret-key'
},
// PayID19 Test
payid19: {
apiKey: 'your-test-api-key',
secretKey: 'your-test-secret-key'
},
// Paysend Test
paysend: {
apiKey: 'your-test-api-key',
sandbox: true
},
// Volet Test
volet: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// BitPay Test
bitpay: {
apiToken: 'YOUR_TEST_API_TOKEN',
environment: 'test'
},
// Payriff Test
payriff: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// Epoint Test
epoint: {
merchantId: 'YOUR_MERCHANT_ID',
privateKey: 'YOUR_PRIVATE_KEY'
},
// Payoneer Test
payoneer: {
programId: 'YOUR_PROGRAM_ID',
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
sandbox: true
},
// PortWallet Test
portwallet: {
apiKey: 'YOUR_API_KEY',
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// 2Checkout Test
'2checkout': {
merchantCode: 'YOUR_MERCHANT_CODE',
secretKey: 'YOUR_SECRET_KEY',
sandbox: true
},
// CoinGate Test
coingate: {
apiKey: 'YOUR_API_KEY',
environment: 'sandbox'
},
// ShurjoPay Test
shurjopay: {
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
prefix: 'YOUR_PREFIX',
sandbox: true
},
// Cashfree Test
cashfree: {
appId: 'YOUR_APP_ID',
secretKey: 'YOUR_SECRET_KEY',
environment: 'sandbox'
},
// PaySpace Test
payspace: {
merchantId: 'YOUR_MERCHANT_ID',
apiKey: 'YOUR_API_KEY'
},
// PayU Latam Test
payulatam: {
apiKey: 'YOUR_API_KEY',
apiLogin: 'YOUR_API_LOGIN',
merchantId: 'YOUR_MERCHANT_ID',
accountId: 'YOUR_ACCOUNT_ID',
sandbox: true
},
// PayU India Test
payuindia: {
merchantKey: 'YOUR_MERCHANT_KEY',
salt: 'YOUR_SALT',
sandbox: true
},
// ePay Test
epay: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// PayNet Test
paynet: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// PayNetTR Test
paynettr: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// Doku Test
doku: {
clientId: 'YOUR_CLIENT_ID',
secretKey: 'YOUR_SECRET_KEY',
sharedKey: 'YOUR_SHARED_KEY',
sandbox: true
},
// Coinbase Commerce Test
coinbase: {
apiKey: 'YOUR_API_KEY',
webhookSecret: 'YOUR_WEBHOOK_SECRET'
},
// Amazon Pay Test
amazonpay: {
merchantId: 'YOUR_MERCHANT_ID',
accessKey: 'YOUR_ACCESS_KEY',
secretKey: 'YOUR_SECRET_KEY',
region: 'us',
sandbox: true
},
// Perfect Money Test
perfectmoney: {
accountId: 'YOUR_ACCOUNT_ID',
passPhrase: 'YOUR_PASSPHRASE',
alternatePassPhrase: 'YOUR_ALTERNATE_PASSPHRASE'
},
// Paddle Test
paddle: {
vendorId: 'YOUR_VENDOR_ID',
apiKey: 'YOUR_API_KEY',
publicKey: 'YOUR_PUBLIC_KEY',
sandbox: true
},
// Instamojo Test
instamojo: {
apiKey: 'YOUR_API_KEY',
authToken: 'YOUR_AUTH_TOKEN',
sandbox: true
},
// FreeKassa Test
freekassa: {
shopId: 'YOUR_SHOP_ID',
secretKey1: 'YOUR_SECRET_KEY_1',
secretKey2: 'YOUR_SECRET_KEY_2'
},
// PicPay Test
picpay: {
token: 'YOUR_TOKEN',
sellerToken: 'YOUR_SELLER_TOKEN'
},
// PayTabs Test
paytabs: {
profileId: 'YOUR_PROFILE_ID',
serverKey: 'YOUR_SERVER_KEY',
region: 'ARE'
},
// Payssion Test
payssion: {
apiKey: 'YOUR_API_KEY',
secretKey: 'YOUR_SECRET_KEY',
sandbox: true
},
// PayKun Test
paykun: {
merchantId: 'YOUR_MERCHANT_ID',
accessToken: 'YOUR_ACCESS_TOKEN',
encryptionKey: 'YOUR_ENCRYPTION_KEY',
sandbox: true
},
// Omise Test
omise: {
publicKey: 'YOUR_PUBLIC_KEY',
secretKey: 'YOUR_SECRET_KEY'
},
// PhonePe Test
phonepe: {
merchantId: 'YOUR_MERCHANT_ID',
saltKey: 'YOUR_SALT_KEY',
saltIndex: 1,
sandbox: true
},
// YouCanPay Test
youcanpay: {
privateKey: 'YOUR_PRIVATE_KEY',
publicKey: 'YOUR_PUBLIC_KEY',
sandbox: true
},
// YooKassa Test
yookassa: {
shopId: 'YOUR_SHOP_ID',
secretKey: 'YOUR_SECRET_KEY'
},
// URWay Test
urway: {
terminalId: 'YOUR_TERMINAL_ID',
password: 'YOUR_PASSWORD',
merchantKey: 'YOUR_MERCHANT_KEY',
testMode: true
},
// Xendit Test
xendit: {
apiKey: 'YOUR_API_KEY',
webhookToken: 'YOUR_WEBHOOK_TOKEN'
},
// Unitpay Test
unitpay: {
publicKey: 'YOUR_PUBLIC_KEY',
secretKey: 'YOUR_SECRET_KEY'
},
// SenangPay Test
senangpay: {
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY',
sandbox: true
},
// Razorpay Test
razorpay: {
keyId: 'YOUR_KEY_ID',
keySecret: 'YOUR_KEY_SECRET'
}
}
};
// Test fonksiyonu
async function testProvider(providerName, provider) {
console.log(`\n🧪 Testing ${providerName}...`);
console.log('─'.repeat(50));
try {
// Test createPayment
console.log('✓ Module loaded successfully');
console.log('✓ createPayment method exists:', typeof provider.createPayment === 'function');
console.log('✓ handleCallback method exists:', typeof provider.handleCallback === 'function');
// Her provider için özel test verileri
const testData = getTestDataForProvider(providerName);
console.log(`\n📝 Test payment data prepared for ${providerName}`);
console.log(' Amount:', testData.amount);
console.log(' Currency:', testData.currency || 'Default');
// Not: Gerçek API çağrıları için geçerli credentials gerekli
// console.log('\n⚠️ Skipping actual API call (requires valid credentials)');
return {
provider: providerName,
status: 'passed',
methods: {
createPayment: typeof provider.createPayment === 'function',
handleCallback: typeof provider.handleCallback === 'function'
}
};
} catch (error) {
console.error(`❌ Error testing ${providerName}:`, error.message);
return {
provider: providerName,
status: 'failed',
error: error.message
};
}
}
// Provider'a özel test verileri
function getTestDataForProvider(providerName) {
const baseData = {
amount: '100',
email: 'test@example.com',
name: 'Test User',
phone: '+1234567890',
orderId: `TEST-${Date.now()}`,
callback_link: 'http://localhost:3000/callback'
};
const providerSpecific = {
midtrans: { currency: 'IDR', amount: '10000' },
plisio: { currency: 'USD', amount: '10' },
tripay: { currency: 'IDR', amount: '10000', paymentMethod: 'BRIVA' },
toyyibpay: { currency: 'MYR', amount: '10' },
zarinpal: { currency: 'IRT', amount: '1000', mobile: '09123456789' },
coinpayments: { currency1: 'USD', currency2: 'BTC', amount: '10' },
checkout: { currency: 'USD', amount: '10', useHostedPage: true },
paytm: { currency: 'INR', amount: '100', mobile: '9876543210' },
cardcom: { currency: 'ILS', amount: '100', mobile: '0501234567' },
paycom: { currency: 'UZS', amount: '10000' },
payid19: { currency: 'IDR', amount: '10000', paymentMethod: 'all' },
paysend: { currency: 'USD', amount: '10', cardNumber: '4111111111111111' },
volet: { currency: 'USD', amount: '10' },
bitpay: { currency: 'USD', amount: '10' },
payriff: { currency: 'AZN', amount: '50' },
epoint: { currency: 'AZN', amount: '100' },
payoneer: { currency: 'USD', amount: '100', payeeId: 'test@example.com' },
portwallet: { currency: 'USD', amount: '100' },
'2checkout': { currency: 'USD', amount: '100', customerName: 'Test User' },
coingate: { currency: 'USD', amount: '10', receiveCurrency: 'EUR' },
shurjopay: { currency: 'BDT', amount: '1000', city: 'Dhaka' },
cashfree: { currency: 'INR', amount: '1000', customerId: 'customer_test' },
payspace: { currency: 'ZAR', amount: '100' },
payulatam: { currency: 'COP', amount: '10000', country: 'CO', paymentMethod: 'VISA' },
payuindia: { currency: 'INR', amount: '1000', productInfo: 'Test Product', firstname: 'John' },
epay: { currency: 'BGN', amount: '100' },
paynet: { currency: 'MDL', amount: '100' },
paynettr: { currency: 'TRY', amount: '100' },
doku: { currency: 'IDR', amount: '50000' },
coinbase: { currency: 'USD', amount: '10', pricingType: 'fixed_price' },
amazonpay: { currency: 'USD', amount: '10', chargePermissionType: 'OneTime' },
perfectmoney: { currency: 'USD', amount: '10' },
paddle: { currency: 'USD', amount: '10', title: 'Test Product' },
instamojo: { currency: 'INR', amount: '1000', purpose: 'Test Payment' },
freekassa: { currency: 'RUB', amount: '1000' },
picpay: { currency: 'BRL', amount: '10.50', firstName: 'John', lastName: 'Doe' },
paytabs: { currency: 'AED', amount: '100', country: 'AE' },
payssion: { currency: 'USD', amount: '50', paymentMethod: 'boleto_br' },
paykun: { currency: 'INR', amount: '1000' },
omise: { currency: 'THB', amount: '1000', sourceType: 'promptpay' },
phonepe: { currency: 'INR', amount: '100', userId: 'USER123' },
youcanpay: { currency: 'MAD', amount: '100' },
yookassa: { currency: 'RUB', amount: '1000' },
urway: { currency: 'SAR', amount: '100', country: 'SA', merchantIp: '1.1.1.1' },
xendit: { currency: 'IDR', amount: '100000', paymentMethod: 'invoice' },
unitpay: { currency: 'RUB', amount: '500', account: 'TEST-001' },
senangpay: { currency: 'MYR', amount: '50.00' },
razorpay: { currency: 'INR', amount: '500', merchantName: 'Test Business' }
};
return { ...baseData, ...providerSpecific[providerName] };
}
// Ana test fonksiyonu
async function runTests() {
console.log('╔════════════════════════════════════════════════╗');
console.log('║ QuickPos Payment Gateway Test Suite ║');
console.log('╚════════════════════════════════════════════════╝\n');
const quickPos = new QuickPos(testConfig);
const results = [];
// Her provider'ı test et
for (const [providerName, provider] of Object.entries(quickPos.providers)) {
const result = await testProvider(providerName, provider);
results.push(result);
}
// Sonuçları göster
console.log('\n\n╔════════════════════════════════════════════════╗');
console.log('║ Test Results Summary ║');
console.log('╚════════════════════════════════════════════════╝\n');
const passed = results.filter(r => r.status === 'passed').length;
const failed = results.filter(r => r.status === 'failed').length;
results.forEach(result => {
const icon = result.status === 'passed' ? '✅' : '❌';
console.log(`${icon} ${result.provider.padEnd(20)} - ${result.status.toUpperCase()}`);
if (result.error) {
console.log(` Error: ${result.error}`);
}
});
console.log('\n' + '─'.repeat(50));
console.log(`Total: ${results.length} | Passed: ${passed} | Failed: ${failed}`);
console.log('─'.repeat(50));
console.log('\n📋 Notes:');
console.log(' • All providers loaded successfully');
console.log(' • createPayment and handleCallback methods verified');
console.log(' • For actual payment testing, configure valid API credentials');
console.log(' • Refer to example files for provider-specific usage\n');
}
// Testleri çalıştır
if (require.main === module) {
runTests().catch(console.error);
}
module.exports = { runTests, testProvider };