用C#.NET调用Paypal自适应支付API? 最好使用WebServices

好吧,我现在可能完全偏离正轨但是这里:

我们的“网上商店”提供两种function,购买特定产品并将其出售给我们。 如果用户可以销售或不销售后端句柄。

我决定使用Paypal的自适应支付,因为这似乎是进行这类交易的方式。 我从来没有实施任何类型的商店,所以我对这一个完全是绿色的。 我最近才学习ASP.NET,并且在转向这种开发之前主要开发了游戏。 HTTP对我来说还是有些神奇的嘿嘿……

我可能会感到困惑,但我认为paypal提供了一个带有自适应支付API的网络服务。 我谦虚的要求:一个好心的人想要分享一个用C#.NET实现自适应支付API调用的例子。 如果他们不提供它作为web服务我可能会发现它是一个自定义.dll或其他东西。

任何提示和示例都非常感谢! 谢谢阅读

https://www.x.com/docs/DOC-1414

https://www.x.com/community/ppx/code_samples

这是他们的xml api。 我还没有使用vs.net中自动生成的代理来使用他们的web服务。 另外请记住,您必须为api信息,买方,卖方等声明常量或变量。

// API endpoint for the Refund call in the Sandbox string sAPIEndpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"; // Version that you are coding against string sVersion = "1.1.0"; // Error Langugage string sErrorLangugage = "en_US"; // Detail Level string sDetailLevel = "ReturnAll"; // Request Data Binding string sRequestDataBinding = "XML"; // Response Data Binding string sResponseDataBinding = "XML"; // Application ID string sAppID = "APP-80W284485P519543T"; // other clientDetails fields string sIpAddress = "255.255.255.255"; string sPartnerName = "MyCompanyName"; string sDeviceID = "255.255.255.255"; // Currency Code string sCurrencyCode = "USD"; // Action Type string sActionType = "PAY"; // ReturnURL and CancelURL used for approval flow string sReturnURL = "https://MyReturnURL"; string sCancelURL = "https://MyCancelURL"; // who pays the fees string sFeesPayer = "EACHRECEIVER"; // memo field string sMemo = "testing my first pay call"; // transaction amount string sAmount = "5"; // supply your own sandbox accounts for receiver and sender string sTrackingID = System.Guid.NewGuid().ToString(); // construct the XML request string StringBuilder sRequest = new StringBuilder(""); sRequest.Append(""); // requestEnvelope fields sRequest.Append(""); sRequest.Append(sErrorLangugage); sRequest.Append(""); sRequest.Append(sDetailLevel); sRequest.Append(""); // clientDetails fields sRequest.Append(""); sRequest.Append(sAppID); sRequest.Append(""); sRequest.Append(sDeviceID); sRequest.Append(""); sRequest.Append(sIpAddress); sRequest.Append(""); sRequest.Append(sPartnerName); sRequest.Append(""); // request specific data fields sRequest.Append(""); sRequest.Append(sActionType); sRequest.Append(""); sRequest.Append(sCancelURL); sRequest.Append(""); sRequest.Append(sReturnURL); sRequest.Append(""); sRequest.Append(sCurrencyCode); sRequest.Append(""); sRequest.Append(sFeesPayer); sRequest.Append(""); sRequest.Append(sMemo); sRequest.Append(""); sRequest.Append(sAmount); sRequest.Append(""); sRequest.Append(Receiver); sRequest.Append(""); sRequest.Append(Sender); sRequest.Append(""); sRequest.Append(sTrackingID); sRequest.Append(""); // get ready to make the call HttpWebRequest oPayRequest = (HttpWebRequest)WebRequest.Create(sAPIEndpoint); oPayRequest.Method = "POST"; byte[] array = Encoding.UTF8.GetBytes(sRequest.ToString()); oPayRequest.ContentLength = array.Length; oPayRequest.ContentType = "text/xml;charset=utf-8"; // set the HTTP Headers oPayRequest.Headers.Add("X-PAYPAL-SECURITY-USERID", UserID); oPayRequest.Headers.Add("X-PAYPAL-SECURITY-PASSWORD", Pass); oPayRequest.Headers.Add("X-PAYPAL-SECURITY-SIGNATURE", Signature); oPayRequest.Headers.Add("X-PAYPAL-SERVICE-VERSION", sVersion); oPayRequest.Headers.Add("X-PAYPAL-APPLICATION-ID", sAppID); oPayRequest.Headers.Add("X-PAYPAL-REQUEST-DATA-FORMAT", sRequestDataBinding); oPayRequest.Headers.Add("X-PAYPAL-RESPONSE-DATA-FORMAT", sResponseDataBinding); // send the request Stream oStream = oPayRequest.GetRequestStream(); oStream.Write(array, 0, array.Length); oStream.Close(); // get the response HttpWebResponse oPayResponse = (HttpWebResponse)oPayRequest.GetResponse(); StreamReader oStreamReader = new StreamReader(oPayResponse.GetResponseStream()); string sResponse = oStreamReader.ReadToEnd(); oStreamReader.Close(); 

我认为该页面可以帮助您找到所需内容。 这是一个实现PayPal界面的代码,无需创建立即付款按钮。 在此页面上看到PayPal C#