pay
This commit is contained in:
12
index.js
12
index.js
@@ -13,6 +13,7 @@ try {
|
||||
}
|
||||
const http = require('http').createServer(app);
|
||||
const multer = require('multer');
|
||||
const { buildZarinpalStartPayUrl } = require('./utils/zarinpalPaymentPage');
|
||||
const cors = require('cors');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const moment = require('moment-jalaali');
|
||||
@@ -425,6 +426,17 @@ app.post('/api/v1/notification/send-sms', [blockCheck], async (req, res) => {
|
||||
// فایل/ویس توی چت (وب و اندروید، چون هر دو همین یه اندپوینتِ مشترک رو صدا میزنن) با
|
||||
// «Server error» شکست میخورد. همون الگوی multer.diskStorage که posts استفاده میکنه،
|
||||
// اینجا هم (مستقیماً روی پوشهی نهایی، بدونِ نیاز به fs.move جداگانه) وصل شد
|
||||
app.get('/api/v1/pay/:authority', (req, res) => {
|
||||
const authority = String(req.params.authority || '')
|
||||
if (!/^[A-Za-z0-9]{1,64}$/.test(authority)) {
|
||||
return res.status(400).send('invalid authority')
|
||||
}
|
||||
const target = buildZarinpalStartPayUrl(authority)
|
||||
res.set('Content-Type', 'text/html; charset=utf-8')
|
||||
res.set('Referrer-Policy', 'origin')
|
||||
res.send(`<!doctype html><html lang="fa" dir="rtl"><head><meta charset="utf-8"><meta name="referrer" content="origin"><meta name="viewport" content="width=device-width,initial-scale=1"><title>انتقال به درگاه پرداخت</title></head><body><p>در حال انتقال به درگاه پرداخت…</p><a href="${target}">ادامه</a><script>location.replace(${JSON.stringify(target)});</script></body></html>`)
|
||||
})
|
||||
|
||||
const chatFileUploadDir = path.join(__dirname, '../storage/messages')
|
||||
if (!fs.existsSync(chatFileUploadDir)) {
|
||||
fs.mkdirSync(chatFileUploadDir, { recursive: true })
|
||||
|
||||
Reference in New Issue
Block a user