quickpos 1.0.3 → 1.0.4
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/example-payeer.js +74 -0
- package/lib/payeer.js +110 -0
- package/package.json +3 -2
- package/readme.md +3 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const QuickPos = require('quickpos');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json({ limit: '50mb', extended: true }));
|
|
7
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
8
|
+
app.use(require('multer')().none());
|
|
9
|
+
|
|
10
|
+
const quickPos = new QuickPos({
|
|
11
|
+
providers: {
|
|
12
|
+
payeer: {
|
|
13
|
+
m_shop: 'XXXX',
|
|
14
|
+
m_key: 'XXXXXX'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
app.use(quickPos.middleware());
|
|
20
|
+
|
|
21
|
+
app.use(async (req, res, next) => {
|
|
22
|
+
console.log('Middleware çalıştı');
|
|
23
|
+
console.log(req.method, req.url);
|
|
24
|
+
next();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
(async () => {
|
|
28
|
+
const payment = await quickPos.providers['payeer'].createPayment({
|
|
29
|
+
orderId: 'S12345',
|
|
30
|
+
amount: '0.01',
|
|
31
|
+
currency: 'RUB',
|
|
32
|
+
description: 'Test payment'
|
|
33
|
+
});
|
|
34
|
+
console.log(payment);
|
|
35
|
+
})();
|
|
36
|
+
|
|
37
|
+
app.post('/status', quickPos.handleCallback('payeer'), async (req, res) => {
|
|
38
|
+
/*
|
|
39
|
+
POST /status
|
|
40
|
+
{
|
|
41
|
+
status: 'success',
|
|
42
|
+
orderId: 'S12345',
|
|
43
|
+
amount: '0.01',
|
|
44
|
+
currency: 'RUB',
|
|
45
|
+
operationId: '2175845325',
|
|
46
|
+
paymentDate: '29.12.2024 20:37:43'
|
|
47
|
+
}
|
|
48
|
+
Ödeme başarılı: {
|
|
49
|
+
status: 'success',
|
|
50
|
+
orderId: 'S12345',
|
|
51
|
+
amount: '0.01',
|
|
52
|
+
currency: 'RUB',
|
|
53
|
+
operationId: 'xxxx',
|
|
54
|
+
paymentDate: '29.12.2024 20:37:43'
|
|
55
|
+
}
|
|
56
|
+
*/
|
|
57
|
+
console.log(req.paymentResult);
|
|
58
|
+
try {
|
|
59
|
+
if (req.paymentResult.status === 'success') {
|
|
60
|
+
console.log('Ödeme başarılı:', req.paymentResult);
|
|
61
|
+
} else {
|
|
62
|
+
console.error('Ödeme başarısız:', req.paymentResult);
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('Webhook hatası:', error);
|
|
66
|
+
res.status(400).json({error: error.message});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const PORT = 80;
|
|
72
|
+
app.listen(PORT, () => {
|
|
73
|
+
console.log(`Webhook server running on port ${PORT}`);
|
|
74
|
+
});
|
package/lib/payeer.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
|
|
4
|
+
class Payeer {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config || {};
|
|
7
|
+
const requiredFields = ['m_shop', 'm_key'];
|
|
8
|
+
for (let field of requiredFields) {
|
|
9
|
+
if (!config[field]) throw new Error(`Missing required field: ${field}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.m_shop = config.m_shop;
|
|
13
|
+
this.m_key = config.m_key;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async createPayment(paymentDetails) {
|
|
17
|
+
try {
|
|
18
|
+
const requiredData = ['orderId', 'amount', 'currency', 'description'];
|
|
19
|
+
for (let data of requiredData) {
|
|
20
|
+
if (!paymentDetails[data]) throw new Error(`Missing required data: ${data}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const m_sign = this.generateSignature(
|
|
24
|
+
paymentDetails.orderId,
|
|
25
|
+
paymentDetails.amount,
|
|
26
|
+
paymentDetails.currency,
|
|
27
|
+
Buffer.from(paymentDetails.description).toString('base64')
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const paymentUrl = `https://payeer.com/merchant/?m_shop=${this.m_shop}&m_orderid=${paymentDetails.orderId}&m_amount=${paymentDetails.amount}&m_curr=${paymentDetails.currency}&m_desc=${Buffer.from(paymentDetails.description).toString('base64')}&m_sign=${m_sign}&lang=${paymentDetails.lang || 'en'}`;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
status: 'success',
|
|
34
|
+
data: {
|
|
35
|
+
url: paymentUrl,
|
|
36
|
+
orderId: paymentDetails.orderId,
|
|
37
|
+
amount: paymentDetails.amount,
|
|
38
|
+
currency: paymentDetails.currency
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(`Error in Payeer payment creation: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async handleCallback(callbackData) {
|
|
47
|
+
try {
|
|
48
|
+
const signHash = this.generatePaymentStatusSignature(callbackData);
|
|
49
|
+
|
|
50
|
+
if (callbackData.m_sign === signHash && callbackData.m_status === 'success') {
|
|
51
|
+
return {
|
|
52
|
+
status: 'success',
|
|
53
|
+
orderId: callbackData.m_orderid,
|
|
54
|
+
amount: callbackData.m_amount,
|
|
55
|
+
currency: callbackData.m_curr,
|
|
56
|
+
operationId: callbackData.m_operation_id,
|
|
57
|
+
paymentDate: callbackData.m_operation_pay_date
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
throw new Error('Payment validation failed');
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new Error(`Error in Payeer callback handling: ${error.message}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
generateSignature(m_orderid, m_amount, m_curr, m_desc) {
|
|
68
|
+
const arHash = [
|
|
69
|
+
this.m_shop,
|
|
70
|
+
m_orderid,
|
|
71
|
+
m_amount,
|
|
72
|
+
m_curr,
|
|
73
|
+
m_desc,
|
|
74
|
+
this.m_key
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
return crypto.createHash('sha256')
|
|
78
|
+
.update(arHash.join(':'))
|
|
79
|
+
.digest('hex')
|
|
80
|
+
.toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
generatePaymentStatusSignature(paymentData) {
|
|
84
|
+
const arHash = [
|
|
85
|
+
paymentData.m_operation_id,
|
|
86
|
+
paymentData.m_operation_ps,
|
|
87
|
+
paymentData.m_operation_date,
|
|
88
|
+
paymentData.m_operation_pay_date,
|
|
89
|
+
paymentData.m_shop,
|
|
90
|
+
paymentData.m_orderid,
|
|
91
|
+
paymentData.m_amount,
|
|
92
|
+
paymentData.m_curr,
|
|
93
|
+
paymentData.m_desc,
|
|
94
|
+
paymentData.m_status
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
if (paymentData.m_params) {
|
|
98
|
+
arHash.push(paymentData.m_params);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
arHash.push(this.m_key);
|
|
102
|
+
|
|
103
|
+
return crypto.createHash('sha256')
|
|
104
|
+
.update(arHash.join(':'))
|
|
105
|
+
.digest('hex')
|
|
106
|
+
.toUpperCase();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = Payeer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickpos",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"main": "app.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"stripe",
|
|
25
25
|
"paypal",
|
|
26
26
|
"shopier",
|
|
27
|
-
"cryptomus"
|
|
27
|
+
"cryptomus",
|
|
28
|
+
"payeer"
|
|
28
29
|
],
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 💳 QuickPos 🚀
|
|
2
2
|
|
|
3
|
-
QuickPos, farklı ödeme sağlayıcılarını destekleyen güçlü bir ödeme entegrasyon modülüdür. Şu anda PayTR, Shopier, Cryptomus sağlayıcısını desteklemektedir ve gelecekte birçok yeni sağlayıcı ile özellik eklemeyi planlamaktadır. Yol haritamıza göz atarak gelecek özellikleri keşfedebilirsiniz.
|
|
3
|
+
QuickPos, farklı ödeme sağlayıcılarını destekleyen güçlü bir ödeme entegrasyon modülüdür. Şu anda PayTR, Shopier, Cryptomus, Payeer sağlayıcısını desteklemektedir ve gelecekte birçok yeni sağlayıcı ile özellik eklemeyi planlamaktadır. Yol haritamıza göz atarak gelecek özellikleri keşfedebilirsiniz.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -135,6 +135,7 @@ const quickPos = new QuickPos({
|
|
|
135
135
|
- PayTR
|
|
136
136
|
- Shopier
|
|
137
137
|
- Cryptomus
|
|
138
|
+
- Payeer
|
|
138
139
|
|
|
139
140
|
---
|
|
140
141
|
|
|
@@ -152,6 +153,7 @@ const quickPos = new QuickPos({
|
|
|
152
153
|
- [x] PayTR entegrasyonu
|
|
153
154
|
- [x] Shopier entegrasyonu
|
|
154
155
|
- [x] Cryptomus entegrasyonu
|
|
156
|
+
- [x] Payeer entegrasyonu
|
|
155
157
|
- [ ] İyzico entegrasyonu
|
|
156
158
|
- [ ] Vallet entegrasyonu
|
|
157
159
|
- [ ] Shipy entegrasyonu
|