asp.net – Paypal自适应支付返回网址是两次调用
发布时间:2020-12-16 03:48:50 所属栏目:asp.Net 来源:网络整理
导读:我已经实现了paypal自适应支付方法和使用网络流程. 付款后,当我明确点击返回按钮时,返回网址会调用两次,但如果我等待自动重定向,则只调用一次. 我无法理解为什么返回网址会调用两次. 请指教. 我正在使用下面的代码. public static ActionOutput MakeTransact
我已经实现了paypal自适应支付方法和使用网络流程.
付款后,当我明确点击返回按钮时,返回网址会调用两次,但如果我等待自动重定向,则只调用一次. 我无法理解为什么返回网址会调用两次. 请指教. 我正在使用下面的代码. public static ActionOutput MakeTransactionUsingPaypal(PaymentDetails payment,ShopCart shop_cart) { ReceiverList receiverList = new ReceiverList(); receiverList.receiver = new List<Receiver>(); string action_type = "PAY_PRIMARY"; decimal amnt_to_admin = ((shop_cart.TotalAmountToBePaid * 10) / 100); /*Total Amount to Admin Account */ Receiver rec1 = new Receiver(shop_cart.TotalAmountToBePaid); rec1.email = Config.AdminPaypalBusinessAccount; rec1.primary = true; /*Amount after deducting to Admin Commision to Seller */ Receiver rec2 = new Receiver(Math.Round((shop_cart.TotalAmountToBePaid - amnt_to_admin),2,MidpointRounding.ToEven)); rec2.email = payment.PaypalEmail; // "anuj_merchant@xicom.biz"; receiverList.receiver.Add(rec1); receiverList.receiver.Add(rec2); PayRequest req = new PayRequest(new RequestEnvelope("en_US"),action_type,Config.PaypalCancelURL,"USD",receiverList,Config.PaypalReturnURL); // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); PayResponse resp = null; //TransactionDetail details = new TransactionDetail(); resp = service.Pay(req); String PayKey = resp.payKey; String PaymentStatus = resp.paymentExecStatus; ResponseEnvelope ResponseEnvelope = resp.responseEnvelope; PayErrorList errorList = resp.payErrorList; List<ErrorData> errorData = resp.error; if (errorData.Count > 0) { return new ActionOutput { Status = ActionStatus.Error,Message = errorData[0].message }; } FundingPlan defaultFundingPlan = resp.defaultFundingPlan; WarningDataList warningDataList = resp.warningDataList; string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_ap-payment&paykey=" + resp.payKey; } return new ActionOutput { Status = ActionStatus.Successfull,Message = "Redirecting to paypal...",Results = new List<string> { redirectUrl,resp.payKey } }; } 解决方法
@jitendra,我有同样的问题,发现paypal使用服务器端脚本,一段时间后将用户重定向到返回URL,当我们明确点击返回按钮,然后paypal服务器脚本再次点击返回URL因此我们在返回网址上得到两个响应/点击.
我们可以通过检查/维护在PayPal付款后得到的回复来解决这个问题. 我们可以使用会话或类似的东西在客户端或服务器上使用cookie来维护它. 希望这很有帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.NET重写自定义错误不发送内容类型头
- 使用ASP.NET MVC时从WebForm访问HtmlHelpers
- asp.net-mvc-5 – 在默认的MVC5应用程序的帐户关联步骤中,从
- 简单探讨一下.NET Core 3.0使用AspectCore的新姿势
- Asp.net – 空QueryString参数
- asp.net-mvc – 如何禁用自动完成在MVC Html助手
- asp.net-mvc – 将Ninject与Ninject.Web.Api用于Web Api 2在
- asp.net-core – 在Microsoft.AspNet.Http.HttpContext中的
- 处理asp:ScriptManager时,mscorlib.dll中的asp.net – Exe
- asp.net – 无法检索元数据