Paypal responsive payment API APIs with C # .NET? Preferably Using WebServices

Ok, now I can be completely offside, but here goes:

Our "online store" offers two functions, buying a specific product and selling it to us. The back-end handles if the user can sell or not.

I decided to use Paypal adaptive payments for this, since it seems that this can be done with such transactions. I have never implemented any store, so I am completely green with this. I only recently learned ASP.NET and basically developed games before moving on to such a development. HTTP is still some level of magic for me hehe ..

I might be confused, but I think PayPal offers a web service with an adaptive payment API. My humble request: a good soul who wants to share an example implementation of the adaptive payment API API with C # .NET. If they do not offer it as a web service, I probably find it as a regular .dll or something like that.

Any tips and examples are welcome! Thanks for reading

+3
source share
2 answers

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

and

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

This is their xml api. I did not get their web services to work using automatically generated proxies in vs .net. Also keep in mind that you will have to declare constants or variables for api information, buyer, seller, etc.

        // 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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        sRequest.Append("<PayRequest xmlns:ns2=\"http://svcs.paypal.com/types/ap\">");
        // requestEnvelope fields
        sRequest.Append("<requestEnvelope><errorLanguage>");
        sRequest.Append(sErrorLangugage);
        sRequest.Append("</errorLanguage><detailLevel>");
        sRequest.Append(sDetailLevel);
        sRequest.Append("</detailLevel></requestEnvelope>");
        // clientDetails fields
        sRequest.Append("<clientDetails><applicationId>");
        sRequest.Append(sAppID);
        sRequest.Append("</applicationId><deviceId>");
        sRequest.Append(sDeviceID);
        sRequest.Append("</deviceId><ipAddress>");
        sRequest.Append(sIpAddress);
        sRequest.Append("</ipAddress><partnerName>");
        sRequest.Append(sPartnerName);
        sRequest.Append("</partnerName></clientDetails>");
        // request specific data fields
        sRequest.Append("<actionType>");
        sRequest.Append(sActionType);
        sRequest.Append("</actionType><cancelUrl>");
        sRequest.Append(sCancelURL);
        sRequest.Append("</cancelUrl><returnUrl>");
        sRequest.Append(sReturnURL);
        sRequest.Append("</returnUrl><currencyCode>");
        sRequest.Append(sCurrencyCode);
        sRequest.Append("</currencyCode><feesPayer>");
        sRequest.Append(sFeesPayer);
        sRequest.Append("</feesPayer><memo>");
        sRequest.Append(sMemo);
        sRequest.Append("</memo><receiverList><receiver><amount>");
        sRequest.Append(sAmount);
        sRequest.Append("</amount><email>");
        sRequest.Append(Receiver);
        sRequest.Append("</email></receiver></receiverList><senderEmail>");
        sRequest.Append(Sender);
        sRequest.Append("</senderEmail><trackingId>");
        sRequest.Append(sTrackingID);
        sRequest.Append("</trackingId></PayRequest>");


        // 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();
+9
source

, , . , PayPal " ". . PayPal #

+1

All Articles