Paypal 自适应支付返回 url 调用两次 [英] Paypal adaptive payment return url is calling twice

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

问题描述

我已经实施了贝宝自适应支付方式并使用了网络流程.付款后,当我明确点击返回按钮时,返回 url 调用两次,但如果我等待自动重定向,则它只调用一次.

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.

我不明白为什么返回 url 调用了两次.

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

请指教.

我正在使用以下代码.

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,当我们明确点击返回按钮,然后贝宝服务器脚本再次自己点击返回 url,因此我们在返回 url 上得到两个响应/点击.

@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.

我们可以通过检查/维护我们在 paypal 上付款后收到的回复数量来解决这个问题.

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

我们可以使用 cookie 在客户端或服务器上使用会话或其他类似的东西来维护这一点.

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

希望这会有所帮助.

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

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