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,200 @@
|
|
|
1
|
+
const PayPal = require('./lib/paypal');
|
|
2
|
+
const QuickPos = require('./app');
|
|
3
|
+
const express = require('express');
|
|
4
|
+
const bodyParser = require('body-parser');
|
|
5
|
+
|
|
6
|
+
// QuickPos yapılandırması
|
|
7
|
+
const quickPos = new QuickPos({
|
|
8
|
+
providers: {
|
|
9
|
+
paypal: {
|
|
10
|
+
environment: 'sandbox',
|
|
11
|
+
merchantId: 'rd8zm2zmqgt3sm2h',
|
|
12
|
+
publicKey: 'zhpbyq9tr997dvvp',
|
|
13
|
+
privateKey: '',
|
|
14
|
+
paypalEmail: 'sb-jzsll25277773@business.example.com'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// PayPal sağlayıcısını al
|
|
20
|
+
let paypal = quickPos.providers['paypal'];
|
|
21
|
+
|
|
22
|
+
// Express uygulaması oluştur
|
|
23
|
+
const app = express();
|
|
24
|
+
app.use(bodyParser.json());
|
|
25
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
26
|
+
app.use(express.static('public'));
|
|
27
|
+
|
|
28
|
+
// Ana sayfa - Basit form
|
|
29
|
+
app.get('/', (req, res) => {
|
|
30
|
+
res.send(`
|
|
31
|
+
<!DOCTYPE html>
|
|
32
|
+
<html>
|
|
33
|
+
<head>
|
|
34
|
+
<title>Ödeme</title>
|
|
35
|
+
<meta charset="UTF-8">
|
|
36
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
37
|
+
<style>
|
|
38
|
+
body { font-family: Arial; margin: 0; padding: 20px; background: #f5f5f5; }
|
|
39
|
+
.container { max-width: 500px; margin: 0 auto; background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
|
40
|
+
h1 { margin-top: 0; }
|
|
41
|
+
label { display: block; margin-bottom: 5px; }
|
|
42
|
+
input, select { width: 100%; padding: 8px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 3px; }
|
|
43
|
+
button { background: #4a7aff; color: white; border: none; padding: 10px 15px; border-radius: 3px; cursor: pointer; width: 100%; }
|
|
44
|
+
</style>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<div class="container">
|
|
48
|
+
<h1>Ödeme Oluştur</h1>
|
|
49
|
+
<form action="/checkout" method="GET">
|
|
50
|
+
<label for="amount">Tutar:</label>
|
|
51
|
+
<input type="text" id="amount" name="amount" value="99.99" required>
|
|
52
|
+
|
|
53
|
+
<label for="currency">Para Birimi:</label>
|
|
54
|
+
<select id="currency" name="currency">
|
|
55
|
+
<option value="USD">USD - Amerikan Doları</option>
|
|
56
|
+
<option value="EUR">EUR - Euro</option>
|
|
57
|
+
<option value="TRY">TRY - Türk Lirası</option>
|
|
58
|
+
</select>
|
|
59
|
+
|
|
60
|
+
<label for="description">Açıklama:</label>
|
|
61
|
+
<input type="text" id="description" name="description" value="Premium Üyelik" required>
|
|
62
|
+
|
|
63
|
+
<button type="submit">Ödeme Sayfasına Git</button>
|
|
64
|
+
</form>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
68
|
+
`);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Ödeme sayfası - renderHtmlCheckout metodunu kullanır
|
|
72
|
+
app.get('/checkout', async (req, res) => {
|
|
73
|
+
try {
|
|
74
|
+
const { amount, currency, description } = req.query;
|
|
75
|
+
|
|
76
|
+
// HTML sayfasını renderla
|
|
77
|
+
const html = await paypal.renderHtmlCheckout({
|
|
78
|
+
amount: amount || '99.99',
|
|
79
|
+
currency: currency || 'USD',
|
|
80
|
+
description: description || 'Premium Üyelik',
|
|
81
|
+
orderId: 'order-' + Date.now(),
|
|
82
|
+
successUrl: `http://${req.headers.host}/success`,
|
|
83
|
+
cancelUrl: `http://${req.headers.host}/cancel`
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
res.send(html);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
res.status(500).send(`
|
|
89
|
+
<div style="text-align:center; padding:20px;">
|
|
90
|
+
<h1>Hata</h1>
|
|
91
|
+
<p>${error.message}</p>
|
|
92
|
+
<a href="/">Geri Dön</a>
|
|
93
|
+
</div>
|
|
94
|
+
`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// İptal sayfası - basit HTML
|
|
99
|
+
app.get('/cancel', (req, res) => {
|
|
100
|
+
res.send(`
|
|
101
|
+
<div style="text-align:center; padding:20px;">
|
|
102
|
+
<h1>Ödeme İptal Edildi</h1>
|
|
103
|
+
<p>İşlem iptal edildi, herhangi bir ücret tahsil edilmedi.</p>
|
|
104
|
+
<a href="/">Geri Dön</a>
|
|
105
|
+
</div>
|
|
106
|
+
`);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Ödeme doğrulama fonksiyonu
|
|
110
|
+
async function verifyPayment(paymentDetails) {
|
|
111
|
+
try {
|
|
112
|
+
// PayPal API ile ödeme doğrulama
|
|
113
|
+
const verificationResult = await paypal.verifyPayment(paymentDetails);
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
verified: verificationResult.verified,
|
|
117
|
+
details: verificationResult.details
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('Ödeme doğrulama hatası:', error);
|
|
121
|
+
return {
|
|
122
|
+
success: false,
|
|
123
|
+
error: error.message
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Başarılı ödeme sayfası - doğrulama ile birlikte
|
|
129
|
+
app.get('/success', async (req, res) => {
|
|
130
|
+
const { order_id, PayerID, paymentId } = req.query;
|
|
131
|
+
|
|
132
|
+
// Ödeme doğrulama işlemi
|
|
133
|
+
const verification = await verifyPayment({
|
|
134
|
+
orderId: order_id,
|
|
135
|
+
payerId: PayerID,
|
|
136
|
+
paymentId: paymentId
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (verification.success && verification.verified) {
|
|
140
|
+
res.send(`
|
|
141
|
+
<div style="text-align:center; padding:20px;">
|
|
142
|
+
<h1>Ödeme Başarılı ve Doğrulandı</h1>
|
|
143
|
+
<p>Sipariş ID: ${order_id || 'N/A'}</p>
|
|
144
|
+
<p>Ödeme ID: ${paymentId || 'N/A'}</p>
|
|
145
|
+
<p>Ödeme Yapan ID: ${PayerID || 'N/A'}</p>
|
|
146
|
+
<p style="color:green; font-weight:bold;">Ödeme durumu: Doğrulanmış</p>
|
|
147
|
+
<p>İşlem tarihi: ${new Date().toLocaleString('tr-TR')}</p>
|
|
148
|
+
<a href="/">Yeni Ödeme</a>
|
|
149
|
+
</div>
|
|
150
|
+
`);
|
|
151
|
+
} else {
|
|
152
|
+
res.send(`
|
|
153
|
+
<div style="text-align:center; padding:20px;">
|
|
154
|
+
<h1>Ödeme Bilgisi Alındı</h1>
|
|
155
|
+
<p>Sipariş ID: ${order_id || 'N/A'}</p>
|
|
156
|
+
<p>Ödeme ID: ${paymentId || 'N/A'}</p>
|
|
157
|
+
<p>Ödeme Yapan ID: ${PayerID || 'N/A'}</p>
|
|
158
|
+
<p style="color:orange; font-weight:bold;">Ödeme durumu: Doğrulanamadı</p>
|
|
159
|
+
<p>Hata: ${verification.error || 'Bilinmeyen doğrulama hatası'}</p>
|
|
160
|
+
<a href="/">Geri Dön</a>
|
|
161
|
+
</div>
|
|
162
|
+
`);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// PayPal webhook handler - IPN (Instant Payment Notification) için
|
|
167
|
+
app.post('/paypal-webhook', bodyParser.raw({ type: 'application/json' }), async (req, res) => {
|
|
168
|
+
try {
|
|
169
|
+
// PayPal'dan gelen webhook bildirimi doğrulama
|
|
170
|
+
const event = req.body;
|
|
171
|
+
const isVerified = await paypal.verifyWebhook(event);
|
|
172
|
+
|
|
173
|
+
if (isVerified) {
|
|
174
|
+
console.log('PayPal webhook olayı doğrulandı:', event);
|
|
175
|
+
|
|
176
|
+
// Olay tipine göre işlem yapabilirsiniz
|
|
177
|
+
// Örneğin: payment.capture.completed, payment.capture.denied, vb.
|
|
178
|
+
const eventType = event.event_type;
|
|
179
|
+
if (eventType === 'PAYMENT.CAPTURE.COMPLETED') {
|
|
180
|
+
// Ödeme tamamlandı - veritabanını güncelleyebilir veya email gönderebilirsiniz
|
|
181
|
+
console.log('Ödeme başarıyla tamamlandı:', event.resource);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
res.status(200).send('OK');
|
|
185
|
+
} else {
|
|
186
|
+
console.warn('Geçersiz PayPal webhook bildirimi');
|
|
187
|
+
res.status(400).send('Geçersiz bildirim');
|
|
188
|
+
}
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error('Webhook işleme hatası:', error);
|
|
191
|
+
res.status(500).send('Webhook işleme hatası');
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Sunucuyu başlat
|
|
196
|
+
const PORT = process.env.PORT || 3000;
|
|
197
|
+
app.listen(PORT, () => {
|
|
198
|
+
console.log(`Sunucu çalışıyor: http://localhost:${PORT}`);
|
|
199
|
+
console.log(`Örnek ödeme sayfası: http://localhost:${PORT}`);
|
|
200
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const PayriffClient = require('../lib/payriff');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// Payriff yapılandırması
|
|
10
|
+
const payriffClient = new PayriffClient({
|
|
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 payriffClient.createPayment({
|
|
19
|
+
amount: 50.00,
|
|
20
|
+
currency: 'AZN',
|
|
21
|
+
orderId: `ORDER-${Date.now()}`,
|
|
22
|
+
name: 'Test Product',
|
|
23
|
+
description: 'Test payment description',
|
|
24
|
+
language: 'AZ',
|
|
25
|
+
callback_link: 'http://localhost:3000/callback',
|
|
26
|
+
successUrl: 'http://localhost:3000/success',
|
|
27
|
+
failUrl: 'http://localhost:3000/fail',
|
|
28
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('Payment created:', payment);
|
|
32
|
+
|
|
33
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
34
|
+
res.redirect(payment.data.url);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Error:', error.message);
|
|
37
|
+
res.status(500).json({ error: error.message });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Callback endpoint
|
|
42
|
+
app.post('/callback', async (req, res) => {
|
|
43
|
+
try {
|
|
44
|
+
console.log('Callback received:', req.body);
|
|
45
|
+
|
|
46
|
+
const result = await payriffClient.handleCallback(req.body);
|
|
47
|
+
|
|
48
|
+
console.log('Payment result:', result);
|
|
49
|
+
|
|
50
|
+
if (result.status === 'success') {
|
|
51
|
+
// Ödeme başarılı
|
|
52
|
+
console.log('Payment successful!');
|
|
53
|
+
console.log('Order ID:', result.orderId);
|
|
54
|
+
console.log('Transaction ID:', result.transactionId);
|
|
55
|
+
console.log('Amount:', result.amount, result.currency);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
res.status(200).send('OK');
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('Callback error:', error.message);
|
|
61
|
+
res.status(400).send('ERROR');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Sipariş durumu sorgulama
|
|
66
|
+
app.get('/order-status/:orderId', async (req, res) => {
|
|
67
|
+
try {
|
|
68
|
+
const status = await payriffClient.getOrderStatus(req.params.orderId);
|
|
69
|
+
res.json(status);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
res.status(500).json({ error: error.message });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Başarı sayfası
|
|
76
|
+
app.get('/success', (req, res) => {
|
|
77
|
+
res.send('<h1>Ödəniş Uğurlu!</h1><p>Ödənişiniz üçün təşəkkür edirik.</p>');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Hata sayfası
|
|
81
|
+
app.get('/fail', (req, res) => {
|
|
82
|
+
res.send('<h1>Ödəniş Uğursuz</h1><p>Ödənişiniz icra oluna bilmədi.</p>');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const PORT = 3000;
|
|
86
|
+
app.listen(PORT, () => {
|
|
87
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
88
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
89
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
paysend: {
|
|
12
|
+
apiKey: 'your-api-key',
|
|
13
|
+
sandbox: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
app.use(quickPos.middleware());
|
|
19
|
+
|
|
20
|
+
// Payment form
|
|
21
|
+
app.get('/', (req, res) => {
|
|
22
|
+
res.send(`
|
|
23
|
+
<h1>Paysend Transfer Example</h1>
|
|
24
|
+
<form action="/payment/paysend" method="post">
|
|
25
|
+
<input type="text" name="amount" placeholder="Amount" required>
|
|
26
|
+
<input type="text" name="currency" placeholder="Currency (USD, EUR, GBP)" required>
|
|
27
|
+
<input type="text" name="cardNumber" placeholder="Recipient Card Number" required>
|
|
28
|
+
<input type="text" name="recipientName" placeholder="Recipient Name" required>
|
|
29
|
+
<input type="email" name="email" placeholder="Your Email" required>
|
|
30
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
31
|
+
<button type="submit">Send Money</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
|
+
amount: req.body.amount,
|
|
47
|
+
currency: req.body.currency || 'USD',
|
|
48
|
+
cardNumber: req.body.cardNumber,
|
|
49
|
+
recipientName: req.body.recipientName,
|
|
50
|
+
senderEmail: req.body.email,
|
|
51
|
+
orderId: req.body.orderId,
|
|
52
|
+
callback_link: `http://localhost:3000/payment-callback/${provider}`
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (result.status === 'success') {
|
|
56
|
+
res.json({
|
|
57
|
+
success: true,
|
|
58
|
+
transferId: result.data.transferId,
|
|
59
|
+
status: result.data.status,
|
|
60
|
+
amount: result.data.amount,
|
|
61
|
+
currency: result.data.currency
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
res.status(400).json(result);
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
res.status(500).json({ error: error.message });
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Payment callback
|
|
72
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('paysend'), (req, res) => {
|
|
73
|
+
console.log('Transfer result:', req.paymentResult);
|
|
74
|
+
res.json({ success: true, data: req.paymentResult });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const PORT = process.env.PORT || 3000;
|
|
78
|
+
app.listen(PORT, () => {
|
|
79
|
+
console.log(`Server is running on port ${PORT}`);
|
|
80
|
+
console.log(`Open http://localhost:${PORT} to test`);
|
|
81
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const PaySpaceClient = require('../lib/payspace');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// PaySpace yapılandırması
|
|
10
|
+
const payspaceClient = new PaySpaceClient({
|
|
11
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
12
|
+
apiKey: 'YOUR_API_KEY'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ödeme oluşturma
|
|
16
|
+
app.get('/create-payment', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const payment = await payspaceClient.createPayment({
|
|
19
|
+
amount: 100.00,
|
|
20
|
+
currency: 'ZAR',
|
|
21
|
+
orderId: `ORDER-${Date.now()}`,
|
|
22
|
+
name: 'John Doe',
|
|
23
|
+
description: 'Test payment description',
|
|
24
|
+
email: 'customer@example.com',
|
|
25
|
+
phone: '+27123456789',
|
|
26
|
+
callback_link: 'http://localhost:3000/callback',
|
|
27
|
+
successUrl: 'http://localhost:3000/success',
|
|
28
|
+
failUrl: 'http://localhost:3000/fail',
|
|
29
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
console.log('Payment created:', payment);
|
|
33
|
+
|
|
34
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
35
|
+
res.redirect(payment.data.url);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error:', error.message);
|
|
38
|
+
res.status(500).json({ error: error.message });
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Callback endpoint
|
|
43
|
+
app.post('/callback', async (req, res) => {
|
|
44
|
+
try {
|
|
45
|
+
console.log('Callback received:', req.body);
|
|
46
|
+
|
|
47
|
+
const result = await payspaceClient.handleCallback(req.body);
|
|
48
|
+
|
|
49
|
+
console.log('Payment result:', result);
|
|
50
|
+
|
|
51
|
+
if (result.status === 'success') {
|
|
52
|
+
// Ödeme başarılı
|
|
53
|
+
console.log('Payment successful!');
|
|
54
|
+
console.log('Order ID:', result.orderId);
|
|
55
|
+
console.log('Transaction ID:', result.transactionId);
|
|
56
|
+
console.log('Amount:', result.amount, result.currency);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
res.status(200).send('OK');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Callback error:', error.message);
|
|
62
|
+
res.status(400).send('ERROR');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Ödeme durumu sorgulama
|
|
67
|
+
app.get('/payment-status/:paymentId', async (req, res) => {
|
|
68
|
+
try {
|
|
69
|
+
const status = await payspaceClient.getPaymentStatus(req.params.paymentId);
|
|
70
|
+
res.json(status);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
res.status(500).json({ error: error.message });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// İade işlemi
|
|
77
|
+
app.post('/refund/:paymentId', async (req, res) => {
|
|
78
|
+
try {
|
|
79
|
+
const refund = await payspaceClient.refundPayment(req.params.paymentId, {
|
|
80
|
+
amount: req.body.amount,
|
|
81
|
+
reason: req.body.reason || 'Customer request'
|
|
82
|
+
});
|
|
83
|
+
res.json(refund);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
res.status(500).json({ error: error.message });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Başarı sayfası
|
|
90
|
+
app.get('/success', (req, res) => {
|
|
91
|
+
res.send('<h1>Payment Successful!</h1><p>Thank you for your payment.</p>');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Hata sayfası
|
|
95
|
+
app.get('/fail', (req, res) => {
|
|
96
|
+
res.send('<h1>Payment Failed</h1><p>Your payment could not be processed.</p>');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const PORT = 3000;
|
|
100
|
+
app.listen(PORT, () => {
|
|
101
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
102
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
103
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const PayssionClient = require('../lib/payssion');
|
|
2
|
+
|
|
3
|
+
const client = new PayssionClient({
|
|
4
|
+
apiKey: 'YOUR_API_KEY',
|
|
5
|
+
secretKey: 'YOUR_SECRET_KEY',
|
|
6
|
+
sandbox: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function example() {
|
|
10
|
+
try {
|
|
11
|
+
const payment = await client.createPayment({
|
|
12
|
+
amount: 50,
|
|
13
|
+
orderId: 'TEST-001',
|
|
14
|
+
currency: 'USD',
|
|
15
|
+
paymentMethod: 'boleto_br',
|
|
16
|
+
callback_link: 'https://yoursite.com/callback',
|
|
17
|
+
name: 'Test Payment'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('Payment URL:', payment.data.url);
|
|
21
|
+
console.log('Transaction ID:', payment.data.transactionId);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error:', error.message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
example();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const PayTabsClient = require('../lib/paytabs');
|
|
2
|
+
|
|
3
|
+
const client = new PayTabsClient({
|
|
4
|
+
profileId: 'YOUR_PROFILE_ID',
|
|
5
|
+
serverKey: 'YOUR_SERVER_KEY',
|
|
6
|
+
region: 'ARE'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function example() {
|
|
10
|
+
try {
|
|
11
|
+
const payment = await client.createPayment({
|
|
12
|
+
amount: 100,
|
|
13
|
+
orderId: 'TEST-001',
|
|
14
|
+
currency: 'AED',
|
|
15
|
+
callback_link: 'https://yoursite.com/callback',
|
|
16
|
+
name: 'Ahmed Mohammed',
|
|
17
|
+
email: 'ahmed@example.com',
|
|
18
|
+
phone: '+971501234567'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log('Payment URL:', payment.data.url);
|
|
22
|
+
console.log('Transaction Ref:', payment.data.transactionRef);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
example();
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
paytm: {
|
|
12
|
+
merchantId: 'your-merchant-id',
|
|
13
|
+
merchantKey: 'your-merchant-key',
|
|
14
|
+
websiteName: 'WEBSTAGING', // or 'DEFAULT' for production
|
|
15
|
+
sandbox: true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
app.use(quickPos.middleware());
|
|
21
|
+
|
|
22
|
+
// Payment form
|
|
23
|
+
app.get('/', (req, res) => {
|
|
24
|
+
res.send(`
|
|
25
|
+
<h1>Paytm Payment Example (India)</h1>
|
|
26
|
+
<form action="/payment/paytm" method="post">
|
|
27
|
+
<input type="text" name="amount" placeholder="Amount (INR)" required>
|
|
28
|
+
<input type="email" name="email" placeholder="Email">
|
|
29
|
+
<input type="text" name="mobile" placeholder="Mobile (10 digits)">
|
|
30
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
31
|
+
<button type="submit">Pay with Paytm</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
|
+
amount: req.body.amount,
|
|
47
|
+
email: req.body.email,
|
|
48
|
+
mobile: req.body.mobile,
|
|
49
|
+
orderId: req.body.orderId,
|
|
50
|
+
callback_link: `http://localhost:3000/payment-callback/${provider}`
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (result.status === 'success') {
|
|
54
|
+
res.json({
|
|
55
|
+
success: true,
|
|
56
|
+
redirectUrl: result.data.url,
|
|
57
|
+
txnToken: result.data.txnToken,
|
|
58
|
+
orderId: result.data.orderId
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
res.status(400).json(result);
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
res.status(500).json({ error: error.message });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Payment callback
|
|
69
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('paytm'), (req, res) => {
|
|
70
|
+
console.log('Payment result:', req.paymentResult);
|
|
71
|
+
res.json({ success: true, data: req.paymentResult });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const PORT = process.env.PORT || 3000;
|
|
75
|
+
app.listen(PORT, () => {
|
|
76
|
+
console.log(`Server is running on port ${PORT}`);
|
|
77
|
+
console.log(`Open http://localhost:${PORT} to test`);
|
|
78
|
+
});
|