1

My employer has an application he wants to make a change to. The application itself is used to process payment information and it is a desktop application.

It was pretty much just dropped in my lap. The former API used was Authorize.Net to handle credit card stuff and now he's switching over to the PayPal API.

While that may be great for him, it sucks for me as my experience with web development is near nil. I am endeavoring to keep this as a desktop application, but everything I've seen screams "ASP.NET ASP.NET ASP.NET", and as far as I am aware, ASP.NET is for web applications.

Is there any way that I can just do this in a windows form application? Is there a step-by-step for the hopelessly clueless as to how to implement the PayPal API in a C# .Net WinForms Desktop application?

Will
  • 3,413
  • 7
  • 50
  • 107
  • You might want to take a look at [USBSwiper](http://www.usbswiper.com). It's a basic POS solution that works with PayPal already, and can be installed on Windows or Mac. – Drew Angell Jun 13 '14 at 22:50

2 Answers2

2

You are going to have to implement a web service to talk to the PayPal API. However, you will be able to call the web service from your Winforms application. Try this StackOverflow question and answer:

Call webservice in windows application

Also, the references you are seeing should be to ASP.Net, which is different from ASP, which is Active Server Pages and is older technology.

Community
  • 1
  • 1
SeraM
  • 487
  • 4
  • 10
1

So it turns out I was making it WAY more complicated than it needed to be. While before it was necessary with the Authorize.net to do stuff, with PayPal it actually requires (for our purposes, your mileage may vary) nothing from them other than having your stuff set up. All it requires is for you to post some properly formatted information to a url:

sUrl = "https://pilot-payflowpro.paypal.com"
WebRequest request = WebRequest.Create( sUrl );
request.Method = "POST";
string PostData =
                "USER=/*User*/" + 
                "&VENDOR=/*Vendor*/" +
                "&PARTNER=PayPal" + 
                "&PWD=/*PassWord*/" + 
                "&TRXTYPE=S" +
                "&TENDER=C" +
                "&ACCT=/*CC#*/" +
                "&EXPDATE=/*CC Expiration Date*/" +
                "&CVV2=/*CCV Code*/" +
                "&AMT=/*Order Amount*/" +
                "&FIRSTNAME=/*First Name*/" +
                "&LASTNAME=/*Last Name*/" +
                "&STREET=/*Address Street*/" +
                "&CITY=/*Address City*/" +
                "&STATE=/*Address State*/" +
                "&ZIP=/*Zip Code*/" +
                "COMMENT1=/*Any Comment*/";

byte[] bar = Encoding.UTF8.GetBytes( PostData );
                request.ContentLength = bar.Length;

            using ( Stream datStream = request.GetRequestStream( ) ) {
                datStream.Write( bar, 0, bar.Length );
                datStream.Close( );
            }
            string serverResponse;
            WebResponse wResp = request.GetResponse( );
            using ( Stream datStream = wResp.GetResponseStream( ) ) 
                using ( StreamReader datSReader = new StreamReader( datStream ) ) 
                    serverResponse = datSReader.ReadToEnd( );
            this.Response = HttpUtility.ParseQueryString(serverResponse);
            IsSuccess = this.Response.Get( "RESULT" ) == "0";
            if ( !IsSuccess ) MessageBox.Show( "RESULT != 0: RESULT = " + this.Response.Get( "RESULT" ) );
            return IsSuccess;

This code, in its form before it was changed, came straight from the guys at PayPal, and made it a lot easier to manage transactions via a windows form application.

Will
  • 3,413
  • 7
  • 50
  • 107
  • Forgive me, is it possible you can provide some code sample or a more detail way to implement your code? I am still amateur in programming. – Pigeon Mar 11 '15 at 21:13