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,297 @@
|
|
|
1
|
+
const NOONPaymentsService = require('./lib/noonpayments');
|
|
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
|
+
if (Object.keys(req.query).length > 0) {
|
|
14
|
+
console.log('Query:', JSON.stringify(req.query));
|
|
15
|
+
}
|
|
16
|
+
if (req.body && Object.keys(req.body).length > 0) {
|
|
17
|
+
console.log('Body:', JSON.stringify(req.body));
|
|
18
|
+
}
|
|
19
|
+
next();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// NOONPayments konfigürasyonu - kendi API anahtarınızı kullanmalısınız
|
|
23
|
+
const noonpaymentsConfig = {
|
|
24
|
+
businessId: 'test', // NOONPayments panelinden alınır
|
|
25
|
+
appName: 'test', // NOONPayments uygulamanızın adı
|
|
26
|
+
appKey: 'test', // NOONPayments uygulamanızın anahtarı
|
|
27
|
+
region: '', // Boş bırakılırsa global, 'sa' veya 'eg' olabilir
|
|
28
|
+
sandbox: true, // Sandbox (test) ortamı için true
|
|
29
|
+
debug: true // Debug modu açık (geliştirme sırasında)
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// NOONPayments servisini başlat
|
|
33
|
+
const noonpayments = new NOONPaymentsService(noonpaymentsConfig);
|
|
34
|
+
|
|
35
|
+
// Ödeme oluşturma örneği
|
|
36
|
+
async function createPaymentExample() {
|
|
37
|
+
try {
|
|
38
|
+
console.log('Yeni ödeme isteği oluşturuluyor...');
|
|
39
|
+
|
|
40
|
+
// Benzersiz sipariş ID'si oluştur
|
|
41
|
+
const orderId = 'order-' + Date.now();
|
|
42
|
+
|
|
43
|
+
const paymentResult = await noonpayments.createPayment({
|
|
44
|
+
amount: 100.50, // Ödeme tutarı
|
|
45
|
+
currency: 'AED', // Para birimi (AED, SAR, EGP vb.)
|
|
46
|
+
reference: orderId, // Sipariş referansı/ID'si
|
|
47
|
+
name: 'Premium Üyelik', // Sipariş/ürün adı
|
|
48
|
+
channel: 'web', // Ödeme kanalı (web, mobile)
|
|
49
|
+
category: 'pay', // Kategori (noonpayments panelinde tanımlı)
|
|
50
|
+
returnUrl: 'https://test.quickpanel.net/success', // Başarılı ödeme dönüş URL'i
|
|
51
|
+
locale: 'en', // Dil
|
|
52
|
+
generateQr: true, // QR kod oluştur
|
|
53
|
+
// İsteğe bağlı alanlar
|
|
54
|
+
billing: { // Fatura bilgileri
|
|
55
|
+
address: {
|
|
56
|
+
street: 'Test Street',
|
|
57
|
+
city: 'Dubai',
|
|
58
|
+
stateProvince: 'Dubai',
|
|
59
|
+
country: 'AE',
|
|
60
|
+
postalCode: '12345'
|
|
61
|
+
},
|
|
62
|
+
contact: {
|
|
63
|
+
firstName: 'John',
|
|
64
|
+
lastName: 'Doe',
|
|
65
|
+
phone: '05012345678',
|
|
66
|
+
email: 'test@example.com'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
shipping: { // Teslimat bilgileri (gerekiyorsa)
|
|
70
|
+
address: {
|
|
71
|
+
street: 'Test Street',
|
|
72
|
+
city: 'Dubai',
|
|
73
|
+
stateProvince: 'Dubai',
|
|
74
|
+
country: 'AE',
|
|
75
|
+
postalCode: '12345'
|
|
76
|
+
},
|
|
77
|
+
contact: {
|
|
78
|
+
firstName: 'John',
|
|
79
|
+
lastName: 'Doe',
|
|
80
|
+
phone: '05012345678',
|
|
81
|
+
email: 'test@example.com'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// Doğrudan kart bilgileri ile ödeme (PCI-DSS uyumlu merchantlar için)
|
|
85
|
+
// cardData: {
|
|
86
|
+
// nameOnCard: 'John Doe',
|
|
87
|
+
// numberPlain: '4111111111111111',
|
|
88
|
+
// cvv: '123',
|
|
89
|
+
// expiryMonth: '12',
|
|
90
|
+
// expiryYear: '2030'
|
|
91
|
+
// },
|
|
92
|
+
// Token kullanarak ödeme
|
|
93
|
+
// tokenIdentifier: 'a9eca373-c4c8-4dde-be64-d058b3ce6eb9',
|
|
94
|
+
paymentAction: 'AUTHORIZE,SALE' // AUTHORIZE sonra SALE için
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log('Ödeme bağlantısı oluşturuldu:');
|
|
98
|
+
console.log(JSON.stringify(paymentResult, null, 2));
|
|
99
|
+
|
|
100
|
+
return paymentResult;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Ödeme oluşturma hatası:', error.message);
|
|
103
|
+
return { status: 'error', message: error.message };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Webhook endpoint
|
|
108
|
+
app.post('/webhook', async (req, res) => {
|
|
109
|
+
console.log('🔔 NOONPayments webhook çağrısı alındı!');
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
// Webhook verilerini işle
|
|
113
|
+
const result = await noonpayments.handleCallback(req.body);
|
|
114
|
+
console.log('✅ Ödeme durumu:', result);
|
|
115
|
+
|
|
116
|
+
if (result.status === 'success') {
|
|
117
|
+
console.log(`✅ Başarılı Ödeme: Sipariş ${result.orderId} için ${result.amount} ${result.currency} ödeme alındı`);
|
|
118
|
+
|
|
119
|
+
// Burada başarılı ödeme işlemleri yapılabilir
|
|
120
|
+
// - Veritabanı güncelleme
|
|
121
|
+
// - Sipariş durumu değiştirme
|
|
122
|
+
// - Kullanıcı hesabını aktifleştirme vb.
|
|
123
|
+
|
|
124
|
+
} else if (result.status === 'authorized') {
|
|
125
|
+
console.log(`🔄 Yetkilendirilmiş Ödeme: Sipariş ${result.orderId} için ${result.amount} ${result.currency} ödeme yetkilendirildi`);
|
|
126
|
+
} else if (result.status === 'captured') {
|
|
127
|
+
console.log(`💰 Çekilen Ödeme: Sipariş ${result.orderId} için ${result.amount} ${result.currency} ödeme çekildi`);
|
|
128
|
+
} else if (result.status === 'refunded') {
|
|
129
|
+
console.log(`♻️ İade Edilen Ödeme: Sipariş ${result.orderId} için ${result.amount} ${result.currency} iade edildi`);
|
|
130
|
+
} else if (result.status === 'failed' || result.status === 'authorization_failed' || result.status === 'capture_failed') {
|
|
131
|
+
console.log(`❌ Başarısız Ödeme: Sipariş ${result.orderId}`);
|
|
132
|
+
} else {
|
|
133
|
+
console.log(`ℹ️ Diğer Ödeme Durumu: ${result.status} - Sipariş: ${result.orderId}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Başarılı yanıt gönder
|
|
137
|
+
res.status(200).json({ status: 'success' });
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('⚠️ Webhook işleme hatası:', error.message);
|
|
140
|
+
// Hata durumunda bile 200 OK dönmek genelde daha iyidir
|
|
141
|
+
res.status(200).json({ status: 'error', message: error.message });
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Ödeme durumu sorgulama endpoint'i
|
|
146
|
+
app.get('/order-status/:orderId', async (req, res) => {
|
|
147
|
+
try {
|
|
148
|
+
const result = await noonpayments.getOrderStatus(req.params.orderId);
|
|
149
|
+
res.json(result);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error(`❌ Ödeme durumu sorgulama hatası: ${error.message}`);
|
|
152
|
+
res.status(400).json({ error: error.message });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Başarılı ödeme dönüş sayfası
|
|
157
|
+
app.get('/success', (req, res) => {
|
|
158
|
+
res.send(`
|
|
159
|
+
<html>
|
|
160
|
+
<head>
|
|
161
|
+
<title>Ödeme Başarılı</title>
|
|
162
|
+
<style>
|
|
163
|
+
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
|
|
164
|
+
.success { color: green; font-size: 24px; margin-bottom: 20px; }
|
|
165
|
+
</style>
|
|
166
|
+
</head>
|
|
167
|
+
<body>
|
|
168
|
+
<div class="success">Ödemeniz işleme alındı!</div>
|
|
169
|
+
<p>Teşekkür ederiz. Siparişiniz işleme alınacaktır.</p>
|
|
170
|
+
<pre>${JSON.stringify(req.query, null, 2)}</pre>
|
|
171
|
+
</body>
|
|
172
|
+
</html>
|
|
173
|
+
`);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Ana sayfa
|
|
177
|
+
app.get('/', (req, res) => {
|
|
178
|
+
res.send(`
|
|
179
|
+
<html>
|
|
180
|
+
<head>
|
|
181
|
+
<title>NOONPayments Ödeme Testi</title>
|
|
182
|
+
<style>
|
|
183
|
+
body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; }
|
|
184
|
+
button { padding: 10px 15px; background: #0066ff; color: white; border: none; border-radius: 4px; cursor: pointer; }
|
|
185
|
+
.container { margin-top: 20px; }
|
|
186
|
+
pre { background: #f4f4f4; padding: 10px; border-radius: 4px; overflow: auto; }
|
|
187
|
+
.error { color: red; }
|
|
188
|
+
.verify-form { margin-top: 30px; padding: 15px; border: 1px solid #ddd; border-radius: 4px; }
|
|
189
|
+
input { padding: 8px; width: 300px; }
|
|
190
|
+
</style>
|
|
191
|
+
</head>
|
|
192
|
+
<body>
|
|
193
|
+
<h1>NOONPayments Ödeme Testi</h1>
|
|
194
|
+
<p>NOONPayments API ile ödeme bağlantısı oluşturma testi.</p>
|
|
195
|
+
<button id="create-payment-btn">Yeni Ödeme Oluştur</button>
|
|
196
|
+
|
|
197
|
+
<div class="container" id="result">
|
|
198
|
+
<p>Bu test için aşağıdaki bilgileri kullanıyoruz:</p>
|
|
199
|
+
<pre>Business ID: ${noonpaymentsConfig.businessId}
|
|
200
|
+
Application: ${noonpaymentsConfig.appName}
|
|
201
|
+
Ortam: ${noonpaymentsConfig.sandbox ? 'Sandbox (test)' : 'Production (canlı)'}</pre>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div class="verify-form">
|
|
205
|
+
<h3>Sipariş Durumu Sorgulama</h3>
|
|
206
|
+
<p>NOONPayments sipariş ID'si ile ödeme durumunu kontrol edin:</p>
|
|
207
|
+
<input type="text" id="orderId" placeholder="Sipariş ID'si girin">
|
|
208
|
+
<button id="check-status-btn">Sorgula</button>
|
|
209
|
+
<div id="statusResult"></div>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<script>
|
|
213
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
214
|
+
document.getElementById('create-payment-btn').addEventListener('click', function() {
|
|
215
|
+
document.getElementById('result').innerHTML = '<p>Ödeme oluşturuluyor...</p>';
|
|
216
|
+
|
|
217
|
+
fetch('/create-payment')
|
|
218
|
+
.then(response => response.json())
|
|
219
|
+
.then(data => {
|
|
220
|
+
if (data.status === 'success') {
|
|
221
|
+
let html = \`
|
|
222
|
+
<h3>Ödeme Bağlantısı Oluşturuldu</h3>
|
|
223
|
+
<p>Sipariş ID: \${data.data.id}</p>
|
|
224
|
+
<p>Sipariş Referansı: \${data.data.orderId}</p>
|
|
225
|
+
<p>Ödeme URL: <a href="\${data.data.url}" target="_blank">\${data.data.url}</a></p>
|
|
226
|
+
\`;
|
|
227
|
+
|
|
228
|
+
if (data.data.qr) {
|
|
229
|
+
html += \`<p>QR Kod:</p><img src="\${data.data.qr}" width="200" />\`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
document.getElementById('result').innerHTML = html;
|
|
233
|
+
} else {
|
|
234
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + data.message + '</p>';
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
.catch(error => {
|
|
238
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + error + '</p>';
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
document.getElementById('check-status-btn').addEventListener('click', function() {
|
|
243
|
+
const orderId = document.getElementById('orderId').value.trim();
|
|
244
|
+
if (!orderId) {
|
|
245
|
+
alert('Lütfen bir sipariş ID\\'si girin');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
document.getElementById('statusResult').innerHTML = '<p>Sipariş durumu sorgulanıyor...</p>';
|
|
250
|
+
|
|
251
|
+
fetch(\`/order-status/\${orderId}\`)
|
|
252
|
+
.then(response => response.json())
|
|
253
|
+
.then(data => {
|
|
254
|
+
let html = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
|
255
|
+
document.getElementById('statusResult').innerHTML = html;
|
|
256
|
+
})
|
|
257
|
+
.catch(error => {
|
|
258
|
+
document.getElementById('statusResult').innerHTML = '<p class="error">Hata: ' + error + '</p>';
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
</script>
|
|
263
|
+
</body>
|
|
264
|
+
</html>
|
|
265
|
+
`);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// API endpoint - yeni ödeme oluşturma
|
|
269
|
+
app.get('/create-payment', async (req, res) => {
|
|
270
|
+
try {
|
|
271
|
+
const result = await createPaymentExample();
|
|
272
|
+
res.json(result);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
res.status(400).json({ status: 'error', message: error.message });
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Test sunucusunu başlat
|
|
279
|
+
const PORT = 80;
|
|
280
|
+
app.listen(PORT, () => {
|
|
281
|
+
console.log(`🚀 Test sunucusu başlatıldı: http://localhost:${PORT}`);
|
|
282
|
+
console.log(`🔔 Webhook URL: http://localhost:${PORT}/webhook`);
|
|
283
|
+
console.log('⚠️ NOONPayments Entegrasyon Ayarları:');
|
|
284
|
+
console.log(` - Business ID: ${noonpaymentsConfig.businessId}`);
|
|
285
|
+
console.log(` - App Name: ${noonpaymentsConfig.appName}`);
|
|
286
|
+
console.log(` - Ortam: ${noonpaymentsConfig.sandbox ? 'Sandbox (Test)' : 'Production (Canlı)'}`);
|
|
287
|
+
console.log(` - API Base URL: ${noonpayments.baseUrl}`);
|
|
288
|
+
|
|
289
|
+
console.log('⚠️ Not: Gerçek ortamda, webhook URL\'inizi NOONPayments panelinde ayarlayın');
|
|
290
|
+
console.log('⚠️ Ayrıca, example-noonpayments.js dosyasındaki konfigürasyon bilgilerini kendi değerlerinizle değiştirmeyi unutmayın');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Sunucuyu kapatmak için CTRL+C
|
|
294
|
+
process.on('SIGINT', () => {
|
|
295
|
+
console.log('Test sunucusu kapatılıyor...');
|
|
296
|
+
process.exit(0);
|
|
297
|
+
});
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
const NOWPaymentsService = require('./lib/nowpayments');
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const bodyParser = require('body-parser');
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
const app = express();
|
|
6
|
+
|
|
7
|
+
// Body parser middleware
|
|
8
|
+
app.use(bodyParser.json());
|
|
9
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
10
|
+
|
|
11
|
+
// Tüm istekleri loglama
|
|
12
|
+
app.use((req, res, next) => {
|
|
13
|
+
console.log(`[${new Date().toISOString()}] Gelen istek: ${req.method} ${req.url}`);
|
|
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
|
+
// NOWPayments konfigürasyonu - kendi API anahtarınızı kullanmalısınız
|
|
24
|
+
const nowpaymentsConfig = {
|
|
25
|
+
apiKey: 'V25V8J9-1ZY4B7K', // NOWPayments API anahtarınız
|
|
26
|
+
ipnSecret: '2uy+CaE', // Webhook güvenlik anahtarı
|
|
27
|
+
sandbox: false, // Sandbox ortamı için true, canlı ortam için false
|
|
28
|
+
debug: true // Debug modu açık (geliştirme sırasında)
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// NOWPayments servisini başlat
|
|
32
|
+
const nowpayments = new NOWPaymentsService(nowpaymentsConfig);
|
|
33
|
+
|
|
34
|
+
// Ödeme oluşturma örneği
|
|
35
|
+
async function createPaymentExample() {
|
|
36
|
+
try {
|
|
37
|
+
console.log('Yeni kripto ödeme isteği oluşturuluyor...');
|
|
38
|
+
|
|
39
|
+
// Benzersiz sipariş ID'si oluştur
|
|
40
|
+
const orderId = 'order-' + Date.now();
|
|
41
|
+
|
|
42
|
+
const paymentResult = await nowpayments.createPayment({
|
|
43
|
+
price: 100.50, // 100.50 USD/EUR/TL vb.
|
|
44
|
+
currency_from: 'USD', // Ödeme almak istediğiniz para birimi (USD, EUR, TRY vb.)
|
|
45
|
+
currency_to: 'ETH', // Hangi kripto para ile ödeme alınacak (BTC, ETH, LTC vb.)
|
|
46
|
+
order_id: orderId, // Sipariş ID'niz
|
|
47
|
+
description: 'Premium Üyelik - 1 Ay',
|
|
48
|
+
callbackUrl: 'https://test.quickpanel.net/webhook/nowpayments', // Webhook URL
|
|
49
|
+
successUrl: 'https://test.quickpanel.net/success', // Başarılı ödeme dönüş sayfası
|
|
50
|
+
cancelUrl: 'https://test.quickpanel.net/cancel', // İptal edilirse dönüş sayfası
|
|
51
|
+
generateQr: true // Kripto adresi için QR kod oluştur
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log('Ödeme bağlantısı oluşturuldu:');
|
|
55
|
+
console.log(JSON.stringify(paymentResult, null, 2));
|
|
56
|
+
|
|
57
|
+
return paymentResult;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Ödeme oluşturma hatası:', error.message);
|
|
60
|
+
return { status: 'error', message: error.message };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Webhook endpoint
|
|
65
|
+
app.post('/webhook/nowpayments', async (req, res) => {
|
|
66
|
+
console.log('🔔 NOWPayments webhook çağrısı alındı!');
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// Webhook verilerini işle
|
|
70
|
+
const result = await nowpayments.handleWebhook(req.body);
|
|
71
|
+
console.log('✅ Ödeme durumu:', result);
|
|
72
|
+
|
|
73
|
+
if (result.status === 'success') {
|
|
74
|
+
console.log(`✅ Başarılı Ödeme: Sipariş ${result.orderId} için ${result.priceAmount} ${result.priceCurrency} ödeme alındı`);
|
|
75
|
+
console.log(` ${result.payAmount} ${result.payCurrency} olarak ödendi`);
|
|
76
|
+
|
|
77
|
+
// Burada başarılı ödeme işlemleri yapılabilir
|
|
78
|
+
// - Veritabanı güncelleme
|
|
79
|
+
// - Sipariş durumu değiştirme
|
|
80
|
+
// - Kullanıcı hesabını aktifleştirme vb.
|
|
81
|
+
|
|
82
|
+
} else if (result.status === 'partially_paid') {
|
|
83
|
+
console.log(`⚠️ Kısmi Ödeme: Sipariş ${result.orderId} için kısmi ödeme alındı`);
|
|
84
|
+
console.log(` Beklenen: ${result.payAmount} ${result.payCurrency}, Alınan: ${result.actualAmount} ${result.payCurrency}`);
|
|
85
|
+
} else if (result.status === 'waiting') {
|
|
86
|
+
console.log(`⏳ Ödeme Bekleniyor: Sipariş ${result.orderId} için ${result.priceAmount} ${result.priceCurrency} ödeme bekleniyor`);
|
|
87
|
+
console.log(` Beklenen kripto: ${result.payAmount} ${result.payCurrency}`);
|
|
88
|
+
} else if (result.status === 'confirming') {
|
|
89
|
+
console.log(`🔄 Ödeme Onaylanıyor: Sipariş ${result.orderId} için blok zinciri onayı bekleniyor`);
|
|
90
|
+
} else if (result.status === 'refunded') {
|
|
91
|
+
console.log(`♻️ İade Edilen Ödeme: Sipariş ${result.orderId} için ödeme iade edildi`);
|
|
92
|
+
} else if (result.status === 'failed') {
|
|
93
|
+
console.log(`❌ Başarısız Ödeme: Sipariş ${result.orderId}`);
|
|
94
|
+
} else {
|
|
95
|
+
console.log(`ℹ️ Ödeme durumu güncellendi: ${result.orderId} - ${result.status} (${result.statusDescription})`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// NOWPayments'e başarılı yanıt gönder
|
|
99
|
+
res.status(200).send('OK');
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('⚠️ Webhook işleme hatası:', error.message);
|
|
102
|
+
// Webhook işleme hatası durumunda bile 200 OK dönmek önemli
|
|
103
|
+
res.status(200).send('OK');
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Ödeme durumu kontrol endpoint'i
|
|
108
|
+
app.get('/payment-status/:paymentId', async (req, res) => {
|
|
109
|
+
try {
|
|
110
|
+
const result = await nowpayments.checkPaymentStatus(req.params.paymentId);
|
|
111
|
+
res.json(result);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error(`❌ Ödeme durumu sorgulama hatası: ${error.message}`);
|
|
114
|
+
res.status(400).json({ error: error.message });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Başarılı ödeme dönüş sayfası
|
|
119
|
+
app.get('/success', (req, res) => {
|
|
120
|
+
res.send(`
|
|
121
|
+
<html>
|
|
122
|
+
<head>
|
|
123
|
+
<title>Ödeme Başarılı</title>
|
|
124
|
+
<style>
|
|
125
|
+
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
|
|
126
|
+
.success { color: green; font-size: 24px; margin-bottom: 20px; }
|
|
127
|
+
</style>
|
|
128
|
+
</head>
|
|
129
|
+
<body>
|
|
130
|
+
<div class="success">Ödemeniz işleme alındı!</div>
|
|
131
|
+
<p>Teşekkür ederiz. Ödemeniz onaylandığında siparişiniz işleme alınacaktır.</p>
|
|
132
|
+
<p>Not: Kripto para ödemeleri, işlemin blok zincirinde onaylanmasını gerektirdiği için biraz zaman alabilir.</p>
|
|
133
|
+
<pre>${JSON.stringify(req.query, null, 2)}</pre>
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
136
|
+
`);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// İptal sayfası
|
|
140
|
+
app.get('/cancel', (req, res) => {
|
|
141
|
+
res.send(`
|
|
142
|
+
<html>
|
|
143
|
+
<head>
|
|
144
|
+
<title>Ödeme İptal Edildi</title>
|
|
145
|
+
<style>
|
|
146
|
+
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
|
|
147
|
+
.cancel { color: red; font-size: 24px; margin-bottom: 20px; }
|
|
148
|
+
</style>
|
|
149
|
+
</head>
|
|
150
|
+
<body>
|
|
151
|
+
<div class="cancel">Ödeme işlemi iptal edildi</div>
|
|
152
|
+
<p>Ödeme işleminiz tamamlanmadı. Tekrar denemek için anasayfaya dönebilirsiniz.</p>
|
|
153
|
+
<a href="/">Anasayfaya Dön</a>
|
|
154
|
+
</body>
|
|
155
|
+
</html>
|
|
156
|
+
`);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Ana sayfa
|
|
160
|
+
app.get('/', (req, res) => {
|
|
161
|
+
res.send(`
|
|
162
|
+
<html>
|
|
163
|
+
<head>
|
|
164
|
+
<title>NOWPayments Kripto Ödeme Testi</title>
|
|
165
|
+
<style>
|
|
166
|
+
body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; }
|
|
167
|
+
button { padding: 10px 15px; background: #0066ff; color: white; border: none; border-radius: 4px; cursor: pointer; }
|
|
168
|
+
.container { margin-top: 20px; }
|
|
169
|
+
pre { background: #f4f4f4; padding: 10px; border-radius: 4px; overflow: auto; }
|
|
170
|
+
.error { color: red; }
|
|
171
|
+
.verify-form { margin-top: 30px; padding: 15px; border: 1px solid #ddd; border-radius: 4px; }
|
|
172
|
+
input { padding: 8px; width: 300px; }
|
|
173
|
+
</style>
|
|
174
|
+
</head>
|
|
175
|
+
<body>
|
|
176
|
+
<h1>NOWPayments Kripto Ödeme Testi</h1>
|
|
177
|
+
<p>NOWPayments API ile kripto para ödeme bağlantısı oluşturma testi.</p>
|
|
178
|
+
<button id="create-payment-btn">Yeni Kripto Ödeme Oluştur</button>
|
|
179
|
+
|
|
180
|
+
<div class="container" id="result">
|
|
181
|
+
<p>Bu test için aşağıdaki bilgileri kullanıyoruz:</p>
|
|
182
|
+
<pre>API Key: ${nowpaymentsConfig.apiKey.substring(0, 10)}...
|
|
183
|
+
Ortam: ${nowpaymentsConfig.sandbox ? 'Sandbox (test)' : 'Production (canlı)'}</pre>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div class="verify-form">
|
|
187
|
+
<h3>Ödeme Durumu Sorgulama</h3>
|
|
188
|
+
<p>NOWPayments ödeme ID'si ile durumu kontrol edin:</p>
|
|
189
|
+
<input type="text" id="paymentId" placeholder="Ödeme ID'si girin">
|
|
190
|
+
<button id="check-status-btn">Sorgula</button>
|
|
191
|
+
<div id="statusResult"></div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<script>
|
|
195
|
+
// DOM yüklendikten sonra çalıştırılacak fonksiyonlar
|
|
196
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
197
|
+
// Ödeme oluşturma butonu click event'i
|
|
198
|
+
document.getElementById('create-payment-btn').addEventListener('click', function() {
|
|
199
|
+
document.getElementById('result').innerHTML = '<p>Ödeme oluşturuluyor...</p>';
|
|
200
|
+
|
|
201
|
+
fetch('/create-payment')
|
|
202
|
+
.then(response => response.json())
|
|
203
|
+
.then(data => {
|
|
204
|
+
if (data.status === 'success') {
|
|
205
|
+
let html = \`
|
|
206
|
+
<h3>Kripto Ödeme Bağlantısı Oluşturuldu</h3>
|
|
207
|
+
<p>Ödeme ID: \${data.data.id}</p>
|
|
208
|
+
<p>Sipariş ID: \${data.data.orderId}</p>
|
|
209
|
+
<p>Ödeme URL: <a href="\${data.data.url}" target="_blank">\${data.data.url}</a></p>
|
|
210
|
+
\`;
|
|
211
|
+
|
|
212
|
+
if (data.data.payAmount && data.data.payCurrency) {
|
|
213
|
+
html += \`<p>Ödeme miktarı: \${data.data.payAmount} \${data.data.payCurrency}</p>\`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (data.data.payAddress) {
|
|
217
|
+
html += \`<p>Ödeme adresi: \${data.data.payAddress}</p>\`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (data.data.qr) {
|
|
221
|
+
html += \`<p>QR Kod:</p><img src="\${data.data.qr}" width="200" />\`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
document.getElementById('result').innerHTML = html;
|
|
225
|
+
} else {
|
|
226
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + data.message + '</p>';
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.catch(error => {
|
|
230
|
+
document.getElementById('result').innerHTML = '<p class="error">Hata: ' + error + '</p>';
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Durum sorgulama butonu click event'i
|
|
235
|
+
document.getElementById('check-status-btn').addEventListener('click', function() {
|
|
236
|
+
const paymentId = document.getElementById('paymentId').value.trim();
|
|
237
|
+
if (!paymentId) {
|
|
238
|
+
alert('Lütfen bir ödeme ID\\'si girin');
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
document.getElementById('statusResult').innerHTML = '<p>Ödeme durumu sorgulanıyor...</p>';
|
|
243
|
+
|
|
244
|
+
fetch(\`/payment-status/\${paymentId}\`)
|
|
245
|
+
.then(response => response.json())
|
|
246
|
+
.then(data => {
|
|
247
|
+
let html = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
|
248
|
+
document.getElementById('statusResult').innerHTML = html;
|
|
249
|
+
})
|
|
250
|
+
.catch(error => {
|
|
251
|
+
document.getElementById('statusResult').innerHTML = '<p class="error">Hata: ' + error + '</p>';
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
</script>
|
|
256
|
+
</body>
|
|
257
|
+
</html>
|
|
258
|
+
`);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// API endpoint - yeni ödeme oluşturma
|
|
262
|
+
app.get('/create-payment', async (req, res) => {
|
|
263
|
+
try {
|
|
264
|
+
const result = await createPaymentExample();
|
|
265
|
+
res.json(result);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
res.status(400).json({ status: 'error', message: error.message });
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Test sunucusunu başlat
|
|
272
|
+
const PORT = 80;
|
|
273
|
+
app.listen(PORT, () => {
|
|
274
|
+
console.log(`🚀 Test sunucusu başlatıldı: http://localhost:${PORT}`);
|
|
275
|
+
console.log(`🔔 Webhook URL: http://localhost:${PORT}/webhook/nowpayments`);
|
|
276
|
+
console.log('⚠️ NOWPayments Entegrasyon Ayarları:');
|
|
277
|
+
console.log(` - API Key: ${nowpaymentsConfig.apiKey.substring(0, 10)}...`);
|
|
278
|
+
console.log(` - IPN Secret: ${nowpaymentsConfig.ipnSecret ? (nowpaymentsConfig.ipnSecret.substring(0, 10) + '...') : 'Ayarlanmadı'}`);
|
|
279
|
+
console.log(` - Ortam: ${nowpaymentsConfig.sandbox ? 'Sandbox (Test)' : 'Production (Canlı)'}`);
|
|
280
|
+
|
|
281
|
+
console.log('⚠️ Not: Gerçek ortamda, webhook URL\'inizi NOWPayments panelinde ayarlayın');
|
|
282
|
+
console.log('⚠️ Ayrıca, example-nowpayments.js dosyasındaki API anahtarını ve webhook secret\'ı kendi değerlerinizle değiştirmeyi unutmayın');
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Sunucuyu kapatmak için CTRL+C
|
|
286
|
+
process.on('SIGINT', () => {
|
|
287
|
+
console.log('Test sunucusu kapatılıyor...');
|
|
288
|
+
process.exit(0);
|
|
289
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const OmiseClient = require('../lib/omise');
|
|
2
|
+
|
|
3
|
+
const client = new OmiseClient({
|
|
4
|
+
publicKey: 'YOUR_PUBLIC_KEY',
|
|
5
|
+
secretKey: 'YOUR_SECRET_KEY'
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
async function example() {
|
|
9
|
+
try {
|
|
10
|
+
const payment = await client.createPayment({
|
|
11
|
+
amount: 1000,
|
|
12
|
+
orderId: 'TEST-001',
|
|
13
|
+
currency: 'THB',
|
|
14
|
+
sourceType: 'promptpay',
|
|
15
|
+
callback_link: 'https://yoursite.com/callback',
|
|
16
|
+
name: 'Somchai Prasert',
|
|
17
|
+
email: 'somchai@example.com'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('Payment URL:', payment.data.url);
|
|
21
|
+
console.log('Charge ID:', payment.data.id);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error:', error.message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
example();
|