locked
First Data Web Service API Integration Problem RRS feed

  • Question

  • User-1254167453 posted

    Hi,

    I'm trying to use the First Data Global Gateway web service API. I was able to reverence the WSDL file in VS and get the classes to show up. I get the error "Object reference not set to an instance of an object." I can't figure out what I'm doing wrong.

    FDGGWSApiOrderService OrderService = new FDGGWSApiOrderService();
            OrderService.Url = @"https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
            OrderService.ClientCertificates.Add(X509Certificate.CreateFromCertFile(ConfigurationManager.AppSettings["Keyfile"]));
            NetworkCredential nc = new NetworkCredential(ConfigurationManager.AppSettings["CredUser"], ConfigurationManager.AppSettings["CredPass"]);
            OrderService.Credentials = nc;
            FDGGWSApiActionRequest ActionRequest = new FDGGWSApiActionRequest();
            RecurringPayment recurring = new RecurringPayment();
            // Sets for new recurring payment
            recurring.Function = RecurringPaymentFunction.install;
            // Info for Recurring Payment
            RecurringPaymentInformation recurinfo = new RecurringPaymentInformation();
            recurinfo.InstallmentCount = "99";
            recurinfo.InstallmentFrequency = "1";
            recurinfo.InstallmentPeriod = RecurringPaymentInformationInstallmentPeriod.year;
            recurinfo.MaximumFailures = "3";
            DateTime date = DateTime.Now;
            string strDate = date.ToString("yyyyMMdd");
            recurinfo.RecurringStartDate = strDate;
            recurring.RecurringPaymentInformation = recurinfo;
            // Card Data
            CreditCardData CardData = new CreditCardData();
            CardData.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.CardNumber, ItemsChoiceType.ExpMonth, ItemsChoiceType.ExpYear, ItemsChoiceType.CardCodeValue };        
            CardData.Items = new string[] { "4111111111111111", "05", "2015", "598" };
            // Next line is where the ERROR occurs
            recurring.TransactionDataType.Item = CardData;
            // Add Billing Address
            Billing BillAddr = new Billing();        
            BillAddr.Name = "Kris Scheppe";        
            BillAddr.Address1 = "3446 Marinatown Ln.";
            //BillAddr.City = txtCcCity.Text;
            BillAddr.City = "Fort Myers";        
            BillAddr.State = "FL";        
            BillAddr.Zip = "33080";
            BillAddr.Country = "US";
            recurring.Billing = BillAddr;
            // Set the Order Id        
            recurring.OrderId = "1590";
            // Set Payment Amount
            Payment charge = new Payment();        
            charge.ChargeTotal = 120.00M;
            recurring.Payment = charge;        
            TransactionDetails txnDetails = new TransactionDetails();        
            txnDetails.OrderId = "21";        
            txnDetails.PONumber = "2106";
            recurring.TransactionDetails = txnDetails;
            FDGGWSAPI.Action action = new FDGGWSAPI.Action();
            action.Item = recurring;
            ActionRequest.Item = action;
            // Get the Response
            FDGGWSApiActionResponse response = null;
            OrderService.FDGGWSApiAction(ActionRequest);
            if (response.ProcessorResponseMessage == "APPROVED")
            {
                MultiView1.SetActiveView(vwSuccess);
            }
            else
            {
                lblError.Text = response.ErrorMessage;
                lblStatus.Text = response.TransactionResult;
                MultiView1.SetActiveView(vwFailure);
            }


    Any help you can provide would be appreciated.


    Thanks,

    its4net

    Thursday, January 27, 2011 2:12 PM

Answers

  • User-833064204 posted

    Put a breakpoint there and see what the null object is. It might be that recurring.TransactionDataType is null, so accessing the .Item property on a null object would throw that exception.

    Another issue may be the setter on either the .TransactionDataType property, or the .Item property. Usually though, it is something simple.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 27, 2011 5:10 PM

