简体   繁体   English

使用 java 从 Payment GateWay 重定向时,我丢失了 session 数据

[英]I am losing session data when being redirected from Payment GateWay using java

I am setting some values using java session. After calling the Payment gateway, all me stored session values are losing.我正在使用 java session 设置一些值。调用支付网关后,我存储的所有 session 值都丢失了。 Please help me how to get those session values.请帮助我如何获得那些 session 值。

i set the some values to session like session.setAttribute("id", 120).我将一些值设置为 session,例如 session.setAttribute("id", 120)。 After redirect the paymeny gateway.重定向支付网关后。 I try to get the id using session.getAttribute("id").我尝试使用 session.getAttribute("id") 获取 id。 Here it returns the null value.在这里它返回 null 值。

From chat, you had stated that you are keeping the JSP session ID in a URL parameter rather than a cookie. 在聊天中,您已经声明要在URL参数而不是cookie中保留JSP会话ID。 This will cause an issue with the callback from the payment gateway, if the callback URL does not specify the same session ID. 如果回调URL未指定相同的会话ID,则这将导致付款网关的回调出现问题。

This means that you need to put the session ID in the callback URL. 这意味着您需要将会话ID放在回调URL中。 I am not familiar with CCAvenue as a payment gateway, but I can tell you this much: 我不熟悉CCAvenue作为付款网关,但是我可以告诉您很多:

When you set the callback URL, you need to encode the session ID onto it using HttpServletResponse#encodeURL 设置回调URL时,需要使用HttpServletResponse#encodeURL在其上编码会话ID。

You would pass the URL of the callback (ie your homepage) to this method, and it will return the callback URL with the session ID encoded within it, if necessary . 您可以将回调的URL(即您的主页)传递给此方法,并且如有必要 ,它将返回带有在其中编码的会话ID的回调URL。 You can then use this URL as the user redirect (callback) on your gateway and when the redirect completes, the page will be loaded with a valid session. 然后,您可以将该URL用作网关上的用户重定向(回调),当重定向完成时,页面将加载有效的会话。

You need to add the JSESSIONID in the callback url something like the following:您需要在回调 url 中添加 JSESSIONID,如下所示:

HttpSession session = request.getSession();
session.setAttribute("someName", someObject);

String callbackURL = "http://yourapplicationserver.com/callback.jsp;JSESSIONID=" + session.getId();
String redirectURL = "http://paymentgateway.com/process?callbackURL=" + URLEncoder.encode(callbackURL, "UTF-8");

response.sendRedirect(redirectURL);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 Payment Gateway 重定向时,我丢失了会话数据 - I am losing session data when being redirected from Payment GateWay 为什么我在Java中更改类时会丢失已存储的数据 - Why I am losing the data that I have stored when I change the class in java 无法从JAVA中的重定向URL检索PayPal成功/取消付款数据 - Unable to retrieve PayPal success/cancel payment data from redirected urls in JAVA 在不同的 class 中从构造函数转到主方法时,我丢失了数据。 怎么了? - I am losing data when going from constructor to main method in a different class. What is happening? 我在使用Java Mail发送的电子邮件中丢失了一段时间 - I am losing periods in an email sent using Java Mail Java用非零退出值2结束-使用Eds付款网关Android SDK时Android Gradle - Java finished with non-zero exit value 2 - Android Gradle when using eds payment gateway android sdk 当我尝试将数据保存到mysql时,引发了异常(java.sql.SQLException) - when i am trying to save the data to mysql, an exception is being thrown( java.sql.SQLException) 当我从服务器获取数据时,无法从Android端设置登录注销会话 - can not set login logout session from android side when i am fetch data from server 我正在使用Authorize.net付款网关并通过直接邮寄方法进行交易,是否可以仅验证卡信息 - I am using Authorize.net payment gateway and doing transaction through Direct Post Method,is it possible to just validate card information 为什么我在班级之间切换时会丢失 ArrayList 的内容? - Why I am losing the content of my ArrayList when I switch from class to class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM