quickpos 1.0.4 → 1.0.6
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-papara.js +112 -0
- package/lib/papara.js +145 -0
- package/package.json +3 -2
- package/readme.md +3 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const PaparaClient = require('./lib/papara');
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const bodyParser = require('body-parser');
|
|
4
|
+
const app = express();
|
|
5
|
+
app.use(bodyParser.json());
|
|
6
|
+
|
|
7
|
+
const papara = new PaparaClient({
|
|
8
|
+
apiKey: 'xxxx',
|
|
9
|
+
merchantSecretKey: 'xxxx'
|
|
10
|
+
}, true);
|
|
11
|
+
|
|
12
|
+
app.post('/callback', async (req, res) => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await papara.handleCallback(req.body);
|
|
15
|
+
console.log(result);
|
|
16
|
+
/*
|
|
17
|
+
{
|
|
18
|
+
status: 'success',
|
|
19
|
+
orderId: '1234',
|
|
20
|
+
uuid: '39061b51-7688-4287-9f90-5b1aa4a25178',
|
|
21
|
+
amount: 1,
|
|
22
|
+
currency: 0,
|
|
23
|
+
paymentMethod: 0
|
|
24
|
+
}
|
|
25
|
+
*/
|
|
26
|
+
res.send('OK');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
res.status(400).send(error.message);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
app.listen(80, () => console.log('Server started'));
|
|
33
|
+
|
|
34
|
+
// Ödeme oluşturma örneği
|
|
35
|
+
(async () => {
|
|
36
|
+
const payment = await papara.createPayment({
|
|
37
|
+
amount: 1,
|
|
38
|
+
nameSurname: 'Test Customer',
|
|
39
|
+
referenceId: '1234',
|
|
40
|
+
currency: 'USD', // TRY, USD, EUR
|
|
41
|
+
orderDescription: 'Test Payment',
|
|
42
|
+
notificationUrl: 'https://test.dalamangoldtaxi.net/callback',
|
|
43
|
+
redirectUrl: 'https://your-domain.com'
|
|
44
|
+
});
|
|
45
|
+
/*
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
data: {
|
|
50
|
+
merchant: {
|
|
51
|
+
id: '2f73fd0a-d480-4f6f-a2a3-4c663ffbc26d',
|
|
52
|
+
balances: [Array],
|
|
53
|
+
legalName: 'TEST2',
|
|
54
|
+
iconUrl: null,
|
|
55
|
+
brandName: 'TEST2',
|
|
56
|
+
allowedPaymentTypes: [Array],
|
|
57
|
+
allowingGuestCheckout: true,
|
|
58
|
+
allowingPaparaCheckout: false,
|
|
59
|
+
isCorporateCardsListOnPaparaAppEnabled: true,
|
|
60
|
+
atmDepositEnabled: false
|
|
61
|
+
},
|
|
62
|
+
userName: null,
|
|
63
|
+
relatedTransactions: [],
|
|
64
|
+
totalRefundedAmount: 0,
|
|
65
|
+
id: 'f825a55e-598c-411b-af80-a729fd3c13d1',
|
|
66
|
+
createdAt: '2025-01-03T21:59:38.1511487',
|
|
67
|
+
merchantId: '2f73fd0a-d480-4f6f-a2a3-4c663ffbc26d',
|
|
68
|
+
userId: null,
|
|
69
|
+
paymentMethod: 0,
|
|
70
|
+
paymentMethodDescription: null,
|
|
71
|
+
referenceId: '1234',
|
|
72
|
+
orderDescription: 'Test Payment',
|
|
73
|
+
status: 0,
|
|
74
|
+
statusDescription: null,
|
|
75
|
+
amount: 1,
|
|
76
|
+
fee: 0,
|
|
77
|
+
currency: 0,
|
|
78
|
+
currencyInfo: {
|
|
79
|
+
currencyEnum: 0,
|
|
80
|
+
symbol: '₺',
|
|
81
|
+
code: 'TRY',
|
|
82
|
+
number: 949,
|
|
83
|
+
preferredDisplayCode: 'TL',
|
|
84
|
+
name: 'Türk Lirası',
|
|
85
|
+
isCryptocurrency: false,
|
|
86
|
+
isInternationalMoneyTransferCurrency: false,
|
|
87
|
+
precision: 2,
|
|
88
|
+
iconUrl: 'https://dkto9gpxgolik.cloudfront.net/icons/currencies/try.svg',
|
|
89
|
+
flagUrl: 'https://dkto9gpxgolik.cloudfront.net/icons/currencies/try_flag.png',
|
|
90
|
+
currencyEnumIso: 949,
|
|
91
|
+
isMetalCurrency: false
|
|
92
|
+
},
|
|
93
|
+
notificationUrl: 'https://your-domain.com/callback',
|
|
94
|
+
failNotificationUrl: null,
|
|
95
|
+
notificationDone: false,
|
|
96
|
+
paymentUrl: 'https://test.papara.com/checkout/f825a55e-598c-411b-af80-a729fd3c13d1',
|
|
97
|
+
merchantSecretKey: null,
|
|
98
|
+
remainingRefundAmount: null,
|
|
99
|
+
returningRedirectUrl: 'https://your-domain.com?paymentId=f825a55e-598c-411b-af80-a729fd3c13d1&referenceId=1234&status=0&amount=1&paymentId=f825a55e-598c-411b-af80-a729fd3c13d1&referenceId=1234&status=0&amount=1',
|
|
100
|
+
errorCode: null,
|
|
101
|
+
errorMessage: null,
|
|
102
|
+
turkishNationalId: 0,
|
|
103
|
+
secureType: 1,
|
|
104
|
+
basketUrl: null
|
|
105
|
+
},
|
|
106
|
+
succeeded: true
|
|
107
|
+
}
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
// console.log(payment);
|
|
111
|
+
console.log(payment.data.paymentUrl);
|
|
112
|
+
})();
|
package/lib/papara.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
class PaparaClient {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
const requiredFields = ['apiKey', 'merchantSecretKey'];
|
|
6
|
+
for (let field of requiredFields) {
|
|
7
|
+
if (!config[field]) throw new Error(`Missing required field: ${field}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
this.URL = config?.test ? 'https://merchant-api.test.papara.com' : 'https://merchant.papara.com';
|
|
11
|
+
console.log(this.URL);
|
|
12
|
+
this.merchantSecretKey = config.merchantSecretKey;
|
|
13
|
+
this.client = axios.create({
|
|
14
|
+
baseURL: this.URL,
|
|
15
|
+
headers: {
|
|
16
|
+
'ApiKey': config.apiKey,
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
this.client.interceptors.response.use(response => {
|
|
22
|
+
return response;
|
|
23
|
+
}, error => {
|
|
24
|
+
if (error.response) {
|
|
25
|
+
throw new Error(`Papara API error: ${error.response.data.message}`);
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`Papara API error: ${error.message}`);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async createPayment(options) {
|
|
32
|
+
try {
|
|
33
|
+
let currencys = {
|
|
34
|
+
'TRY': 0,
|
|
35
|
+
'USD': 1,
|
|
36
|
+
'EUR': 2
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const response = await this.client.post('/payments', {
|
|
40
|
+
amount: Number(options.amount),
|
|
41
|
+
nameSurname: options.nameSurname,
|
|
42
|
+
referenceId: options.referenceId,
|
|
43
|
+
currency: currencys[options.currency],
|
|
44
|
+
orderDescription: options.orderDescription,
|
|
45
|
+
notificationUrl: options.notificationUrl,
|
|
46
|
+
redirectUrl: options.redirectUrl
|
|
47
|
+
});
|
|
48
|
+
return response.data;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new Error(`Payment creation error: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getAccount() {
|
|
55
|
+
try {
|
|
56
|
+
const response = await this.client.get('/account');
|
|
57
|
+
return response.data;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new Error(`Account info error: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async getAccountLedger(options) {
|
|
64
|
+
try {
|
|
65
|
+
const response = await this.client.post('/account/ledgers', {
|
|
66
|
+
startDate: options.startDate,
|
|
67
|
+
endDate: options.endDate,
|
|
68
|
+
page: options.page || 1,
|
|
69
|
+
pageSize: options.pageSize || 50
|
|
70
|
+
});
|
|
71
|
+
return response.data;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw new Error(`Account ledger error: ${error.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getPaymentStatus(paymentId) {
|
|
78
|
+
try {
|
|
79
|
+
const response = await this.client.get(`/payments?id=${paymentId}`);
|
|
80
|
+
return response.data;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error(`Payment status error: ${error.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async handleCallback(callbackData) {
|
|
87
|
+
try {
|
|
88
|
+
const verification = await this.verifyPaymentCallback(callbackData);
|
|
89
|
+
|
|
90
|
+
if (!verification.status) {
|
|
91
|
+
throw new Error(verification.error.message);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
status: 'success',
|
|
96
|
+
orderId: verification.data.referenceId,
|
|
97
|
+
uuid: verification.data.id,
|
|
98
|
+
amount: parseFloat(verification.data.amount),
|
|
99
|
+
currency: verification.data.currency,
|
|
100
|
+
paymentMethod: verification.data.paymentMethod
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw new Error(`Error in Papara callback handling: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async verifyPaymentCallback(data) {
|
|
108
|
+
try {
|
|
109
|
+
if (data.status !== 1) {
|
|
110
|
+
return {
|
|
111
|
+
status: false,
|
|
112
|
+
error: {
|
|
113
|
+
code: data?.errorCode,
|
|
114
|
+
message: data?.errorMessage || 'Payment failed'
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (data.merchantSecretKey !== this.merchantSecretKey) {
|
|
120
|
+
return {
|
|
121
|
+
status: false,
|
|
122
|
+
error: {
|
|
123
|
+
code: 401,
|
|
124
|
+
message: 'Invalid merchant secret key'
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
status: true,
|
|
131
|
+
data: data
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
return {
|
|
135
|
+
status: false,
|
|
136
|
+
error: {
|
|
137
|
+
code: 500,
|
|
138
|
+
message: error.message
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = PaparaClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickpos",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"main": "app.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"paypal",
|
|
26
26
|
"shopier",
|
|
27
27
|
"cryptomus",
|
|
28
|
-
"payeer"
|
|
28
|
+
"payeer",
|
|
29
|
+
"papara"
|
|
29
30
|
],
|
|
30
31
|
"repository": {
|
|
31
32
|
"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, 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.
|
|
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, Papara 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
|
|
|
@@ -136,6 +136,7 @@ const quickPos = new QuickPos({
|
|
|
136
136
|
- Shopier
|
|
137
137
|
- Cryptomus
|
|
138
138
|
- Payeer
|
|
139
|
+
- Papara
|
|
139
140
|
|
|
140
141
|
---
|
|
141
142
|
|
|
@@ -154,6 +155,7 @@ const quickPos = new QuickPos({
|
|
|
154
155
|
- [x] Shopier entegrasyonu
|
|
155
156
|
- [x] Cryptomus entegrasyonu
|
|
156
157
|
- [x] Payeer entegrasyonu
|
|
158
|
+
- [x] Papara entegrasyonu
|
|
157
159
|
- [ ] İyzico entegrasyonu
|
|
158
160
|
- [ ] Vallet entegrasyonu
|
|
159
161
|
- [ ] Shipy entegrasyonu
|