quickpos 1.0.910 → 1.0.912
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/PROVIDERS-DETAILS.md +1544 -0
- package/examples/example-2checkout.js +78 -0
- package/examples/example-bitpay.js +83 -0
- package/examples/example-cardcom.js +80 -0
- package/examples/example-cashfree.js +109 -0
- package/examples/example-checkout.js +85 -0
- package/examples/example-coingate.js +101 -0
- package/examples/example-coinpayments.js +89 -0
- package/examples/example-doku.js +27 -0
- package/examples/example-epay.js +64 -0
- package/examples/example-epoint.js +91 -0
- package/examples/example-freekassa.js +26 -0
- package/examples/example-heleket.js +139 -0
- package/examples/example-konnect.js +227 -0
- package/examples/example-midtrans.js +80 -0
- package/examples/example-noonpayments.js +297 -0
- package/examples/example-nowpayments.js +289 -0
- package/examples/example-omise.js +27 -0
- package/examples/example-paycom.js +82 -0
- package/{example-paydisini.js → examples/example-paydisini.js} +1 -1
- package/examples/example-payid19.js +87 -0
- package/examples/example-paykun.js +29 -0
- package/examples/example-payme.js +202 -0
- package/examples/example-paymentwall.js +201 -0
- package/examples/example-paynet.js +104 -0
- package/examples/example-paynettr.js +18 -0
- package/examples/example-payoneer.js +74 -0
- package/examples/example-payop.js +351 -0
- package/examples/example-paypal.js +200 -0
- package/examples/example-payriff.js +89 -0
- package/examples/example-paysend.js +81 -0
- package/examples/example-payspace.js +103 -0
- package/examples/example-payssion.js +27 -0
- package/examples/example-paytabs.js +28 -0
- package/examples/example-paytm.js +78 -0
- package/examples/example-payuindia.js +108 -0
- package/examples/example-payulatam.js +75 -0
- package/examples/example-phonepe.js +27 -0
- package/examples/example-picpay.js +27 -0
- package/examples/example-plisio.js +84 -0
- package/examples/example-portwallet.js +90 -0
- package/examples/example-primepayments.js +250 -0
- package/examples/example-razorpay.js +30 -0
- package/examples/example-senangpay.js +28 -0
- package/examples/example-shurjopay.js +94 -0
- package/examples/example-toyyibpay.js +80 -0
- package/examples/example-tripay.js +89 -0
- package/examples/example-unitpay.js +26 -0
- package/examples/example-urway.js +28 -0
- package/examples/example-volet.js +80 -0
- package/examples/example-xendit.js +28 -0
- package/examples/example-yallapay.js +253 -0
- package/examples/example-yookassa.js +27 -0
- package/examples/example-youcanpay.js +28 -0
- package/examples/example-zarinpal.js +98 -0
- package/{example.js → examples/example.js} +1 -1
- package/lib/2checkout.js +165 -0
- package/lib/amazonpay.js +161 -0
- package/lib/bitpay.js +122 -0
- package/lib/cardcom.js +193 -0
- package/lib/cashfree.js +184 -0
- package/lib/checkout.js +248 -0
- package/lib/coinbase.js +150 -0
- package/lib/coingate.js +137 -0
- package/lib/coinpayments.js +245 -0
- package/lib/doku.js +173 -0
- package/lib/epay.js +175 -0
- package/lib/epoint.js +162 -0
- package/lib/freekassa.js +128 -0
- package/lib/heleket.js +67 -1
- package/lib/instamojo.js +158 -0
- package/lib/konnect.js +211 -0
- package/lib/midtrans.js +227 -0
- package/lib/noonpayments.js +650 -0
- package/lib/nowpayments.js +311 -0
- package/lib/omise.js +150 -0
- package/lib/paddle.js +180 -0
- package/lib/paycom.js +216 -0
- package/lib/payid19.js +211 -0
- package/lib/paykun.js +144 -0
- package/lib/payme.js +302 -0
- package/lib/paymentwall.js +205 -0
- package/lib/paynet.js +186 -0
- package/lib/paynettr.js +165 -0
- package/lib/payoneer.js +128 -0
- package/lib/payop.js +256 -0
- package/lib/paypal.js +542 -0
- package/lib/payriff.js +148 -0
- package/lib/paysend.js +189 -0
- package/lib/payspace.js +168 -0
- package/lib/payssion.js +177 -0
- package/lib/paytabs.js +145 -0
- package/lib/paytm.js +253 -0
- package/lib/payuindia.js +162 -0
- package/lib/payulatam.js +179 -0
- package/lib/perfectmoney.js +143 -0
- package/lib/phonepe.js +174 -0
- package/lib/picpay.js +119 -0
- package/lib/plisio.js +234 -0
- package/lib/portwallet.js +152 -0
- package/lib/primepayments.js +256 -0
- package/lib/razorpay.js +205 -0
- package/lib/senangpay.js +130 -0
- package/lib/shurjopay.js +159 -0
- package/lib/toyyibpay.js +151 -0
- package/lib/tripay.js +220 -0
- package/lib/unitpay.js +223 -0
- package/lib/urway.js +182 -0
- package/lib/volet.js +147 -0
- package/lib/xendit.js +206 -0
- package/lib/yallapay.js +279 -0
- package/lib/yookassa.js +193 -0
- package/lib/youcanpay.js +124 -0
- package/lib/zarinpal.js +157 -0
- package/package.json +138 -64
- package/readme.md +348 -105
- package/test.js +492 -0
- package/example-heleket.js +0 -83
- package/lib/vallet.js +0 -22
- /package/{example-anypay.js → examples/example-anypay.js} +0 -0
- /package/{example-bufpay.js → examples/example-bufpay.js} +0 -0
- /package/{example-cryptomus.js → examples/example-cryptomus.js} +0 -0
- /package/{example-esnekpos.js → examples/example-esnekpos.js} +0 -0
- /package/{example-fedapay.js → examples/example-fedapay.js} +0 -0
- /package/{example-iyzico.js → examples/example-iyzico.js} +0 -0
- /package/{example-papara.js → examples/example-papara.js} +0 -0
- /package/{example-payeer.js → examples/example-payeer.js} +0 -0
- /package/{example-paymaya.js → examples/example-paymaya.js} +0 -0
- /package/{example-shopier.js → examples/example-shopier.js} +0 -0
- /package/{ipaymu.js → examples/ipaymu.js} +0 -0
- /package/{oderopay.js → examples/oderopay.js} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const EpayClient = require('../lib/epay');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// ePay yapılandırması
|
|
10
|
+
const epayClient = new EpayClient({
|
|
11
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
12
|
+
secretKey: 'YOUR_SECRET_KEY'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ödeme oluşturma
|
|
16
|
+
app.get('/create-payment', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const payment = await epayClient.createPayment({
|
|
19
|
+
amount: 100.00,
|
|
20
|
+
orderId: `ORDER-${Date.now()}`,
|
|
21
|
+
name: 'Test Product',
|
|
22
|
+
description: 'Тестово плащане',
|
|
23
|
+
expirationTime: epayClient.getExpirationTime(24) // 24 saat
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
console.log('Payment created:', payment);
|
|
27
|
+
|
|
28
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
29
|
+
res.redirect(payment.data.url);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('Error:', error.message);
|
|
32
|
+
res.status(500).json({ error: error.message });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Callback endpoint
|
|
37
|
+
app.post('/callback', async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
console.log('Callback received:', req.body);
|
|
40
|
+
|
|
41
|
+
const result = await epayClient.handleCallback(req.body);
|
|
42
|
+
|
|
43
|
+
console.log('Payment result:', result);
|
|
44
|
+
|
|
45
|
+
if (result.status === 'success') {
|
|
46
|
+
// Ödeme başarılı
|
|
47
|
+
console.log('Плащането е успешно!');
|
|
48
|
+
console.log('Order ID:', result.orderId);
|
|
49
|
+
console.log('Transaction ID:', result.transactionId);
|
|
50
|
+
console.log('Amount:', result.amount, result.currency);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
res.status(200).send('OK');
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Callback error:', error.message);
|
|
56
|
+
res.status(400).send('ERROR');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const PORT = 3000;
|
|
61
|
+
app.listen(PORT, () => {
|
|
62
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
63
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
64
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const EpointClient = require('../lib/epoint');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// Epoint yapılandırması
|
|
10
|
+
const epointClient = new EpointClient({
|
|
11
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
12
|
+
privateKey: 'YOUR_PRIVATE_KEY'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ödeme oluşturma
|
|
16
|
+
app.get('/create-payment', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const payment = await epointClient.createPayment({
|
|
19
|
+
amount: 100.00,
|
|
20
|
+
currency: 'AZN',
|
|
21
|
+
orderId: `ORDER-${Date.now()}`,
|
|
22
|
+
name: 'Test Product',
|
|
23
|
+
description: 'Test payment description',
|
|
24
|
+
language: 'az',
|
|
25
|
+
email: 'customer@example.com',
|
|
26
|
+
phone: '+994501234567',
|
|
27
|
+
callback_link: 'http://localhost:3000/callback',
|
|
28
|
+
successUrl: 'http://localhost:3000/success',
|
|
29
|
+
failUrl: 'http://localhost:3000/fail',
|
|
30
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log('Payment created:', payment);
|
|
34
|
+
|
|
35
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
36
|
+
res.redirect(payment.data.url);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('Error:', error.message);
|
|
39
|
+
res.status(500).json({ error: error.message });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Callback endpoint
|
|
44
|
+
app.post('/callback', async (req, res) => {
|
|
45
|
+
try {
|
|
46
|
+
console.log('Callback received:', req.body);
|
|
47
|
+
|
|
48
|
+
const result = await epointClient.handleCallback(req.body);
|
|
49
|
+
|
|
50
|
+
console.log('Payment result:', result);
|
|
51
|
+
|
|
52
|
+
if (result.status === 'success') {
|
|
53
|
+
// Ödeme başarılı
|
|
54
|
+
console.log('Payment successful!');
|
|
55
|
+
console.log('Order ID:', result.orderId);
|
|
56
|
+
console.log('Payment ID:', result.transactionId);
|
|
57
|
+
console.log('Amount:', result.amount, result.currency);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
res.status(200).send('OK');
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Callback error:', error.message);
|
|
63
|
+
res.status(400).send('ERROR');
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Ödeme durumu sorgulama
|
|
68
|
+
app.get('/payment-status/:paymentId', async (req, res) => {
|
|
69
|
+
try {
|
|
70
|
+
const status = await epointClient.getPaymentStatus(req.params.paymentId);
|
|
71
|
+
res.json(status);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
res.status(500).json({ error: error.message });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Başarı sayfası
|
|
78
|
+
app.get('/success', (req, res) => {
|
|
79
|
+
res.send('<h1>Ödəmə uğurla tamamlandı!</h1><p>Təşəkkürlər.</p>');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Hata sayfası
|
|
83
|
+
app.get('/fail', (req, res) => {
|
|
84
|
+
res.send('<h1>Ödəmə uğursuz</h1><p>Zəhmət olmasa yenidən cəhd edin.</p>');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const PORT = 3000;
|
|
88
|
+
app.listen(PORT, () => {
|
|
89
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
90
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
91
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const FreeKassaClient = require('../lib/freekassa');
|
|
2
|
+
|
|
3
|
+
const client = new FreeKassaClient({
|
|
4
|
+
shopId: 'YOUR_SHOP_ID',
|
|
5
|
+
secretKey1: 'YOUR_SECRET_KEY_1',
|
|
6
|
+
secretKey2: 'YOUR_SECRET_KEY_2'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function example() {
|
|
10
|
+
try {
|
|
11
|
+
const payment = await client.createPayment({
|
|
12
|
+
amount: 1000,
|
|
13
|
+
orderId: 'TEST-001',
|
|
14
|
+
currency: 'RUB',
|
|
15
|
+
email: 'customer@example.com',
|
|
16
|
+
name: 'John Doe'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log('Payment URL:', payment.data.url);
|
|
20
|
+
console.log('Signature:', payment.data.signature);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Error:', error.message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
example();
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const Heleket = require('./lib/heleket');
|
|
2
|
+
const QuickPos = require('./app');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const quickPos = new QuickPos({
|
|
7
|
+
providers: {
|
|
8
|
+
heleket: {
|
|
9
|
+
merchantId: '6764fdb7-7a2c-4599--',
|
|
10
|
+
apiKey: ''
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
let heleket = quickPos.providers['heleket'];
|
|
16
|
+
|
|
17
|
+
// Örnek fatura oluşturma
|
|
18
|
+
async function createSampleInvoice() {
|
|
19
|
+
try {
|
|
20
|
+
const result = await heleket.createInvoice({
|
|
21
|
+
amount: "20",
|
|
22
|
+
currency: "USDT",
|
|
23
|
+
order_id: "test-1234",
|
|
24
|
+
network: "tron"
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
console.log('Fatura oluşturuldu:', result);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Fatura oluşturulurken hata:', error.message);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Örnek ödeme hizmetlerini getirme
|
|
34
|
+
async function getServices() {
|
|
35
|
+
try {
|
|
36
|
+
const services = await heleket.getPaymentServices();
|
|
37
|
+
console.log('Ödeme hizmetleri:', services);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Hizmetler alınırken hata:', error.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Webhook imzasını doğrulama örneği
|
|
44
|
+
function verifyWebhook() {
|
|
45
|
+
const webhookData = {
|
|
46
|
+
order_id: 'test-123',
|
|
47
|
+
status: 'completed',
|
|
48
|
+
amount: '20',
|
|
49
|
+
currency: 'USDT',
|
|
50
|
+
sign: 'example-signature-here'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const isValid = heleket.verifyWebhookSignature(webhookData);
|
|
54
|
+
console.log('Webhook geçerli mi:', isValid);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Webhook callback işleme örneği
|
|
58
|
+
async function handleCallbackExample() {
|
|
59
|
+
const webhookData = {
|
|
60
|
+
order_id: 'test-123',
|
|
61
|
+
transaction_id: 'tx-456789',
|
|
62
|
+
status: 'completed',
|
|
63
|
+
amount: '20',
|
|
64
|
+
currency: 'USDT',
|
|
65
|
+
network: 'tron',
|
|
66
|
+
sign: 'example-signature-here'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const result = await heleket.handleCallback(webhookData);
|
|
71
|
+
console.log('Callback işleme sonucu:', result);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Callback işlenirken hata:', error.message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Örnek ödeme webhook'u test etme
|
|
78
|
+
async function testPaymentWebhookExample() {
|
|
79
|
+
try {
|
|
80
|
+
const result = await heleket.testPaymentWebhook({
|
|
81
|
+
url_callback: "https://test.speedsmm.com/api/payment/callback/heleket",
|
|
82
|
+
currency: "USDT",
|
|
83
|
+
network: "tron",
|
|
84
|
+
order_id: "Sb4afa7aadbb8833c1811daf5353a7df0T1746284735962",
|
|
85
|
+
status: "paid"
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
console.log('Ödeme webhook testi sonucu:', result);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('Ödeme webhook testi sırasında hata:', error.message);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
testPaymentWebhookExample();
|
|
94
|
+
// Örnek ödeme çıkışı webhook'u test etme
|
|
95
|
+
async function testPayoutWebhookExample() {
|
|
96
|
+
try {
|
|
97
|
+
const result = await heleket.testPayoutWebhook({
|
|
98
|
+
url_callback: "https://your-webhook-url.com/callback",
|
|
99
|
+
currency: "USDT",
|
|
100
|
+
network: "tron",
|
|
101
|
+
order_id: "test-5678",
|
|
102
|
+
status: "paid"
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log('Ödeme çıkışı webhook testi sonucu:', result);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error('Ödeme çıkışı webhook testi sırasında hata:', error.message);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Örnek cüzdan webhook'u test etme
|
|
112
|
+
async function testWalletWebhookExample() {
|
|
113
|
+
try {
|
|
114
|
+
const result = await heleket.testWalletWebhook({
|
|
115
|
+
url_callback: "https://your-webhook-url.com/callback",
|
|
116
|
+
currency: "USDT",
|
|
117
|
+
network: "tron",
|
|
118
|
+
uuid: "645eb262-19e5-481c-85ee-28331b5f3254",
|
|
119
|
+
status: "paid"
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log('Cüzdan webhook testi sonucu:', result);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error('Cüzdan webhook testi sırasında hata:', error.message);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Örnek fonksiyonları çalıştır
|
|
129
|
+
(async () => {
|
|
130
|
+
// await createSampleInvoice();
|
|
131
|
+
// // await getServices();
|
|
132
|
+
// verifyWebhook();
|
|
133
|
+
// handleCallbackExample();
|
|
134
|
+
|
|
135
|
+
// Test webhook fonksiyonlarını çalıştır
|
|
136
|
+
// await testPaymentWebhookExample();
|
|
137
|
+
// await testPayoutWebhookExample();
|
|
138
|
+
// await testWalletWebhookExample();
|
|
139
|
+
})();
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
const KonnectService = require('./lib/konnect');
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const bodyParser = require('body-parser');
|
|
4
|
+
const app = express();
|
|
5
|
+
|
|
6
|
+
// Body parser middleware
|
|
7
|
+
app.use(bodyParser.json());
|
|
8
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
9
|
+
|
|
10
|
+
// Tüm istekleri loglama
|
|
11
|
+
app.use((req, res, next) => {
|
|
12
|
+
console.log(`[${new Date().toISOString()}] Gelen istek: ${req.method} ${req.url}`);
|
|
13
|
+
console.log('Headers:', JSON.stringify(req.headers));
|
|
14
|
+
if (Object.keys(req.query).length > 0) {
|
|
15
|
+
console.log('Query:', JSON.stringify(req.query));
|
|
16
|
+
}
|
|
17
|
+
if (req.body && Object.keys(req.body).length > 0) {
|
|
18
|
+
console.log('Body:', JSON.stringify(req.body));
|
|
19
|
+
}
|
|
20
|
+
next();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Konnect konfigürasyonu - kendi API anahtarınızı ve cüzdan ID'nizi kullanmalısınız
|
|
24
|
+
const konnectConfig = {
|
|
25
|
+
apiKey: ':', // Konnect API anahtarınız
|
|
26
|
+
receiverWalletId: '', // Konnect cüzdan ID'niz
|
|
27
|
+
sandbox: true, // Sandbox ortamı için true, canlı ortam için false
|
|
28
|
+
testMode: true
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Konnect servisini başlat
|
|
32
|
+
const konnect = new KonnectService(konnectConfig);
|
|
33
|
+
|
|
34
|
+
// Ödeme oluşturma örneği
|
|
35
|
+
async function createPaymentExample() {
|
|
36
|
+
try {
|
|
37
|
+
console.log('Yeni ödeme isteği oluşturuluyor...');
|
|
38
|
+
|
|
39
|
+
const paymentResult = await konnect.createPayment({
|
|
40
|
+
amount: 10000, // 10 TND (millimes cinsinden)
|
|
41
|
+
token: 'TND', // Para birimi (TND, EUR, veya USD)
|
|
42
|
+
description: 'Premium Üyelik - 1 Ay',
|
|
43
|
+
type: 'immediate', // Anında ödeme
|
|
44
|
+
orderId: 'siparis-' + Date.now(),
|
|
45
|
+
webhook: 'https://test.quickpanel.net/webhook',
|
|
46
|
+
email: 'musteri@ornek.com',
|
|
47
|
+
firstName: 'İsim',
|
|
48
|
+
lastName: 'Soyisim',
|
|
49
|
+
phoneNumber: '22777777',
|
|
50
|
+
acceptedPaymentMethods: ["wallet", "bank_card", "e-DINAR"],
|
|
51
|
+
lifespan: 60, // 60 dakika ödeme süresi
|
|
52
|
+
checkoutForm: true, // Ödeme formunu göster
|
|
53
|
+
theme: 'light', // Arayüz teması
|
|
54
|
+
generateQr: true // QR kod oluştur
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log('Ödeme bağlantısı oluşturuldu:');
|
|
58
|
+
console.log(JSON.stringify(paymentResult, null, 2));
|
|
59
|
+
console.log('\nWebhook test sunucusu başlatıldı: http://localhost:80');
|
|
60
|
+
console.log('Webhook URL\'inizi Konnect panelinde ayarlayabilir veya her ödeme için belirtebilirsiniz.');
|
|
61
|
+
|
|
62
|
+
return paymentResult;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Ödeme oluşturma hatası:', error.message);
|
|
65
|
+
return { status: 'error', message: error.message };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Webhook endpoint
|
|
70
|
+
app.get('/webhook', async (req, res) => {
|
|
71
|
+
console.log('🔔 Konnect webhook çağrısı alındı!');
|
|
72
|
+
|
|
73
|
+
const paymentRef = req.query.payment_ref;
|
|
74
|
+
if (!paymentRef) {
|
|
75
|
+
console.error('❌ Webhook hata: payment_ref parametresi eksik');
|
|
76
|
+
return res.status(400).send('Missing payment_ref');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(`📌 Ödeme Referansı: ${paymentRef}`);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// Callback işleme
|
|
83
|
+
const result = await konnect.handleCallback({ payment_ref: paymentRef });
|
|
84
|
+
console.log('✅ Ödeme durumu:', result);
|
|
85
|
+
|
|
86
|
+
if (result.status === 'success') {
|
|
87
|
+
console.log(`✅ Başarılı Ödeme: Sipariş ${result.orderId} için ${result.amount} ${result.currency} ödeme alındı`);
|
|
88
|
+
|
|
89
|
+
// Burada başarılı ödeme işlemleri yapılabilir
|
|
90
|
+
// - Veritabanı güncelleme
|
|
91
|
+
// - Sipariş durumu değiştirme
|
|
92
|
+
// - Kullanıcı hesabını aktifleştirme vb.
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
console.log(`❌ Başarısız Ödeme: Sipariş ${result.orderId} - Sebep: ${result.reason}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Konnect webhook success sayfasına yönlendir
|
|
99
|
+
res.status(200).send('OK');
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('⚠️ Webhook işleme hatası:', error.message);
|
|
102
|
+
res.status(200).send('Error: ' + error.message);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Ödeme durumu kontrol endpoint'i
|
|
107
|
+
app.get('/payment-status/:paymentRef', async (req, res) => {
|
|
108
|
+
const paymentRef = req.params.paymentRef;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const paymentDetails = await konnect.getPaymentDetails(paymentRef);
|
|
112
|
+
res.json(paymentDetails);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(`❌ Ödeme durumu sorgulama hatası: ${error.message}`);
|
|
115
|
+
res.status(400).json({ error: error.message });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Başarılı ödeme dönüş sayfası
|
|
120
|
+
app.get('/success', (req, res) => {
|
|
121
|
+
res.send(`
|
|
122
|
+
<html>
|
|
123
|
+
<head>
|
|
124
|
+
<title>Ödeme Başarılı</title>
|
|
125
|
+
<style>
|
|
126
|
+
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
|
|
127
|
+
.success { color: green; font-size: 24px; margin-bottom: 20px; }
|
|
128
|
+
</style>
|
|
129
|
+
</head>
|
|
130
|
+
<body>
|
|
131
|
+
<div class="success">Ödemeniz başarıyla tamamlandı!</div>
|
|
132
|
+
<p>Teşekkür ederiz. Siparişiniz işleme alındı.</p>
|
|
133
|
+
<pre>${JSON.stringify(req.query, null, 2)}</pre>
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
136
|
+
`);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Ana sayfa
|
|
140
|
+
app.get('/', (req, res) => {
|
|
141
|
+
res.send(`
|
|
142
|
+
<html>
|
|
143
|
+
<head>
|
|
144
|
+
<title>Konnect Ödeme Testi</title>
|
|
145
|
+
<style>
|
|
146
|
+
body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; }
|
|
147
|
+
button { padding: 10px 15px; background: #0066ff; color: white; border: none; border-radius: 4px; cursor: pointer; }
|
|
148
|
+
.container { margin-top: 20px; }
|
|
149
|
+
pre { background: #f4f4f4; padding: 10px; border-radius: 4px; overflow: auto; }
|
|
150
|
+
.error { color: red; }
|
|
151
|
+
</style>
|
|
152
|
+
</head>
|
|
153
|
+
<body>
|
|
154
|
+
<h1>Konnect Ödeme Testi</h1>
|
|
155
|
+
<p>Konnect Sandbox API ile ödeme bağlantısı oluşturma testi.</p>
|
|
156
|
+
<button onclick="createPayment()">Yeni Ödeme Oluştur</button>
|
|
157
|
+
|
|
158
|
+
<div class="container" id="result">
|
|
159
|
+
<p>Bu test için aşağıdaki bilgileri kullanıyoruz:</p>
|
|
160
|
+
<pre>API Anahtarı: ${konnectConfig.apiKey.substring(0, 10)}...
|
|
161
|
+
Cüzdan ID: ${konnectConfig.receiverWalletId}
|
|
162
|
+
Ortam: ${konnectConfig.sandbox ? 'Sandbox (test)' : 'Production (canlı)'}</pre>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<script>
|
|
166
|
+
function createPayment() {
|
|
167
|
+
document.getElementById('result').innerHTML = '<p>Ödeme oluşturuluyor...</p>';
|
|
168
|
+
|
|
169
|
+
fetch('/create-payment')
|
|
170
|
+
.then(response => response.json())
|
|
171
|
+
.then(data => {
|
|
172
|
+
if (data.status === 'success') {
|
|
173
|
+
let html = \`
|
|
174
|
+
<h3>Ödeme Bağlantısı Oluşturuldu</h3>
|
|
175
|
+
<p>Ödeme ID: \${data.data.id}</p>
|
|
176
|
+
<p>Ödeme URL: <a href="\${data.data.url}" target="_blank">\${data.data.url}</a></p>
|
|
177
|
+
\`;
|
|
178
|
+
|
|
179
|
+
if (data.data.qr) {
|
|
180
|
+
html += \`<p>QR Kod:</p><img src="\${data.data.qr}" width="200" />\`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
document.getElementById('result').innerHTML = html;
|
|
184
|
+
} else {
|
|
185
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + data.message + '</p>';
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
.catch(error => {
|
|
189
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + error + '</p>';
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
</script>
|
|
193
|
+
</body>
|
|
194
|
+
</html>
|
|
195
|
+
`);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// API endpoint - yeni ödeme oluşturma
|
|
199
|
+
app.get('/create-payment', async (req, res) => {
|
|
200
|
+
try {
|
|
201
|
+
const result = await createPaymentExample();
|
|
202
|
+
res.json(result);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
res.status(400).json({ status: 'error', message: error.message });
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Test sunucusunu başlat
|
|
209
|
+
const PORT = 80;
|
|
210
|
+
app.listen(PORT, () => {
|
|
211
|
+
console.log(`🚀 Test sunucusu başlatıldı: http://localhost:${PORT}`);
|
|
212
|
+
console.log(`🔔 Webhook URL: http://localhost:${PORT}/webhook`);
|
|
213
|
+
console.log('⚠️ Konnect Entegrasyon Ayarları:');
|
|
214
|
+
console.log(` - API Key: ${konnectConfig.apiKey.substring(0, 10)}...`);
|
|
215
|
+
console.log(` - Wallet ID: ${konnectConfig.receiverWalletId}`);
|
|
216
|
+
console.log(` - Ortam: ${konnectConfig.sandbox ? 'Sandbox (Test)' : 'Production (Canlı)'}`);
|
|
217
|
+
console.log(` - API Base URL: ${konnect.baseUrl}`);
|
|
218
|
+
|
|
219
|
+
console.log('⚠️ Gerçek ortamda, webhook URL\'inizi Konnect panelinde ayarlayın');
|
|
220
|
+
console.log('⚠️ Konnect entegrasyonu için:');
|
|
221
|
+
console.log(' 1. Konnect hesabı oluşturun:');
|
|
222
|
+
console.log(' - Sandbox (test): https://dashboard.sandbox.konnect.network');
|
|
223
|
+
console.log(' - Üretim: https://dashboard.konnect.network');
|
|
224
|
+
console.log(' 2. KYC/KYB doğrulamasını tamamlayın (kimlik ve kurum doğrulama)');
|
|
225
|
+
console.log(' 3. API anahtarınızı ve cüzdan ID\'nizi alın');
|
|
226
|
+
console.log(' 4. example-konnect.js dosyasındaki yapılandırmayı güncelleyin');
|
|
227
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const QuickPos = require('./app');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
7
|
+
app.use(bodyParser.json());
|
|
8
|
+
|
|
9
|
+
const quickPos = new QuickPos({
|
|
10
|
+
providers: {
|
|
11
|
+
midtrans: {
|
|
12
|
+
serverKey: 'your-server-key',
|
|
13
|
+
clientKey: 'your-client-key',
|
|
14
|
+
isProduction: false // Set to true for production
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
app.use(quickPos.middleware());
|
|
20
|
+
|
|
21
|
+
// Payment form
|
|
22
|
+
app.get('/', (req, res) => {
|
|
23
|
+
res.send(`
|
|
24
|
+
<h1>Midtrans Payment Example</h1>
|
|
25
|
+
<form action="/payment/midtrans" method="post">
|
|
26
|
+
<input type="text" name="amount" placeholder="Amount" required>
|
|
27
|
+
<input type="email" name="email" placeholder="Email" required>
|
|
28
|
+
<input type="text" name="name" placeholder="Name" required>
|
|
29
|
+
<input type="text" name="phone" placeholder="Phone" required>
|
|
30
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
31
|
+
<button type="submit">Pay with Midtrans</button>
|
|
32
|
+
</form>
|
|
33
|
+
`);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Create payment
|
|
37
|
+
app.post('/payment/:provider', async (req, res) => {
|
|
38
|
+
const { provider } = req.params;
|
|
39
|
+
|
|
40
|
+
if (!req.quickPos[provider]) {
|
|
41
|
+
return res.status(400).json({ error: 'Invalid payment provider' });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const result = await req.quickPos[provider].createPayment({
|
|
46
|
+
name: req.body.name,
|
|
47
|
+
amount: req.body.amount,
|
|
48
|
+
email: req.body.email,
|
|
49
|
+
phone: req.body.phone,
|
|
50
|
+
orderId: req.body.orderId,
|
|
51
|
+
callbackUrl: `http://localhost:3000/payment-callback/${provider}`,
|
|
52
|
+
itemName: 'Test Product'
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (result.status === 'success') {
|
|
56
|
+
res.json({
|
|
57
|
+
success: true,
|
|
58
|
+
redirectUrl: result.data.url,
|
|
59
|
+
token: result.data.token,
|
|
60
|
+
orderId: result.data.orderId
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
res.status(400).json(result);
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
res.status(500).json({ error: error.message });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Payment callback
|
|
71
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('midtrans'), (req, res) => {
|
|
72
|
+
console.log('Payment result:', req.paymentResult);
|
|
73
|
+
res.json({ success: true, data: req.paymentResult });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const PORT = process.env.PORT || 3000;
|
|
77
|
+
app.listen(PORT, () => {
|
|
78
|
+
console.log(`Server is running on port ${PORT}`);
|
|
79
|
+
console.log(`Open http://localhost:${PORT} to test`);
|
|
80
|
+
});
|