All replies

  • User-833064204 posted

    First, it struck me as odd that the web service URL is the WSDL; ususally that just describes the service.

    The null reference looks like it comes from here:

             FDGGWSApiActionResponse response = null;  
             OrderService.FDGGWSApiAction(ActionRequest);  
    


    Maybe should be

    FDGGWSApiActionResponse response = OrderService.FDGGWSApiAction(ActionRequest);  
    


    Thursday, January 27, 2011 2:31 PM
  • User-1254167453 posted

    The error is on line 25. I had a comment in the code, but should have spelled it out. You did find another unrelated error I had though. Thanks

    recurring.TransactionDataType.Item = CardData;

    Can someone help me fix this?

    Thursday, January 27, 2011 3:17 PM
  • User-833064204 posted

    Put a breakpoint there and see what the null object is. It might be that recurring.TransactionDataType is null, so accessing the .Item property on a null object would throw that exception.

    Another issue may be the setter on either the .TransactionDataType property, or the .Item property. Usually though, it is something simple.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 27, 2011 5:10 PM
  • User-1254167453 posted

    I have fixed the main error, but now I get a 401 Unauthorized. I have double checked my credentials and they are correct. I downloaded a new certificate also. Am I implementing the credentials and certificate correctly?

    Here's the wsdl for the web service. https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl


    Thanks for the help.

    Friday, January 28, 2011 3:35 PM
  • User-833064204 posted

    I think your service URL is wrong. Look at the WSDL file. At the end, it describes a service location

    <soap:address location="https://ws.merchanttest.firstdataglobalgateway.com:443/fdggwsapi/services"/>


    Friday, January 28, 2011 4:31 PM
  • User-1254167453 posted

    I changed the url to

    https://ws.merchanttest.firstdataglobalgateway.com:443/fdggwsapi/services

    and still get the 401 unauthorized error.

    Friday, January 28, 2011 7:08 PM
  • User-1671285282 posted

    its4net,

    Have you been able to make any progress on this?  I am getting the exact same 401 unauthorized error but have been unable to solve the problem.  Any insight you can provide would be greatly appreciated.

    Thanks in advance,

    Kevin

    Thursday, March 24, 2011 1:46 PM
  • User1104292053 posted

    Anyone get a resolution to their "401 unauthorized" errors? I have the same issue.

     

    Edit:

     

    I got my issue resolved. I had to contact FirstData support and have them reset / regenerate my password and certificate files.

    Tuesday, March 29, 2011 11:34 AM
  • User872749926 posted

    I can verifiy that recently as of 4.25.2012 FirstData still has this problem when creating new SOAP or WebConnect 1.0 clients.

    I have created 4 accounts brand new and every one of the downloaded certificates, passwords and pem files were not valid.

    I was recieving the 401 Unauthrorized exception as well.  And I can tell you this.

    1)  You need to make sure you install the WSXXXXXXXX._.1.p12 into your local certificate store.  You need to use the p12.pw.txt when importing it.

    2) You need to verify you have the host process permissions to access the WSXXXXXXX._.1.pem file.

    3) When creating your connection make sure you use the WSXXXXXXXX._.1auth.txt and the store number.

    If you see SSL/TTL error messages you are not leaving your machine.  You need to ensure you have the certificate "p12 file" in your local computer installed correctly specifically the ._.1.p12 file with the correct permissions.

    If you see anything about not establishing a connection.  the process is not able to find your ._.1.pem file.

    If you see a 401 unauthorized net exception.  Time to call first data support because your certificates are bad and they need to regenerate them server side and repost them so you can download them.  

    NOTE: if you do have to have them regenerate your files.  Please remove all reference of the previous tar files and remove the certificate from yoru local key store as well as remove the pem file.  

    I have literaly spent days of my life on the phone with these people.  

    Stagging is not like production.  They have several issues that exist in staging or in production but not in stagging.  Currently they do not support same day peroidic payments.  You will need to address this by adding +1 days etc for testing. 

    They had could still have issues with the old HTTP protocol Expect100Continue flag.   In production it is not used but in staging it was.  They appear to have fixed that but if you continue to have issues it may be back in stagging.  You set this when establishing your connection. I externalized all these attributes and use injection based on my environment.  

    Good luck.

    Wednesday, April 25, 2012 4:56 PM
  • User1013248257 posted

    Hi,

    I am trying to integrate the Firstdata Web  services API with my web site with ASP classic.I cant find anywhere sample codes with ASP classic.

    Firstdata has just the sample for ASP.net since I am new on ASP.net and the web site is with ASP I can not Integrate the web services API.

    I created codes with ASP just conformed from ASP.net but when I run the soap.asp ...it says HTTP 202 Accepted I assume I did something wrong.

    Here is my codes can any one help me please ....

    thank you in advance.

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/xml; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>

    <%

    dim strURL, strMethod, strPostData


    Dim lngTimeout
    Dim strUserAgentString
    Dim intSslErrorIgnoreFlags
    Dim blnEnableRedirects
    Dim blnEnableHttpsToHttpRedirects
    Dim strHostOverride
    Dim strLogin
    Dim strPassword
    Dim strResponseText
    Dim objWinHttp

    strURL="https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"
    strMethod = "POST"
    strPostData="" &_
    "<?xml version=""1.0"" encoding=""UTF-8""?>" &_
    "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">" &_
    " <SOAP-ENV:Header />" &_
    " <SOAP-ENV:Body>" &_
    " <fdggwsapi:FDGGWSApiOrderRequest xmlns:fdggwsapi= ""http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"">" &_
    " <v1:Transaction xmlns:v1=""http://secure.linkpt.net/fdggwsapi/schemas_us/v1"">" &_
    " <v1:CreditCardTxType>" &_
    " <v1:Type>sale</v1:Type>" &_
    " </v1:CreditCardTxType>" &_
    " <v1:CreditCardData>" &_
    " <v1:CardNumber>4012000033330026</v1:CardNumber>" &_
    " <v1:ExpMonth>12</v1:ExpMonth>" &_
    " <v1:ExpYear>12</v1:ExpYear>" &_
    " </v1:CreditCardData>" &_
    " <v1:Payment>" &_
    " <v1:ChargeTotal>120</v1:ChargeTotal>" &_
    " </v1:Payment>" &_
    " </v1:Transaction>" &_
    " </fdggwsapi:FDGGWSApiOrderRequest>" &_
    " </SOAP-ENV:Body>" &_
    "</SOAP-ENV:Envelope>"

    lngTimeout = 59000
    strUserAgentString = "http_requester/0.1"
    intSslErrorIgnoreFlags = 13056 ' 13056: ignore all err, 0: accept no err
    blnEnableRedirects = True
    blnEnableHttpsToHttpRedirects = True
    strHostOverride = ""

    strLogin = "WS1XXXXXXX._.1"
    strPassword = "XXXXX"

    Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    objWinHttp.SetTimeouts lngTimeout, lngTimeout, lngTimeout, lngTimeout
    objWinHttp.Open strMethod, strURL

    If strMethod = "POST" Then
    objWinHttp.setRequestHeader "Content-type", _
    "application/x-www-form-urlencoded"
    End If

    If strHostOverride <> "" Then
    objWinHttp.SetRequestHeader "Host", strHostOverride
    End If

    objWinHttp.Option(0) = strUserAgentString
    objWinHttp.Option(4) = intSslErrorIgnoreFlags
    objWinHttp.Option(6) = blnEnableRedirects
    objWinHttp.Option(12) = blnEnableHttpsToHttpRedirects

    objWinHttp.SetCredentials "WS1XXXXXXX._.1", "XXXXXX", 0
    ' If (strLogin <> "") And (strPassword <> "") Then
    ' objWinHttp.SetCredentials strLogin, strPassword, 0
    'End If

    objWinHttp.setClientCertificate "LOCAL_MACHINE\My\WS1XXXXXX._.1"

    On Error Resume Next

    objWinHttp.Send(strPostData)

    If Err.Number = 0 Then
    If objWinHttp.Status = "200" Then
    GetDataFromURL = objWinHttp.ResponseText
    Else
    GetDataFromURL = "HTTP " & objWinHttp.Status & " " & _
    objWinHttp.StatusText
    End If
    Else
    GetDataFromURL = "Errora_a " & Err.Number & " " & Err.Source & " " & _
    Err.Description
    End If

    Response.Write(GetDataFromURL)
    On Error GoTo 0
    Set objWinHttp = Nothing

    %>
    </body>
    </html>

     

    Tuesday, July 31, 2012 10:06 PM
  • User1013248257 posted

    Hello,

    I have been trying to integrate firstdata web service API ,for almost three weeks.

    But I couldnt run the application,can anyone help me with the issue,

    here is my codes I dont know where I am doing wrong thank you..

    Here is the error :

     

    Server Error in '/' Application.


    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

    Parser Error Message: Could not load type 'WebApplication4.Default'.

    Source Error: 

    Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4.Default" %> Line 2:  
    Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Source File: /Webapplication4/webapplication4/default.aspx Line: 


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

    Here is the codes...

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using WebApplication4.WebReference;
    namespace WebApplication4
    {
    public partial class Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    ServicePointManager.Expect100Continue = false;
    // Initialize Service Object
    FDGGWSApiOrderService oFDGGWSApiOrderService = newFDGGWSApiOrderService();
    // Set the WSDL URL
    oFDGGWSApiOrderService.Url = @"https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";

    // Configure Client Certificate
    oFDGGWSApiOrderService.ClientCertificates.Add(X509Certificate.CreateFromCertFile("C:/ FDGGWS_Certificate_WSXXXXX._.1/WXXXXX._.1.pem"));

    // Set the Authentication Credentials
    NetworkCredential nc = new NetworkCredential("WSXXXXXX._.1", "XXXXXX");
    oFDGGWSApiOrderService.Credentials = nc;
    // Create Sale Transaction Request
    FDGGWSApiOrderRequest oOrderRequest = new FDGGWSApiOrderRequest();
    Transaction oTransaction = new Transaction();
    CreditCardTxType oCreditCardTxType = new CreditCardTxType();
    oCreditCardTxType.Type = CreditCardTxTypeType.sale;
    CreditCardData oCreditCardData = new CreditCardData();
    oCreditCardData.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.CardNumber, ItemsChoiceType.ExpMonth, ItemsChoiceType.ExpYear };
    oCreditCardData.Items = new string[] { "4012000033330026", "12", "12" };
    oTransaction.Items = new object[] { oCreditCardTxType, oCreditCardData };
    Payment oPayment = new Payment();
    oPayment.ChargeTotal = 1;
    oTransaction.Payment = oPayment;
    oOrderRequest.Item = oTransaction;
    // Get the Response
    FDGGWSApiOrderResponse oReponse = null;
    try
    {
    oReponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oOrderRequest);
    string sApprovalCode = oReponse.TransactionResult;
    TextBox1.Text = oReponse.TransactionResult;


    }
    catch (System.Web.Services.Protocols.SoapException ex)
    {
    // Catch the Exception }

    }
    }


    private FDGGWSApiOrderService newFDGGWSApiOrderService()
    {
    throw new NotImplementedException();
    }

    }
    }

    thank you.

    Tuesday, August 14, 2012 2:30 PM
  • User1013248257 posted

    It's working Thank you!

    Tuesday, August 14, 2012 9:31 PM
  • User1339196 posted

    Completly Working code for recurring through First Data Global Gateway FDGG Webservice

               
       ServicePointManager.Expect100Continue = false;
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
                   
                FDGGWSApiOrderService OrderService = new FDGGWSApiOrderService();
                OrderService.Url = @"https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
                OrderService.ClientCertificates.Add(X509Certificate.CreateFromCertFile("C:/FDGGWSClient/WS1909002996._.1.pem"));
    
                //Set the Authentication Credentials 
    
                NetworkCredential nc = new NetworkCredential("YourStoreNumber", "YourStorePassword");
                OrderService.Credentials = nc;
                FDGGWSApiActionRequest ActionRequest = new FDGGWSApiActionRequest();
    
    
                RecurringPayment recurring = new RecurringPayment();
    
                // Sets for new recurring payment
                recurring.Function = RecurringPaymentFunction.install;
    
                // Info for Recurring Payment
                RecurringPaymentInformation recurinfo = new RecurringPaymentInformation();
                recurinfo.InstallmentCount = "99";
                recurinfo.InstallmentFrequency = "1";
                recurinfo.InstallmentPeriod = RecurringPaymentInformationInstallmentPeriod.day;
                recurinfo.MaximumFailures = "3";
                DateTime date = DateTime.Now;
                string strDate = date.ToString("20120824");
                recurinfo.RecurringStartDate = strDate;
                recurinfo.InstallmentPeriodSpecified = true;
              
                recurring.RecurringPaymentInformation = recurinfo;
                // Card Data
                CreditCardData CardData = new CreditCardData();
                CardData.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.CardNumber, ItemsChoiceType.ExpMonth, ItemsChoiceType.ExpYear};
                CardData.Items = new string[] { "4111111111111111", "05", "15"};
    
          
    
                RecurringPaymentTransactionDataType oRecurringPaymentTransactionDataType = new RecurringPaymentTransactionDataType();
    
                oRecurringPaymentTransactionDataType.Item=CardData;
    
    
                recurring.TransactionDataType=oRecurringPaymentTransactionDataType;
    
             
                // Add Billing Address
                            Billing BillAddr = new Billing();
                BillAddr.Name = "Kris Scheppe";
                BillAddr.Address1 = "3446 Marinatown Ln.";
                //BillAddr.City = txtCcCity.Text;
                BillAddr.City = "Fort Myers";
                BillAddr.State = "FL";
                BillAddr.Zip = "33080";
                BillAddr.Country = "US";
                recurring.Billing = BillAddr;
                // Set the Order Id
                recurring.OrderId = "1590";
                // Set Payment Amount
                Payment charge = new Payment();
                charge.ChargeTotal = 120.00M;
                recurring.Payment = charge;
                TransactionDetails txnDetails = new TransactionDetails();
                txnDetails.OrderId = "21";
                txnDetails.PONumber = "2106";
                recurring.TransactionDetails = txnDetails;
    
          
    
                Test.WebReference.Action action = new Test.WebReference.Action();
                action.Item = recurring;
                ActionRequest.Item = action;
                // Get the Response
                FDGGWSApiActionResponse response = null;
                response = OrderService.FDGGWSApiAction(ActionRequest);
    
        
                if (response.ProcessorResponseMessage == "APPROVED")
                {
                   
                }
                else
                {
                  
                }
    
    
    
    Thursday, August 23, 2012 11:00 AM
  • User1090722982 posted
    I think this like is wrong CardData.Items = new string[] { "4111111111111111", "05", "2015", "598" }; the expiration year have to be 2 digit
    Wednesday, August 21, 2013 11:44 AM