ASP.NET NVP SAMPLE

VERSION 5.6.53

ASP.NET application demonstrating PayPal Web Service calls, including Direct Payment and Express Checkout.

Documentation

PayPal Integration Center
PayPal User Guides
API Documentation

CERTIFICATE TOOL

To run this sample, you need to ensure that the WinHttpCertCfg (Windows HTTP Services Certificate Configuration Tool) executable is in your PATH. You can download WinHttpCertCfg.exe from the following location: http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=winhttpcertcfg&DisplayLang= en

CONFIGURE IIS

When using IIS 6.0, special permissions need to be enabled. In the IIS MMC
Panel, go to "Internet Information Services" -- <YOUR MACHINE NAME> -- Web Service Extensions. Make sure "ASP.NET" is set to "Allowed" in the right hand panel. By default, it is set to "Prohibited".

UNZIP THE NVP SAMPLE

  1. Run \PayPal ASP.NET NVP SDK\Samples\AspNet\InstallSample.bat
  2. To enable logging, add "Full Control" permissions to the logs folder for the appropriate user:
    IIS 6.0: The username used to run IIS, which is "NETWORK SERVICE" by default. pre IIS 6.0: <MACHINE NAME>\ASPNET where <MACHINE NAME> is the name of your local machine.
The default PayPal API credentials used by these samples are:
	API Username: sdk-seller_api1.sdk.com
	API Password: 12345678
	Path to API certificate: \samples\Cert\sdk-seller.p12

RUN THE SAMPLE

Go to http://localhost/PayPalAspNetNvpSamples

CONFIGURE THE SAMPLE WITH YOUR OWN MERCHANT CREDENTIALS

  1. Use openssl to convert the downloaded PayPal certificate (PEM) to the P12 format:
    openssl pkcs12 -export -inkey cert_key_pem.txt -in cert_key_pem.txt -out mycert.p12
  2. Install the certificate into the Microsoft system store and grant access permission to the private key:
    WinHttpCertCfg -i mycert.p12 -p <Export Password> -c LOCAL_MACHINE\My -a ASPNET
  3. In the \samples\ASPNET\Constants.cs class, change the values of API_USERNAME, API_PASSWORD, and SUBJECT to your own credentials:
      	#region Profile
    		public const string API_USERNAME = "sdk-seller_api1.sdk.com";
    		public const string API_PASSWORD = "12345678";
            /// If you are running the samples on behalf of a third-party
            /// account, set SUBJECT to that third-party account's PayPal login id.
    		public const string SUBJECT = "";
            /// Do not change ENVIRONMENT
    		public const string ENVIRONMENT = "sandbox";
    	#endregion
    	

4. Rebuild the  AspNetSamples_Nvp project.

COOKIELESS ASP.NET SESSIONS

You may have noticed that we are using cookieless sessions in the ASP.NET Samples.  Due to the implementation of ASP.NET, a session seems to be reset if we redirect outside of the site, then back in.  This is required in the implementation of ExpressCheckout.  Since we store the Profile in the session object, the session needs to be maintained across calls in the ExpressCheckout flow.

Provide Proxy Support for .NET NVP SDK

Right now, if a user is behind a proxy, they are unable to make a NVP call to PayPal. This feature would provide a method for such users to connect to PayPal. To enable proxy support in the .NET SDK, we rely on the built-in <system.net> section of web.config.  Please refer to MSDN documentation for details on how to use <system.net> in web.config.By default proxy support in the .NET SDK is not used.

TROUBLESHOOTING

Here are solutions to problems you might encounter.
  1. Cannot find WinHttpCertCfg in your PATH.
    Solution: Make sure you have downloaded and installed the Windows HTTP Services Certificate Configuration Tool (WinHttpCertCfg.exe) and included its location on your system in the PATH environment variable. See the "DOWNLOAD MICROSOFT CERTIFICATE TOOL" section, above.
  2. Unable to load the binding classes.
    Solution: Make sure that the user account running your web application has READ and WRITE permission for the directory specified in the TEMP environment system variable. When instantiating the proxy classes, .NET Framework creates an XML serialization assembly in this directory.
  3. COMException(0x80880253): The Signer's certificate is not valid for signing
    Solution: The sample is found NOT to work on Windows2000 machine due to AES algorithm not being supported by it.
  4. The underlying connection was closed: Could not establish secure channel for SSL/TLS.
    Solution 1: Make sure the proper user account was granted access to the certificate. To list all accounts with access to a private key, type: WinHttpCertCfg -l -c LOCAL_MACHINE\My -s sdk-seller_api1.sdk.com Solution 2: Verify that you have installed .NET Framework Service Pack 1 and other Microsoft Service Packs.