Reputation: 559
I am trying to implement a bank payment system using the Express framework. According to the bank's docs, It starts by redirecting the user to a specific URL like this:
res.redirect("https://pec.shaparak.ir/NewIPG/?token=" + apiToken);
After the user enters his credit card information on the bank page, the bank will send the results of the transaction to you using a post request to a specified URL of your website which you told the bank earlier (for example, https://example.com/paymentresult
).
The problem is that each time a post request occurs from the bank page to the original website, the current session gets destroyed and the user gets logged out and has to login again which makes a bad UX.
I even tried to toggle express-session parameters like resave
, saveUninitialized
, or cookie.secure
. But they don't seem to work all the time either.
app.use(session({
secret: process.env.EXPRESS_SESSION_SECRET,
resave: true,
saveUninitialized: false,
cookie: {
secure: false,
maxAge: 30 * 24 * 60 * 60 * 1000 //30 days
},
store: MongoStore.create({
mongoUrl: process.env.MONGODB_URL,
ttl: 30 * 24 * 60 * 60 //30 days
})
}));
What am I doing wrong?
Upvotes: 0
Views: 34