2012-10-18 205 views
2

我正在usning下面的Web服務,爲實現快速結帳PayPal快速結帳在asp.net

//Demo 
https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl 

//Live 
https://www.paypal.com/wsdl/PayPalSvc.wsdl 

我從貝羅博客網址幫助。

http://blog.effectlabs.com/post/2011/11/07/Paypal-Express-Checkout-with-C-using-Paypal-web-services.aspx

誤差-in響應對象我收到「resp.Token是空」當我在XP-64位上運行相同的代碼(端口和IIS6兩者),窗口服務器2008(IIS7 32位模式)

但運行正常(沒有錯誤,令牌是在Win-7 32位IIS7和端口

螺母空在獲得價值)我的代碼如下。

protected void btnPaypal_Click(object sender, EventArgs e) 
{ 

    CustomSecurityHeaderType type = new CustomSecurityHeaderType(); 

    type.Credentials = new UserIdPasswordType() 
    { 

     Username = "removed", 
     Password = "removed", 
     Signature = "removed" 
    }; 

    SetExpressCheckoutRequestDetailsType sdt = new SetExpressCheckoutRequestDetailsType(); 
    sdt.NoShipping = "1"; 
    PaymentDetailsType pdt = new PaymentDetailsType() 
    { 
     OrderDescription = "Payment Details Sushant", 
     OrderTotal = new BasicAmountType() 
     { 
      currencyID = CurrencyCodeType.USD, 
      Value = "100.00" 
     } 
    }; 

    sdt.PaymentDetails = new PaymentDetailsType[] { pdt }; 
    sdt.CancelURL = "http://localhost/OAT/Default.aspx"; 
    sdt.ReturnURL = "http://localhost/OAT/ExpressCheckoutSuccess.aspx"; 

    SetExpressCheckoutReq req = new SetExpressCheckoutReq() 
    { 
     SetExpressCheckoutRequest = new SetExpressCheckoutRequestType() 
     { 
      SetExpressCheckoutRequestDetails = sdt, 
      Version = "60.0" 
     } 
    }; 
    PayPalAPIAAInterfaceClient paypalAAInt = new PayPalAPIAAInterfaceClient(); 
    var resp = paypalAAInt.SetExpressCheckout(ref type, req); 
    if (resp.Errors != null && resp.Errors.Length > 0) 
    { 
     // errors occured 
     throw new Exception("Exception(s) occured when calling PayPal. First exception: " + 
      resp.Errors[0].LongMessage + resp.Errors.Length.ToString()); 
    } 

// error is here.. that resp.Token is null on xp-64 bit port and iis6 both, but running fine on win-7 32 bit iis7 and port, and w 

    Response.Redirect(string.Format("{0}?cmd=_express-checkout&token={1}", 
      "https://www.paypal.com/cgi-bin/webscr", resp.Token)); 


} 

回答

1

在貝寶Web引用文件夾中打開Reference.cs在文本編輯器文件,然後搜索「System.Xml.XmlElement任何」

你會發現這樣的代碼:

[System.Xml.Serialization.XmlElementAttribute(Order=6)] 
    public System.Xml.XmlElement Any { 
     get { 
      return this.anyField; 
     } 
     set { 
      this.anyField = value; 
      this.RaisePropertyChanged("Any"); 
     } 
    } 

現在更換

[System.Xml.Serialization.XmlElementAttribute(Order=6)]

[System.Xml.Serialization.XmlIgnoreAttribute()]

並運行後,重新編譯應用程序。

您現在將看到resp.Token填充所需的值