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,78 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const TwoCheckoutClient = require('../lib/2checkout');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// 2Checkout yapılandırması
|
|
10
|
+
const twoCheckoutClient = new TwoCheckoutClient({
|
|
11
|
+
merchantCode: 'YOUR_MERCHANT_CODE',
|
|
12
|
+
secretKey: 'YOUR_SECRET_KEY',
|
|
13
|
+
sandbox: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Ödeme oluşturma
|
|
17
|
+
app.get('/create-payment', async (req, res) => {
|
|
18
|
+
try {
|
|
19
|
+
const payment = await twoCheckoutClient.createPayment({
|
|
20
|
+
amount: 100.00,
|
|
21
|
+
currency: 'USD',
|
|
22
|
+
orderId: `ORDER-${Date.now()}`,
|
|
23
|
+
name: 'Test Product',
|
|
24
|
+
description: 'Test payment description',
|
|
25
|
+
email: 'customer@example.com',
|
|
26
|
+
customerName: 'John Doe',
|
|
27
|
+
customerId: 'CUST123',
|
|
28
|
+
callback_link: 'http://localhost:3000/callback',
|
|
29
|
+
successUrl: 'http://localhost:3000/success',
|
|
30
|
+
sandbox: true
|
|
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
|
+
// IPN Callback endpoint
|
|
44
|
+
app.post('/callback', async (req, res) => {
|
|
45
|
+
try {
|
|
46
|
+
console.log('IPN received:', req.body);
|
|
47
|
+
|
|
48
|
+
const result = await twoCheckoutClient.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('Transaction ID:', result.transactionId);
|
|
57
|
+
console.log('Amount:', result.amount, result.currency);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 2Checkout expects XML response
|
|
61
|
+
res.set('Content-Type', 'application/xml');
|
|
62
|
+
res.send('<IPN_RESPONSE><DATE>' + new Date().toISOString() + '</DATE></IPN_RESPONSE>');
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Callback error:', error.message);
|
|
65
|
+
res.status(400).send('ERROR');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Başarı sayfası
|
|
70
|
+
app.get('/success', (req, res) => {
|
|
71
|
+
res.send('<h1>Payment Successful!</h1><p>Thank you for your purchase.</p>');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const PORT = 3000;
|
|
75
|
+
app.listen(PORT, () => {
|
|
76
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
77
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
78
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const BitPayClient = require('../lib/bitpay');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// BitPay yapılandırması
|
|
10
|
+
const bitpayClient = new BitPayClient({
|
|
11
|
+
apiToken: 'YOUR_API_TOKEN',
|
|
12
|
+
environment: 'test' // 'test' veya 'prod'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ödeme oluşturma
|
|
16
|
+
app.get('/create-payment', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const payment = await bitpayClient.createPayment({
|
|
19
|
+
amount: 100.00,
|
|
20
|
+
currency: 'USD',
|
|
21
|
+
orderId: `ORDER-${Date.now()}`,
|
|
22
|
+
name: 'Test Product',
|
|
23
|
+
description: 'Test payment description',
|
|
24
|
+
email: 'customer@example.com',
|
|
25
|
+
callback_link: 'http://localhost:3000/callback',
|
|
26
|
+
successUrl: 'http://localhost:3000/success',
|
|
27
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
console.log('Invoice created:', payment);
|
|
31
|
+
|
|
32
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
33
|
+
res.redirect(payment.data.url);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error:', error.message);
|
|
36
|
+
res.status(500).json({ error: error.message });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Callback endpoint
|
|
41
|
+
app.post('/callback', async (req, res) => {
|
|
42
|
+
try {
|
|
43
|
+
console.log('Callback received:', req.body);
|
|
44
|
+
|
|
45
|
+
const result = await bitpayClient.handleCallback(req.body);
|
|
46
|
+
|
|
47
|
+
console.log('Payment result:', result);
|
|
48
|
+
|
|
49
|
+
if (result.status === 'success') {
|
|
50
|
+
// Ödeme başarılı
|
|
51
|
+
console.log('Payment successful!');
|
|
52
|
+
console.log('Order ID:', result.orderId);
|
|
53
|
+
console.log('Transaction ID:', result.transactionId);
|
|
54
|
+
console.log('Amount:', result.amount, result.currency);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
res.status(200).send('OK');
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Callback error:', error.message);
|
|
60
|
+
res.status(400).send('ERROR');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Invoice sorgulama
|
|
65
|
+
app.get('/invoice/:invoiceId', async (req, res) => {
|
|
66
|
+
try {
|
|
67
|
+
const invoice = await bitpayClient.getInvoice(req.params.invoiceId);
|
|
68
|
+
res.json(invoice);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
res.status(500).json({ error: error.message });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Başarı sayfası
|
|
75
|
+
app.get('/success', (req, res) => {
|
|
76
|
+
res.send('<h1>Payment Successful!</h1><p>Thank you for your cryptocurrency payment.</p>');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const PORT = 3000;
|
|
80
|
+
app.listen(PORT, () => {
|
|
81
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
82
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
83
|
+
});
|
|
@@ -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
|
+
cardcom: {
|
|
12
|
+
terminalNumber: 'your-terminal-number',
|
|
13
|
+
userName: 'your-username'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
app.use(quickPos.middleware());
|
|
19
|
+
|
|
20
|
+
// Payment form
|
|
21
|
+
app.get('/', (req, res) => {
|
|
22
|
+
res.send(`
|
|
23
|
+
<h1>Cardcom Payment Example (Israel)</h1>
|
|
24
|
+
<form action="/payment/cardcom" method="post">
|
|
25
|
+
<input type="text" name="amount" placeholder="Amount (ILS)" required>
|
|
26
|
+
<input type="email" name="email" placeholder="Email" required>
|
|
27
|
+
<input type="text" name="name" placeholder="Customer Name" required>
|
|
28
|
+
<input type="text" name="mobile" placeholder="Mobile" required>
|
|
29
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
30
|
+
<input type="text" name="description" placeholder="Description" required>
|
|
31
|
+
<button type="submit">Pay with Cardcom</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
|
+
customerName: req.body.name,
|
|
48
|
+
email: req.body.email,
|
|
49
|
+
mobile: req.body.mobile,
|
|
50
|
+
description: req.body.description,
|
|
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
|
+
redirectUrl: result.data.url,
|
|
59
|
+
lowProfileId: result.data.lowProfileId,
|
|
60
|
+
lowProfileCode: result.data.lowProfileCode
|
|
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('cardcom'), (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
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const CashfreeClient = require('../lib/cashfree');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// Cashfree yapılandırması
|
|
10
|
+
const cashfreeClient = new CashfreeClient({
|
|
11
|
+
appId: 'YOUR_APP_ID',
|
|
12
|
+
secretKey: 'YOUR_SECRET_KEY',
|
|
13
|
+
environment: 'sandbox' // 'sandbox' veya 'production'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Ödeme oluşturma
|
|
17
|
+
app.get('/create-payment', async (req, res) => {
|
|
18
|
+
try {
|
|
19
|
+
const payment = await cashfreeClient.createPayment({
|
|
20
|
+
amount: 1000.00,
|
|
21
|
+
currency: 'INR',
|
|
22
|
+
orderId: `order_${Date.now()}`,
|
|
23
|
+
customerId: `customer_${Date.now()}`,
|
|
24
|
+
name: 'John Doe',
|
|
25
|
+
customerName: 'John Doe',
|
|
26
|
+
email: 'customer@example.com',
|
|
27
|
+
phone: '9999999999',
|
|
28
|
+
description: 'Test payment',
|
|
29
|
+
callback_link: 'http://localhost:3000/callback',
|
|
30
|
+
successUrl: 'http://localhost:3000/success',
|
|
31
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
console.log('Order created:', payment);
|
|
35
|
+
|
|
36
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
37
|
+
res.redirect(payment.data.url);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error:', error.message);
|
|
40
|
+
res.status(500).json({ error: error.message });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Callback endpoint
|
|
45
|
+
app.post('/callback', async (req, res) => {
|
|
46
|
+
try {
|
|
47
|
+
console.log('Callback received:', req.body);
|
|
48
|
+
|
|
49
|
+
const result = await cashfreeClient.handleCallback(req.body);
|
|
50
|
+
|
|
51
|
+
console.log('Payment result:', result);
|
|
52
|
+
|
|
53
|
+
if (result.status === 'success') {
|
|
54
|
+
// Ödeme başarılı
|
|
55
|
+
console.log('Payment successful!');
|
|
56
|
+
console.log('Order ID:', result.orderId);
|
|
57
|
+
console.log('Transaction ID:', result.transactionId);
|
|
58
|
+
console.log('Amount:', result.amount, result.currency);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
res.status(200).send('OK');
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Callback error:', error.message);
|
|
64
|
+
res.status(400).send('ERROR');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Sipariş sorgulama
|
|
69
|
+
app.get('/order/:orderId', async (req, res) => {
|
|
70
|
+
try {
|
|
71
|
+
const order = await cashfreeClient.getOrder(req.params.orderId);
|
|
72
|
+
res.json(order);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
res.status(500).json({ error: error.message });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Ödemeleri sorgulama
|
|
79
|
+
app.get('/payments/:orderId', async (req, res) => {
|
|
80
|
+
try {
|
|
81
|
+
const payments = await cashfreeClient.getPayments(req.params.orderId);
|
|
82
|
+
res.json(payments);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
res.status(500).json({ error: error.message });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// İade işlemi
|
|
89
|
+
app.post('/refund/:orderId', async (req, res) => {
|
|
90
|
+
try {
|
|
91
|
+
const refund = await cashfreeClient.refundPayment(req.params.orderId, {
|
|
92
|
+
amount: req.body.amount
|
|
93
|
+
});
|
|
94
|
+
res.json(refund);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
res.status(500).json({ error: error.message });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Başarı sayfası
|
|
101
|
+
app.get('/success', (req, res) => {
|
|
102
|
+
res.send('<h1>Payment Successful!</h1><p>भुगतान के लिए धन्यवाद।</p>');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const PORT = 3000;
|
|
106
|
+
app.listen(PORT, () => {
|
|
107
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
108
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
109
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
checkout: {
|
|
12
|
+
secretKey: 'your-secret-key',
|
|
13
|
+
publicKey: 'your-public-key',
|
|
14
|
+
sandbox: true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
app.use(quickPos.middleware());
|
|
20
|
+
|
|
21
|
+
// Payment form
|
|
22
|
+
app.get('/', (req, res) => {
|
|
23
|
+
res.send(`
|
|
24
|
+
<h1>Checkout.com Payment Example</h1>
|
|
25
|
+
<form action="/payment/checkout" 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="Customer Name" required>
|
|
29
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
30
|
+
<select name="currency">
|
|
31
|
+
<option value="USD">USD</option>
|
|
32
|
+
<option value="EUR">EUR</option>
|
|
33
|
+
<option value="GBP">GBP</option>
|
|
34
|
+
</select>
|
|
35
|
+
<button type="submit">Create Payment Link</button>
|
|
36
|
+
</form>
|
|
37
|
+
`);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Create payment
|
|
41
|
+
app.post('/payment/:provider', async (req, res) => {
|
|
42
|
+
const { provider } = req.params;
|
|
43
|
+
|
|
44
|
+
if (!req.quickPos[provider]) {
|
|
45
|
+
return res.status(400).json({ error: 'Invalid payment provider' });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const result = await req.quickPos[provider].createPayment({
|
|
50
|
+
amount: req.body.amount,
|
|
51
|
+
currency: req.body.currency || 'USD',
|
|
52
|
+
customerEmail: req.body.email,
|
|
53
|
+
customerName: req.body.name,
|
|
54
|
+
orderId: req.body.orderId,
|
|
55
|
+
name: 'Test Product',
|
|
56
|
+
useHostedPage: true, // Use hosted payment page
|
|
57
|
+
callback_link: `http://localhost:3000/payment-callback/${provider}`
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (result.status === 'success') {
|
|
61
|
+
res.json({
|
|
62
|
+
success: true,
|
|
63
|
+
redirectUrl: result.data.url,
|
|
64
|
+
paymentId: result.data.id,
|
|
65
|
+
expiresOn: result.data.expiresOn
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
res.status(400).json(result);
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
res.status(500).json({ error: error.message });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Payment webhook
|
|
76
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('checkout'), (req, res) => {
|
|
77
|
+
console.log('Payment result:', req.paymentResult);
|
|
78
|
+
res.json({ success: true, data: req.paymentResult });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const PORT = process.env.PORT || 3000;
|
|
82
|
+
app.listen(PORT, () => {
|
|
83
|
+
console.log(`Server is running on port ${PORT}`);
|
|
84
|
+
console.log(`Open http://localhost:${PORT} to test`);
|
|
85
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const CoinGateClient = require('../lib/coingate');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// CoinGate yapılandırması
|
|
10
|
+
const coingateClient = new CoinGateClient({
|
|
11
|
+
apiKey: 'YOUR_API_KEY',
|
|
12
|
+
environment: 'sandbox' // 'sandbox' veya 'live'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ödeme oluşturma
|
|
16
|
+
app.get('/create-payment', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const payment = await coingateClient.createPayment({
|
|
19
|
+
amount: 100.00,
|
|
20
|
+
currency: 'USD',
|
|
21
|
+
receiveCurrency: 'EUR', // Almak istediğiniz para birimi
|
|
22
|
+
orderId: `ORDER-${Date.now()}`,
|
|
23
|
+
title: 'Test Product',
|
|
24
|
+
description: 'Test cryptocurrency payment',
|
|
25
|
+
email: 'customer@example.com',
|
|
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 coingateClient.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('Paid:', result.payAmount, result.payCurrency);
|
|
57
|
+
console.log('Received:', result.receiveAmount, result.receiveCurrency);
|
|
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
|
+
// Sipariş sorgulama
|
|
68
|
+
app.get('/order/:orderId', async (req, res) => {
|
|
69
|
+
try {
|
|
70
|
+
const order = await coingateClient.getOrder(req.params.orderId);
|
|
71
|
+
res.json(order);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
res.status(500).json({ error: error.message });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Exchange rate sorgulama
|
|
78
|
+
app.get('/rate/:from/:to', async (req, res) => {
|
|
79
|
+
try {
|
|
80
|
+
const rate = await coingateClient.getExchangeRate(req.params.from, req.params.to);
|
|
81
|
+
res.json({ rate });
|
|
82
|
+
} catch (error) {
|
|
83
|
+
res.status(500).json({ error: error.message });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Başarı sayfası
|
|
88
|
+
app.get('/success', (req, res) => {
|
|
89
|
+
res.send('<h1>Payment Successful!</h1><p>Thank you for your cryptocurrency payment.</p>');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Hata sayfası
|
|
93
|
+
app.get('/fail', (req, res) => {
|
|
94
|
+
res.send('<h1>Payment Failed</h1><p>Your payment could not be processed.</p>');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const PORT = 3000;
|
|
98
|
+
app.listen(PORT, () => {
|
|
99
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
100
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
101
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
coinpayments: {
|
|
12
|
+
publicKey: 'your-public-key',
|
|
13
|
+
privateKey: 'your-private-key',
|
|
14
|
+
ipnSecret: 'your-ipn-secret'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
app.use(quickPos.middleware());
|
|
20
|
+
|
|
21
|
+
// Payment form
|
|
22
|
+
app.get('/', (req, res) => {
|
|
23
|
+
res.send(`
|
|
24
|
+
<h1>CoinPayments Crypto Payment Example</h1>
|
|
25
|
+
<form action="/payment/coinpayments" method="post">
|
|
26
|
+
<input type="text" name="amount" placeholder="Amount (USD)" required>
|
|
27
|
+
<input type="email" name="email" placeholder="Email" required>
|
|
28
|
+
<input type="text" name="name" placeholder="Name" required>
|
|
29
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
30
|
+
<select name="currency2">
|
|
31
|
+
<option value="BTC">Bitcoin (BTC)</option>
|
|
32
|
+
<option value="ETH">Ethereum (ETH)</option>
|
|
33
|
+
<option value="LTCT">Litecoin Test (LTCT)</option>
|
|
34
|
+
<option value="LTC">Litecoin (LTC)</option>
|
|
35
|
+
</select>
|
|
36
|
+
<button type="submit">Pay with CoinPayments</button>
|
|
37
|
+
</form>
|
|
38
|
+
`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Create payment
|
|
42
|
+
app.post('/payment/:provider', async (req, res) => {
|
|
43
|
+
const { provider } = req.params;
|
|
44
|
+
|
|
45
|
+
if (!req.quickPos[provider]) {
|
|
46
|
+
return res.status(400).json({ error: 'Invalid payment provider' });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const result = await req.quickPos[provider].createPayment({
|
|
51
|
+
amount: req.body.amount,
|
|
52
|
+
currency1: 'USD',
|
|
53
|
+
currency2: req.body.currency2 || 'BTC',
|
|
54
|
+
buyerEmail: req.body.email,
|
|
55
|
+
buyerName: req.body.name,
|
|
56
|
+
itemName: 'Test Product',
|
|
57
|
+
orderId: req.body.orderId,
|
|
58
|
+
callback_link: `http://localhost:3000/payment-callback/${provider}`
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (result.status === 'success') {
|
|
62
|
+
res.json({
|
|
63
|
+
success: true,
|
|
64
|
+
txnId: result.data.txnId,
|
|
65
|
+
address: result.data.address,
|
|
66
|
+
amount: result.data.amount,
|
|
67
|
+
qrcodeUrl: result.data.qrcodeUrl,
|
|
68
|
+
statusUrl: result.data.statusUrl,
|
|
69
|
+
checkoutUrl: result.data.url
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
res.status(400).json(result);
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
res.status(500).json({ error: error.message });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Payment IPN callback
|
|
80
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('coinpayments'), (req, res) => {
|
|
81
|
+
console.log('Payment result:', req.paymentResult);
|
|
82
|
+
res.json({ success: true, data: req.paymentResult });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const PORT = process.env.PORT || 3000;
|
|
86
|
+
app.listen(PORT, () => {
|
|
87
|
+
console.log(`Server is running on port ${PORT}`);
|
|
88
|
+
console.log(`Open http://localhost:${PORT} to test`);
|
|
89
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DokuClient = require('../lib/doku');
|
|
2
|
+
|
|
3
|
+
const client = new DokuClient({
|
|
4
|
+
clientId: 'YOUR_CLIENT_ID',
|
|
5
|
+
secretKey: 'YOUR_SECRET_KEY',
|
|
6
|
+
sharedKey: 'YOUR_SHARED_KEY',
|
|
7
|
+
sandbox: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function example() {
|
|
11
|
+
try {
|
|
12
|
+
const payment = await client.createPayment({
|
|
13
|
+
amount: 50000,
|
|
14
|
+
orderId: 'TEST-001',
|
|
15
|
+
callback_link: 'https://yoursite.com/callback',
|
|
16
|
+
name: 'Test Payment',
|
|
17
|
+
email: 'customer@example.com'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('Payment URL:', payment.data.url);
|
|
21
|
+
console.log('Payment Code:', payment.data.paymentCode);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error:', error.message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
example();
|