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,28 @@
|
|
|
1
|
+
const SenangPayClient = require('../lib/senangpay');
|
|
2
|
+
|
|
3
|
+
const client = new SenangPayClient({
|
|
4
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
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.00,
|
|
13
|
+
orderId: 'TEST-001',
|
|
14
|
+
callback_link: 'https://yoursite.com/callback',
|
|
15
|
+
name: 'Ahmad Abdullah',
|
|
16
|
+
email: 'ahmad@example.com',
|
|
17
|
+
phone: '0123456789',
|
|
18
|
+
description: 'Test Payment'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log('Payment URL:', payment.data.url);
|
|
22
|
+
console.log('Hash:', payment.data.hash);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
example();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const ShurjoPayClient = require('../lib/shurjopay');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// ShurjoPay yapılandırması
|
|
10
|
+
const shurjopayClient = new ShurjoPayClient({
|
|
11
|
+
username: 'YOUR_USERNAME',
|
|
12
|
+
password: 'YOUR_PASSWORD',
|
|
13
|
+
prefix: 'YOUR_PREFIX',
|
|
14
|
+
sandbox: true
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Ödeme oluşturma
|
|
18
|
+
app.get('/create-payment', async (req, res) => {
|
|
19
|
+
try {
|
|
20
|
+
const payment = await shurjopayClient.createPayment({
|
|
21
|
+
amount: 1000.00,
|
|
22
|
+
currency: 'BDT',
|
|
23
|
+
orderId: `ORDER-${Date.now()}`,
|
|
24
|
+
name: 'John Doe',
|
|
25
|
+
customerName: 'John Doe',
|
|
26
|
+
email: 'customer@example.com',
|
|
27
|
+
phone: '01711111111',
|
|
28
|
+
address: 'Dhaka, Bangladesh',
|
|
29
|
+
city: 'Dhaka',
|
|
30
|
+
callback_link: 'http://localhost:3000/callback',
|
|
31
|
+
successUrl: 'http://localhost:3000/success',
|
|
32
|
+
failUrl: 'http://localhost:3000/fail',
|
|
33
|
+
callbackUrl: 'http://localhost:3000/callback'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log('Payment created:', payment);
|
|
37
|
+
|
|
38
|
+
// Kullanıcıyı ödeme sayfasına yönlendir
|
|
39
|
+
res.redirect(payment.data.url);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error:', error.message);
|
|
42
|
+
res.status(500).json({ error: error.message });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Callback endpoint
|
|
47
|
+
app.post('/callback', async (req, res) => {
|
|
48
|
+
try {
|
|
49
|
+
console.log('Callback received:', req.body);
|
|
50
|
+
|
|
51
|
+
const result = await shurjopayClient.handleCallback(req.body);
|
|
52
|
+
|
|
53
|
+
console.log('Payment result:', result);
|
|
54
|
+
|
|
55
|
+
if (result.status === 'success') {
|
|
56
|
+
// Ödeme başarılı
|
|
57
|
+
console.log('Payment successful!');
|
|
58
|
+
console.log('Order ID:', result.orderId);
|
|
59
|
+
console.log('Transaction ID:', result.transactionId);
|
|
60
|
+
console.log('Amount:', result.amount, result.currency);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
res.status(200).send('OK');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('Callback error:', error.message);
|
|
66
|
+
res.status(400).send('ERROR');
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Ödeme doğrulama
|
|
71
|
+
app.get('/verify/:orderId', async (req, res) => {
|
|
72
|
+
try {
|
|
73
|
+
const verification = await shurjopayClient.verifyPayment(req.params.orderId);
|
|
74
|
+
res.json(verification);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
res.status(500).json({ error: error.message });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Başarı sayfası
|
|
81
|
+
app.get('/success', (req, res) => {
|
|
82
|
+
res.send('<h1>Payment Successful!</h1><p>ধন্যবাদ আপনার পেমেন্টের জন্য।</p>');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Hata sayfası
|
|
86
|
+
app.get('/fail', (req, res) => {
|
|
87
|
+
res.send('<h1>Payment Failed</h1><p>পেমেন্ট সম্পন্ন হয়নি। অনুগ্রহ করে আবার চেষ্টা করুন।</p>');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const PORT = 3000;
|
|
91
|
+
app.listen(PORT, () => {
|
|
92
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
93
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
94
|
+
});
|
|
@@ -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
|
+
toyyibpay: {
|
|
12
|
+
secretKey: 'your-secret-key',
|
|
13
|
+
categoryCode: 'your-category-code'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
app.use(quickPos.middleware());
|
|
19
|
+
|
|
20
|
+
// Payment form
|
|
21
|
+
app.get('/', (req, res) => {
|
|
22
|
+
res.send(`
|
|
23
|
+
<h1>ToyyibPay Payment Example</h1>
|
|
24
|
+
<form action="/payment/toyyibpay" method="post">
|
|
25
|
+
<input type="text" name="amount" placeholder="Amount (MYR)" 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="phone" placeholder="Phone (60XXXXXXXXX)" required>
|
|
29
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
30
|
+
<input type="text" name="description" placeholder="Bill Description" required>
|
|
31
|
+
<button type="submit">Pay with ToyyibPay</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
|
+
billName: req.body.name || 'Bill Payment',
|
|
47
|
+
billDescription: req.body.description,
|
|
48
|
+
amount: req.body.amount,
|
|
49
|
+
email: req.body.email,
|
|
50
|
+
phone: req.body.phone,
|
|
51
|
+
customerName: req.body.name,
|
|
52
|
+
orderId: req.body.orderId,
|
|
53
|
+
callback_link: `http://localhost:3000/payment-callback/${provider}`
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (result.status === 'success') {
|
|
57
|
+
res.json({
|
|
58
|
+
success: true,
|
|
59
|
+
redirectUrl: result.data.url,
|
|
60
|
+
billCode: result.data.billCode
|
|
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('toyyibpay'), (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,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
|
+
tripay: {
|
|
12
|
+
apiKey: 'your-api-key',
|
|
13
|
+
privateKey: 'your-private-key',
|
|
14
|
+
merchantCode: 'your-merchant-code',
|
|
15
|
+
isProduction: false
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
app.use(quickPos.middleware());
|
|
21
|
+
|
|
22
|
+
// Payment form
|
|
23
|
+
app.get('/', (req, res) => {
|
|
24
|
+
res.send(`
|
|
25
|
+
<h1>Tripay Payment Example</h1>
|
|
26
|
+
<form action="/payment/tripay" method="post">
|
|
27
|
+
<input type="text" name="amount" placeholder="Amount (IDR)" required>
|
|
28
|
+
<input type="email" name="email" placeholder="Email" required>
|
|
29
|
+
<input type="text" name="name" placeholder="Customer Name" required>
|
|
30
|
+
<input type="text" name="phone" placeholder="Phone" required>
|
|
31
|
+
<input type="text" name="orderId" placeholder="Order ID" required>
|
|
32
|
+
<select name="paymentMethod">
|
|
33
|
+
<option value="BRIVA">BRI Virtual Account</option>
|
|
34
|
+
<option value="BNIVA">BNI Virtual Account</option>
|
|
35
|
+
<option value="MANDIRIVA">Mandiri Virtual Account</option>
|
|
36
|
+
<option value="QRIS">QRIS</option>
|
|
37
|
+
</select>
|
|
38
|
+
<button type="submit">Pay with Tripay</button>
|
|
39
|
+
</form>
|
|
40
|
+
`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Create payment
|
|
44
|
+
app.post('/payment/:provider', async (req, res) => {
|
|
45
|
+
const { provider } = req.params;
|
|
46
|
+
|
|
47
|
+
if (!req.quickPos[provider]) {
|
|
48
|
+
return res.status(400).json({ error: 'Invalid payment provider' });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const result = await req.quickPos[provider].createPayment({
|
|
53
|
+
name: req.body.name,
|
|
54
|
+
amount: req.body.amount,
|
|
55
|
+
email: req.body.email,
|
|
56
|
+
phone: req.body.phone,
|
|
57
|
+
orderId: req.body.orderId,
|
|
58
|
+
paymentMethod: req.body.paymentMethod || 'BRIVA',
|
|
59
|
+
callbackUrl: `http://localhost:3000/payment-callback/${provider}`,
|
|
60
|
+
itemName: 'Test Product'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (result.status === 'success') {
|
|
64
|
+
res.json({
|
|
65
|
+
success: true,
|
|
66
|
+
redirectUrl: result.data.paymentUrl,
|
|
67
|
+
reference: result.data.reference,
|
|
68
|
+
qrUrl: result.data.qrUrl,
|
|
69
|
+
instructions: result.data.instructions
|
|
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 callback
|
|
80
|
+
app.post('/payment-callback/:provider', quickPos.handleCallback('tripay'), (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,26 @@
|
|
|
1
|
+
const UnitpayClient = require('../lib/unitpay');
|
|
2
|
+
|
|
3
|
+
const client = new UnitpayClient({
|
|
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: 500,
|
|
12
|
+
orderId: 'TEST-001',
|
|
13
|
+
currency: 'RUB',
|
|
14
|
+
callback_link: 'https://yoursite.com/callback',
|
|
15
|
+
email: 'customer@example.com',
|
|
16
|
+
name: 'Test Payment'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log('Payment URL:', payment.data.url);
|
|
20
|
+
console.log('Account:', payment.data.account);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Error:', error.message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
example();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const URWayClient = require('../lib/urway');
|
|
2
|
+
|
|
3
|
+
const client = new URWayClient({
|
|
4
|
+
terminalId: 'YOUR_TERMINAL_ID',
|
|
5
|
+
password: 'YOUR_PASSWORD',
|
|
6
|
+
merchantKey: 'YOUR_MERCHANT_KEY',
|
|
7
|
+
testMode: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function example() {
|
|
11
|
+
try {
|
|
12
|
+
const payment = await client.createPayment({
|
|
13
|
+
amount: 100,
|
|
14
|
+
orderId: 'TEST-001',
|
|
15
|
+
currency: 'SAR',
|
|
16
|
+
callback_link: 'https://yoursite.com/callback',
|
|
17
|
+
email: 'customer@example.com',
|
|
18
|
+
country: 'SA'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log('Payment URL:', payment.data.url);
|
|
22
|
+
console.log('Track ID:', payment.data.trackId);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
example();
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const VoletClient = require('../lib/volet');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json());
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
|
|
9
|
+
// Volet yapılandırması
|
|
10
|
+
const voletClient = new VoletClient({
|
|
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 voletClient.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
|
+
phone: '+1234567890',
|
|
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 voletClient.handleCallback(req.body);
|
|
48
|
+
|
|
49
|
+
console.log('Payment result:', result);
|
|
50
|
+
|
|
51
|
+
if (result.status === 'success') {
|
|
52
|
+
// Ödeme başarılı - sipariş işlemlerini gerçekleştir
|
|
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
|
+
// Başarı sayfası
|
|
67
|
+
app.get('/success', (req, res) => {
|
|
68
|
+
res.send('<h1>Payment Successful!</h1><p>Thank you for your payment.</p>');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Hata sayfası
|
|
72
|
+
app.get('/fail', (req, res) => {
|
|
73
|
+
res.send('<h1>Payment Failed</h1><p>Your payment could not be processed.</p>');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const PORT = 3000;
|
|
77
|
+
app.listen(PORT, () => {
|
|
78
|
+
console.log(`Server running on http://localhost:${PORT}`);
|
|
79
|
+
console.log(`Create payment: http://localhost:${PORT}/create-payment`);
|
|
80
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const XenditClient = require('../lib/xendit');
|
|
2
|
+
|
|
3
|
+
const client = new XenditClient({
|
|
4
|
+
apiKey: 'YOUR_API_KEY',
|
|
5
|
+
webhookToken: 'YOUR_WEBHOOK_TOKEN'
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
async function example() {
|
|
9
|
+
try {
|
|
10
|
+
const payment = await client.createPayment({
|
|
11
|
+
amount: 100000,
|
|
12
|
+
orderId: 'TEST-001',
|
|
13
|
+
paymentMethod: 'invoice',
|
|
14
|
+
currency: 'IDR',
|
|
15
|
+
callback_link: 'https://yoursite.com/callback',
|
|
16
|
+
name: 'Budi Santoso',
|
|
17
|
+
email: 'budi@example.com',
|
|
18
|
+
phone: '+628123456789'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log('Payment URL:', payment.data.url);
|
|
22
|
+
console.log('Invoice ID:', payment.data.id);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
example();
|