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);
}
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.
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?
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.
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.
its4net
Member
1 Points
4 Posts
First Data Web Service API Integration Problem
Jan 27, 2011 06:12 PM|LINK
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
WSDL API eCommerce Gateway First Data
doyleits
Contributor
3580 Points
549 Posts
Re: First Data Web Service API Integration Problem
Jan 27, 2011 06:31 PM|LINK
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
Collabroscape LLC [www.collabroscape.com]
its4net
Member
1 Points
4 Posts
Re: First Data Web Service API Integration Problem
Jan 27, 2011 07:17 PM|LINK
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
Can someone help me fix this?
doyleits
Contributor
3580 Points
549 Posts
Re: First Data Web Service API Integration Problem
Jan 27, 2011 09:10 PM|LINK
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.
Collabroscape LLC [www.collabroscape.com]
its4net
Member
1 Points
4 Posts
Re: First Data Web Service API Integration Problem
Jan 28, 2011 07:35 PM|LINK
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.
doyleits
Contributor
3580 Points
549 Posts
Re: First Data Web Service API Integration Problem
Jan 28, 2011 08:31 PM|LINK
I think your service URL is wrong. Look at the WSDL file. At the end, it describes a service location
Collabroscape LLC [www.collabroscape.com]
its4net
Member
1 Points
4 Posts
Re: First Data Web Service API Integration Problem
Jan 28, 2011 11:08 PM|LINK
I changed the url to
and still get the 401 unauthorized error.
kkallberg
Member
2 Points
1 Post
Re: First Data Web Service API Integration Problem
Mar 24, 2011 05:46 PM|LINK
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
rally25rs
Member
2 Points
1 Post
Re: First Data Web Service API Integration Problem
Mar 29, 2011 03:34 PM|LINK
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.
XMLViking
Member
452 Points
91 Posts
Re: First Data Web Service API Integration Problem
Apr 25, 2012 08:56 PM|LINK
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.