2013-05-02 77 views
6

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

我不明白为什么返回网址要调用两次。

请指教。

我正在使用下面的代码。

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; // "[email protected]"; 

    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 } 
    }; 
} 
+1

我可以验证这一点。我特别的设置是Ruby 1.9.3/Rails 3.2.13,并使用'paypal-sdk-adaptivepayments'创业板。 – 2013-07-10 19:32:18

+0

@Oshuma:你有没有得到任何解决方案,或者它是在贝宝结束的错误? – 2013-07-11 04:52:00

回答

2

@jitendra,我有这个同样的问题,结果发现,PayPal的使用服务器端脚本,一段时间后,用户将返回URL重定向,当我们明确地点击返回按钮,则贝宝服务器脚本再次点击返回网址,因此我们得到两个回复/点击我们的返回网址。

我们可以通过检查/维护在paypal上进行付款后得到的回复数量来解决某些问题。

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

希望这有帮助。