Asp.net Paypal自适应支付返回url正在调用两次
我已经实现了paypal自适应支付方法并使用了web流。 付款后,当我显式单击return按钮时,return url会调用两次,但如果我等待自动重定向,则只会调用一次 我不明白为什么返回url调用了两次 请给我一些建议 我正在使用下面的代码Asp.net Paypal自适应支付返回url正在调用两次,asp.net,paypal,payment-gateway,paypal-adaptive-payments,Asp.net,Paypal,Payment Gateway,Paypal Adaptive Payments,我已经实现了paypal自适应支付方法并使用了web流。 付款后,当我显式单击return按钮时,return url会调用两次,但如果我等待自动重定向,则只会调用一次 我不明白为什么返回url调用了两次 请给我一些建议 我正在使用下面的代码 public static ActionOutput MakeTransactionUsingPaypal(PaymentDetails payment, ShopCart shop_cart) { ReceiverList receiverLis
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 }
};
}
public静态操作输出makeTransaction使用PayPal(PaymentDetails付款、ShopCart购物车)
{
ReceiverList ReceiverList=新的ReceiverList();
receiverList.receiver=新列表();
string action_type=“PAY_PRIMARY”;
十进制amnt_to_admin=((shop_cart.TotalAmountToBePaid*10)/100);
/*管理员帐户的总金额*/
Receiver rec1=新的接收器(车间\购物车总数量待备);
rec1.email=Config.AdminPaypalBusinessAccount;
rec1.primary=true;
/*扣除卖方管理佣金后的金额*/
Receiver rec2=新接收器(数学圆整((shop_cart.TotalAmountToBePaid-amnt_to_admin),2,中点圆整.ToEven));
rec2.email=payment.PaypalEmail;//“anuj_merchant@xicom.biz";
接收人名单。接收人。添加(rec1);
接收人名单。接收人。添加(rec2);
PayRequest req=新的PayRequest(新的RequestEnvelope(“en_US”),操作类型,Config.PaypalCancelURL,“USD”,接收者列表,Config.PaypalReturnURL);
//一切就绪,按要求开火
AdaptivePaymentsService=新的AdaptivePaymentsService();
PayResponse resp=null;
//TransactionDetails=新建TransactionDetail();
resp=服务费(req);
字符串PayKey=resp.PayKey;
字符串PaymentStatus=resp.paymentExecStatus;
响应发展响应发展=响应发展;
PayErrorList errorList=对应的PayErrorList;
列表错误数据=响应错误;
如果(errorData.Count>0)
{
返回新的ActionOutput
{
状态=操作状态。错误,
Message=errorData[0]。消息
};
}
FundingPlan defaultFundingPlan=各自的defaultFundingPlan;
WarningDataList WarningDataList=分别为WarningDataList;
字符串重定向URL=null;
如果(!(resp.responseenevelope.ack==AckCode.FAILURE)&&
!(resp.responseenevelope.ack==AckCode.FAILUREWITHWARNING))
{
redirectUrl=ConfigurationManager.AppSettings[“PAYPAL\u REDIRECT\u URL”]+“\u ap-payment&paykey=“+resp.paykey;
}
返回新的ActionOutput
{
状态=操作状态。成功,
Message=“正在重定向到paypal…”,
结果=新列表{redirectUrl,resp.payKey}
};
}
@jitendra,我也遇到了同样的问题,我发现paypal使用了一个服务器端脚本,它会在一段时间后将用户重定向到返回url,当我们显式单击返回按钮时,paypal服务器脚本会再次自己点击返回url,因此我们在返回url上得到两个响应/点击
我们可以通过检查/维护在paypal上付款后收到的回复数量来解决一些问题
我们可以在客户端或服务器上使用会话或其他类似的方式使用cookies来维护此功能
希望这有帮助。我可以验证这一点。我的特别设置是Ruby 1.9.3/Rails 3.2.13,并使用“paypal sdk adaptivepayments”gem。@Oshuma:你有没有找到解决方案,或者这是paypal的一个bug?