贝宝自适应支付返回URL呼吁两次 [英] Paypal adaptive payment return url is calling twice

查看:190
本文介绍了贝宝自适应支付返回URL呼吁两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了贝宝自适应支付方式和使用网络流量。
在付款时,我明确点击返回按钮后,返回URL调用两次,但如果我等待自动重定向那么它只有一次调用。

我不能够理解为什么返回URL呼吁两次。

请咨询。

我使用低于code。

 公共静态ActionOutput MakeTransactionUsingPaypal(PaymentDetails支付,询shop_cart)
{
    ReceiverList receiverList =新ReceiverList();
    receiverList.receiver =新的List<接收>();
    字符串ACTION_TYPE =PAY_PRIMARY;
    小数amnt_to_admin =((shop_cart.TotalAmountToBePaid * 10)/ 100);    / *总金额为管理员帐户* /
    接收器REC1 =新的接收器(shop_cart.TotalAmountToBePaid);
    rec1.email = Config.AdminPaypalBusinessAccount;
    rec1.primary = TRUE;    / *扣除管理员佣金给卖家后金额* /
    接收器REC2 =新的接收器(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 =新PayRequest(新RequestEnvelope(EN_US),ACTION_TYPE,Config.PaypalCancelURL,USD,receiverList,Config.PaypalReturnURL);    // 可以了,好了。消防要求
    AdaptivePaymentsService服务=新AdaptivePaymentsService();    PayResponse RESP = NULL;
    // TransactionDetail细节=新TransactionDetail();    RESP = service.Pay(REQ);
    字符串PayKey = resp.payKey;
    字符串PaymentStatus = resp.paymentExecStatus;
    ResponseEnvelope ResponseEnvelope = resp.responseEnvelope;
    PayErrorList errorList = resp.payErrorList;
    清单<&errordata子GT; errordata子= resp.error;
    如果(errorData.Count大于0)
    {
        返回新ActionOutput
        {
            状态= ActionStatus.Error,
            消息= errordata子[0] .message
        };
    }
    FundingPlan defaultFundingPlan = resp.defaultFundingPlan;
    WarningDataList warningDataList = resp.warningDataList;
    字符串的redirectUrl = NULL;
    如果((resp.responseEnvelope.ack ==确认code.FAILURE)及!&安培;
        !(resp.responseEnvelope.ack ==确认code.FAILUREWITHWARNING))
    {
        的redirectUrl = ConfigurationManager.AppSettings [PAYPAL_REDIRECT_URL] +_ap支付和放大器; paykey =+ resp.payKey;    }
    返回新ActionOutput
    {
        状态= ActionStatus.Successfull,
        消息=重定向到贝宝......
        结果=新的List<串GT; {的redirectUrl,resp.payKey}
    };
}


解决方案

@jitendra,我有这个同样的问题,并发现了贝宝使用服务器端脚本,用户重定向到返回URL一段时间后,当我们明确点击返回按钮,然后PayPal的服务器脚本再次击中了自己的这样,我们得到两个响应返回URL上的退货地址/打。

我们可以通过检查/维护没有的,我们得到支付的贝宝后的反应有些过度此。

我们能保持对客户最终还是使用会话或别的类似的服务器这个使用cookie。

希望这有助于很好。

I have implemented paypal adaptive payment method and using the web flow. After making a payment, when i explicitly clicks on return button, the return url calls twice but if i wait for auto redirect then it calls once only.

I am not able to understand why return url is calling twice.

Please advice.

I am using below code.

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, I had this same issue and found out that the paypal uses a server side script which redirects the user to the return url after a while and when we explicitly click on return button, then the paypal server script again hits the return url on its own thus we get two responses/hits on our return url.

We can over some this by checking/maintaining the no of responses which we get after the payments are made on paypal.

We can maintain this using cookies on client end or on server using sessions or something else similar.

Hope this helps well.

这篇关于贝宝自适应支付返回URL呼吁两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