Help Center - Personal Account
  • Home
  • Payments and Transfers
  • Disputes and Limitations
  • My Account
  • My Wallet
  • Login & Security
  • Seller Tools

How do I set up and process an API call using the Payflow .NET SDK?

To set up and process an API call, download the Payflow .NET SDK from GitHub and extract the files from .zip to install the SDK.

Disclaimer: This code isn't intended to be used in a production environment; it's just an example and should be used as such. The code is supplied "as is" with no warranty and should be used only for reference. This tutorial shows you how to set up and process an API call using the Payflow .NET SDK using Microsoft Visual Studio. When finished, you'll be able to communicate with the server and see a response on the page.

Download the Payflow .NET SDK

  1. Log in to your GitHub account and download the Payflow.NET SDK.
  2. Extract the files from the .zip file and install the SDK.
  3. Once the SDK is installed, rename the file from payflow_dotNET_2.0.dll to payflow_dotNET.dll.

Create a new project in Visual Studio

  1. Open Visual Studio.
  2. Select File > New Project.

Create a new application

  1. For this example, create a C#, ASP.NET Web Application called "MyFirstAPICall".
  2. Click OK, and you'll see your first page, Default.aspx.

Reference the Payflow_dotNET.dll file

  1. Right-click References under Solution Explorer, then select Add Reference.
  2. On the Browse tab, go to the Payflow_dotNET.dll file, then click OK.

Add a new button to the page

  1. Go back to the Default.aspx page.
  2. Click Design.
  3. Drag a Button from the toolbox onto the page.

View the button code and add using statements

  1. Double-click the new button.
  2. By default you'll see the following code: 
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    namespace MyFirstAPICall{

    public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e){

    protected void Button1_Click(object sender, EventArgs e){
  3. Add the following statements to the "using" section to include the PayPal SDK DLL for the file: 
    using PayPal.Payments.Common.Utility;
    using PayPal.Payments.Communication;
    using PayPal.Payments.DataObjects;

Add code for the Button1_Click function

  1. The following is sample code for the Button1_Click function:  

  1. //Set your API Credentials 

  1. ///////////////////////////////////////////// 



  1. ///////////////////////////////////////////// 


  1. string USER = "xxxx"; 

  1. string VENDOR = "xxxx"; 

  1. string PARTNER = "PayPal"; 

  1. string PWD = "xxxxx"; 


  1. //set the port 

  1. int hostPort = 443; 


  1. //set the timeout 

  1. int timeOut = 30; 


  1. //set the host address (pilot-) for testing 

  1. string hostAddress = ""; 


  1. //build a test request string 

  1. string Request = "USER=" + USER + "&PWD=" + PWD + "&VENDOR=" + VENDOR + "&PARTNER=" + PARTNER 

  1. + "&TRXTYPE=S&TENDER=C&ACCT=4111111111111111&EXPDATE=1213&CVV2=123&AMT=99.00&FIRSTNAME=John&LASTNAME=Smith&STREET=123 

  1. Main St.&CITY=San Jose&STATE=CA&ZIP=12345&COMMENT1=Reservation&VERBOSITY=MEDIUM"; 


  1. //build a Payflow API Object with the address, port, and timeout 

  1. PayflowNETAPIpfObj = new PayflowNETAPI(hostAddress, hostPort, timeOut); 


  1. //set the response variable to the value of the response from the call and make the call 

  1. string response = pfObj.SubmitTransaction(Request + PayflowUtility.RequestId, PayflowUtility.RequestId); 


  1. //get the status from the response 

  1. string status = PayflowUtility.GetStatus(response); 


  1. //print the status to the page 

  1. Response.Write(status); 

  1. Response.Write("<br />");//line break 


  1. //API Request: 

  1. Response.Write("API Request:\n"); 

  1. Response.Write("<br />");//line break 


  1. //print the raw request string to the page 

  1. Response.Write(Request); 

  1. Response.Write("<br />");//line break 


  1. //API Response: 

  1. Response.Write("\nAPI Response:\n"); 

  1. Response.Write("<br />");//line break 


  1. //print the raw API response String to the page 


  1. Set the USER, VENDOR, PARTNER, and PWD variables to your API credentials for the Payflow API. 

  1. Set the preceding code between the curly braces for the Button1_Click function. 

Build and run the application

  1. Under Build, select Build MyFirstAPICall.
  2. Click the green arrow to run the application. 
  3. Your browser will open you'll see the button, which will be labeled Button (unless you changed it).
  4. Click the button to show your API Request and Response.

More ways we can help

We’ll use cookies to improve and customize your experience if you continue to browse. Is it OK if we also use cookies to show you personalized ads? Learn more and manage your cookies