1

I have compiled a simple ASP.NET project to test first data global gateway API Integration.

Someone tell me what to do because I have tried everything.

It throws the ERROR if I use ASP.NET Development server:
<r_error> Unable to load certificate   ERRs: wsa=33558530 err=33558530 ssl=537317504 sys=33558530.  INFO: ACE_SSL (5260|6284) error code: 33558530 - error:02001002:lib(2):func(1):reason(2)
</r_error>

ERROR if I use Virtual Directory: This is generated when

//Call LPTxn
string resp = LPTxn.send(keyfile, host, port, outXml);

is done

ERROR: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Testing On:

Windows 7 ultimate 64 bit

Project at the root have:

default.aspx 
status.aspx
111222333.pem

Bin:

LinkPointTransaction.dll
lpssl.dll
libeay32.lib
libssl32.dll
ssleay32.lib

Web.Config just showing this to make sure:

<client>
      <!-- Change this to your store number -->
      <add key="Configfile" value="xxxxx"/>
      <!-- Change this to the name and location of your certificate file -->
      <add key="Keyfile" value="111222333.pem"/>
      <add key="Host" value="xxx.xxx.net"/>
      <add key="Port" value="1129"/>
</client>
Mike Wills
  • 20,959
  • 28
  • 93
  • 149
Pirzada
  • 4,685
  • 18
  • 60
  • 113
  • I won't post an answer yet, because I'm not at home where I have my sample code, but from personal experience using their DLL is almost impossible to make work. Instead use the web services (I'll post the code in a few hours and you can decide if it's an acceptable path to take). – Peter Aug 12 '11 at 18:56
  • Patricker . I would really appreciate if you post WebService sample code. I have tried WebService but its not working for me using Test account. Gives me 104 Authorization error. Contacted First data and they regenerated my Credentials but still get that error and can not pass it. Please help me. – Pirzada Aug 12 '11 at 21:55
  • error is "The request failed with HTTP status 401: Unauthorized." – Pirzada Aug 12 '11 at 22:05
  • @Patricker any help please with webservices? – Pirzada Aug 13 '11 at 11:56

4 Answers4

4

Sorry for the delay in getting back to you. Below is the code I used. In particular take a look at how BuildOrderService sets up the certificate.

Response

Public Class CLinkTransResponse
    Public ApprovalCode As String
    Public ErrorMessage As String
    Public OrderId As String
    Public TransactionID As String
    Public TransactionResult As String


    Public Sub New()
        ApprovalCode = ""
        ErrorMessage = ""
        OrderId = ""
        TransactionID = ""
        TransactionResult = ""
    End Sub
End Class

Settings

--XML File--

<?xml version="1.0" encoding="utf-8"?>
<LinkPointSettings>
  <OrderServiceUrl>https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl</OrderServiceUrl>
  <P12File>WS{texthere}._.1.p12</P12File>
  <!-- From .auth.txt-->
  <username>WS{texthere}._.1</username>
  <password>{texthere}</password>
  <!-- From .p12.pw.txt-->
  <P12Pw>{texthere}</P12Pw>  
</LinkPointSettings>

--Code--

Imports System.IO
Imports System.Web

Friend Class CLinkPointSettings
    Private sOrderServiceUrl As String
    Private sP12File As String
    Private sP12Pw As String
    Private susername As String
    Private spassword As String

    Public Sub New()
        ' Read XML Link Point Settings File
        Dim sXMLFile As String
        sXMLFile = HttpContext.Current.Server.MapPath("~/bin/xLinkPointSettings.xml")

        If Not File.Exists(sXMLFile) Then
            Return
        End If

        ' Read XML File
        Dim oXmlDoc As New System.Xml.XmlDocument
        oXmlDoc.Load(sXMLFile)

        sOrderServiceUrl = oXmlDoc.GetElementsByTagName("OrderServiceUrl")(0).InnerText
        sP12File = oXmlDoc.GetElementsByTagName("P12File")(0).InnerText
        sP12Pw = oXmlDoc.GetElementsByTagName("P12Pw")(0).InnerText
        susername = oXmlDoc.GetElementsByTagName("username")(0).InnerText
        spassword = oXmlDoc.GetElementsByTagName("password")(0).InnerText
    End Sub

    Public ReadOnly Property OrderServiceUrl() As String
        Get
            Return sOrderServiceUrl
        End Get
    End Property

    Public ReadOnly Property P12File() As String
        Get
            Return sP12File
        End Get
    End Property

    Public ReadOnly Property P12Pw() As String
        Get
            Return sP12Pw
        End Get
    End Property

    Public ReadOnly Property Username() As String
        Get
            Return susername
        End Get
    End Property

    Public ReadOnly Property Password As String
        Get
            Return spassword
        End Get
    End Property
End Class

Transaction

Imports FirstDataGlobalGateway.WebReference
Imports System.Security.Cryptography.X509Certificates
Imports System.Net
Imports System.IO
Imports System.Web

Public Class CLinkTransaction
    Public Sub New()
        ServicePointManager.Expect100Continue = False
    End Sub

    ''' <summary>
    ''' charge credit card
    ''' </summary>
    ''' <param name="cardNumber">Credit Card Number</param>
    ''' <param name="expMonth">expiry month</param>
    ''' <param name="expYear">expiry year</param>
    ''' <param name="chargeTotal">charge total(including tax,vat etc)</param>
    ''' <param name="billingInfo">Client Billing Information</param>
    ''' <returns>Returns True/False Transaction result</returns>
    ''' <remarks></remarks>    
    Public Function ChargeCreditCard(ByVal cardNumber As String, ByVal expMonth As String, _
                                     ByVal expYear As String, _
                                     ByVal ccv As String, _
                                     ByVal chargeTotal As Decimal, _
                                     ByVal billingInfo As Billing, ByRef transResponse As CLinkTransResponse) As Boolean

        Dim oFDGGWSApiOrderService As FDGGWSApiOrderService = BuildOrderService()

        ' Create sale transaction request
        Dim oFDGGWSApiOrderRequest As New FDGGWSApiOrderRequest()

        Dim oTransaction As New Transaction()

        Dim oCreditCardTxType As New CreditCardTxType()

        oCreditCardTxType.Type = CreditCardTxTypeType.sale

        Dim oCreditCardData As New CreditCardData()

        oCreditCardData.ItemsElementName = New ItemsChoiceType() {ItemsChoiceType.CardNumber, ItemsChoiceType.ExpMonth, ItemsChoiceType.ExpYear}

        oCreditCardData.Items = New String() {cardNumber, expMonth, expYear}

        oTransaction.Items = New Object() {oCreditCardTxType, oCreditCardData}

        Dim oPayment As New Payment() With {.ChargeTotal = chargeTotal}

        '' Set Billing Information
        'Dim oBilling As New Billing()

        'oBilling.Address1 = billingInfo.Address1
        'oBilling.Address2 = billingInfo.Address2
        'oBilling.City = billingInfo.City
        'oBilling.Company = billingInfo.Company
        'oBilling.Country = billingInfo.Country
        'oBilling.CustomerID = billingInfo.CustomerID
        'oBilling.Email = billingInfo.Email
        'oBilling.Fax = billingInfo.Fax
        'oBilling.Name = billingInfo.Name
        'oBilling.Phone = billingInfo.Phone
        'oBilling.State = billingInfo.State
        'oBilling.Zip = billingInfo.Zip

        oTransaction.Billing = billingInfo

        oFDGGWSApiOrderRequest.Item = oTransaction

        Try
            ' Get Response
            Dim oFDGGWSApiOrderResponse As FDGGWSApiOrderResponse

            oFDGGWSApiOrderResponse = Nothing

            oFDGGWSApiOrderResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oFDGGWSApiOrderRequest)

            transResponse.ApprovalCode = oFDGGWSApiOrderResponse.ApprovalCode
            transResponse.TransactionResult = oFDGGWSApiOrderResponse.TransactionResult
            transResponse.ErrorMessage = oFDGGWSApiOrderResponse.ErrorMessage
            transResponse.OrderId = oFDGGWSApiOrderResponse.OrderId
            transResponse.TransactionID = oFDGGWSApiOrderResponse.TransactionID

            If (transResponse.TransactionResult.ToLower() <> "approved") Then
                Return False
            End If

            Return True

        Catch ex As System.Web.Services.Protocols.SoapException
            transResponse.ErrorMessage = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' Perfrom Refund
    ''' </summary>
    ''' <param name="orderID">Order ID</param>
    ''' <param name="chargeTotal">Charge Total (Including Taxes)</param>
    ''' <param name="transResponse">Transaction Response</param>
    ''' <returns>Returns True/False</returns>
    ''' <remarks></remarks>
    Public Function PerformRefund(ByVal orderID As String, ByVal chargeTotal As Decimal, ByRef transResponse As CLinkTransResponse) As Boolean
        Dim oFDGGWSApiOrderService As FDGGWSApiOrderService = BuildOrderService()

        ' Create sale transaction request
        Dim oFDGGWSApiOrderRequest As New FDGGWSApiOrderRequest()

        Dim oTransaction As New Transaction()

        Dim oCreditCardTxType As New CreditCardTxType()

        oCreditCardTxType.Type = CreditCardTxTypeType.return

        oTransaction.Items = New Object() {oCreditCardTxType}

        Dim oPayment As New Payment()

        oPayment.ChargeTotal = chargeTotal

        oTransaction.Payment = oPayment

        Dim oTransactionDetails As New TransactionDetails()

        oTransactionDetails.OrderId = orderID

        oTransaction.TransactionDetails = oTransactionDetails

        oFDGGWSApiOrderRequest.Item = oTransaction

        Try
            ' Get Response
            Dim oFDGGWSApiOrderResponse As FDGGWSApiOrderResponse

            oFDGGWSApiOrderResponse = Nothing

            oFDGGWSApiOrderResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oFDGGWSApiOrderRequest)

            transResponse.ApprovalCode = oFDGGWSApiOrderResponse.ApprovalCode
            transResponse.TransactionResult = oFDGGWSApiOrderResponse.TransactionResult
            transResponse.ErrorMessage = oFDGGWSApiOrderResponse.ErrorMessage
            transResponse.OrderId = oFDGGWSApiOrderResponse.OrderId
            transResponse.TransactionID = oFDGGWSApiOrderResponse.TransactionID

            If (transResponse.TransactionResult.ToLower() <> "approved") Then
                Return False
            End If

            Return True

        Catch ex As System.Web.Services.Protocols.SoapException
            transResponse.ErrorMessage = ex.Message
            Return False
        End Try
    End Function
    ''' <summary>
    ''' Check Sale Transaction
    ''' </summary>
    ''' <param name="teleCheckData">TeleCheckData</param>
    ''' <param name="chargeTotal">Charge Total</param>
    ''' <param name="transResponse">Transaction Response</param>
    ''' <returns>Returns True/False</returns>
    ''' <remarks></remarks>
    Public Function CheckSaleTransaction(ByVal teleCheckData As TeleCheckData, ByVal chargeTotal As Decimal, ByRef transResponse As CLinkTransResponse) As Boolean
        Dim oFDGGWSApiOrderService As FDGGWSApiOrderService = BuildOrderService()

        ' Create sale transaction request
        Dim oFDGGWSApiOrderRequest As New FDGGWSApiOrderRequest()

        Dim oTransaction As New Transaction()

        Dim oTeleCheckTxType As New TeleCheckTxType()

        oTeleCheckTxType.Type = CreditCardTxTypeType.sale

        oTransaction.Items = New Object() {oTeleCheckTxType, teleCheckData}

        Dim oPayment As New Payment()

        oPayment.ChargeTotal = chargeTotal

        oTransaction.Payment = oPayment

        oFDGGWSApiOrderRequest.Item = oTransaction

        Try
            ' Get Response
            Dim oFDGGWSApiOrderResponse As FDGGWSApiOrderResponse

            oFDGGWSApiOrderResponse = Nothing

            oFDGGWSApiOrderResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oFDGGWSApiOrderRequest)

            transResponse.ApprovalCode = oFDGGWSApiOrderResponse.ApprovalCode
            transResponse.TransactionResult = oFDGGWSApiOrderResponse.TransactionResult
            transResponse.ErrorMessage = oFDGGWSApiOrderResponse.ErrorMessage
            transResponse.OrderId = oFDGGWSApiOrderResponse.OrderId
            transResponse.TransactionID = oFDGGWSApiOrderResponse.TransactionID

            If (transResponse.TransactionResult.ToLower() <> "approved") Then
                Return False
            End If

            Return True

        Catch ex As System.Web.Services.Protocols.SoapException
            transResponse.ErrorMessage = ex.Message
            Return False
        End Try
    End Function

    ''' <summary>
    ''' Void Transaction
    ''' </summary>
    ''' <param name="orderID">Order ID</param>
    ''' <param name="chargeTotal">Charge Total (Including Taxes)</param>
    ''' <param name="transResponse">Transaction Response</param>
    ''' <returns>Returns True/False</returns>
    ''' <remarks></remarks>
    Public Function VoidTransaction(ByVal orderID As String, ByVal chargeTotal As Decimal, ByRef transResponse As CLinkTransResponse) As Boolean
        Dim oFDGGWSApiOrderService As FDGGWSApiOrderService = BuildOrderService()

        ' Create sale transaction request
        Dim oFDGGWSApiOrderRequest As New FDGGWSApiOrderRequest()

        Dim oTransaction As New Transaction()

        Dim oTeleCheckTxType As New TeleCheckTxType()

        oTeleCheckTxType.Type = CreditCardTxTypeType.void

        oTransaction.Items = New Object() {oTeleCheckTxType}

        Dim oPayment As New Payment()

        oPayment.ChargeTotal = chargeTotal

        oTransaction.Payment = oPayment

        Dim oTransactionDetails As New TransactionDetails()

        oTransactionDetails.OrderId = orderID

        oTransaction.TransactionDetails = oTransactionDetails

        oFDGGWSApiOrderRequest.Item = oTransaction

        Try
            ' Get Response
            Dim oFDGGWSApiOrderResponse As FDGGWSApiOrderResponse

            oFDGGWSApiOrderResponse = Nothing

            oFDGGWSApiOrderResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oFDGGWSApiOrderRequest)

            transResponse.ApprovalCode = oFDGGWSApiOrderResponse.ApprovalCode
            transResponse.TransactionResult = oFDGGWSApiOrderResponse.TransactionResult
            transResponse.ErrorMessage = oFDGGWSApiOrderResponse.ErrorMessage
            transResponse.OrderId = oFDGGWSApiOrderResponse.OrderId
            transResponse.TransactionID = oFDGGWSApiOrderResponse.TransactionID

            If (transResponse.TransactionResult.ToLower() <> "approved") Then
                Return False
            End If

            Return True

        Catch ex As System.Web.Services.Protocols.SoapException
            transResponse.ErrorMessage = ex.Message
            Return False
        End Try
    End Function

    Private Function BuildOrderService() As FDGGWSApiOrderService

        Dim olinkpoint As New CLinkPointSettings()

        ServicePointManager.Expect100Continue = False

        Dim oFDGGWSApiOrderService As New FDGGWSApiOrderService()

        ' Set WSDL URL
        oFDGGWSApiOrderService.Url = olinkpoint.OrderServiceUrl

        ' Configure Client Certificate
        oFDGGWSApiOrderService.ClientCertificates.Add(
                New X509Certificate(HttpContext.Current.Server.MapPath("~/bin/" + olinkpoint.P12File), olinkpoint.P12Pw))


        ' Initialize Netwokr Credentials
        Dim oNetworkCredentials As New NetworkCredential(olinkpoint.Username, olinkpoint.Password)

        ' Assign network creditials
        oFDGGWSApiOrderService.Credentials = oNetworkCredentials

        Return oFDGGWSApiOrderService
    End Function
End Class
Peter
  • 9,643
  • 6
  • 61
  • 108
  • Thanks for the reply. I get error "The request failed with HTTP status 401: Unauthorized" at code oFDGGWSApiOrderResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oFDGGWSApiOrderRequest);. I have double checked .auth.txt & .p12.pw.txt and everything looks fine. I also noticed that you haven't use .pem file. I am testing your code on win7 local machine without virtual directory. Any idea what to do? – Pirzada Aug 16 '11 at 02:49
  • In your xml config file you have the values from the txt files and not references to the text files themselves, correct? And no, I don't use the .pem file. – Peter Aug 16 '11 at 03:01
  • @pirzada - you are using the test URL? ws.merchanttest.firstdataglobalgateway.com? – Peter Aug 16 '11 at 13:29
  • Yes I am using Test URL in xml file. – Pirzada Aug 16 '11 at 19:43
  • @pirzada - I went back to my test box and tried my code and it worked. I then went and setup a NEW test account with First Data Global Gateway and dropped the new files into my working code. When I tested with these new files I received the 401 unauthorized exception that you are receiving. Given this issue I would say that it's an issue with FDGG, have you tried calling them? – Peter Aug 17 '11 at 15:58
  • Thanks. Yes I called them and regenerated my files and downloaded to test but still get the error. What should I say when I call them. What could be the cause? – Pirzada Aug 17 '11 at 16:39
  • @pirzada - I wish i knew. When I originally set this up I didn't have the issues your having. – Peter Aug 17 '11 at 16:54
  • I need your help please. I regenerated file from FirstData and everything started work on local machine. Problem is when I deploy on a server get error which I have mentioned in my Question. Will you please help. – Pirzada Aug 22 '11 at 11:52
  • I have started bounty again and will give it to you in 23 hrs. System not allowing me to award bounty now. Here is error question http://stackoverflow.com/questions/7147183/firstdata-webservice-giving-error-please-help – Pirzada Aug 22 '11 at 12:06
0
  1. Check that you properly copied the digital certificate from the merchant's Welcome Email into a .PEM file on the web server. Compare the path to the file with the path and file name you provided to the secure payment gateway.
  2. 32bit versus 64bit issues:
  3. Check that the Solution Platform is set to x86 in Visual Studio and compile the application again.
  4. Possibly caused by a PEM file that is not able to be processed with the API.
    • Try: make a copy of your existing PEM file and reformat it using notepad. Add line breaks at the 66th character position
Community
  • 1
  • 1
Chains
  • 12,541
  • 8
  • 45
  • 62
  • thanks for the reply. Your message helped alot. There is one problem on my local machine API is working fine and I get response once data is posted but when I deploy my application I get ERROR: {The connection was reset The connection to the server was reset while the page was loading} . Can you help me why this is happening. – Pirzada Aug 12 '11 at 21:23
  • That's a tough one...you might be running into a firewall...or maybe your server doesn't have openSSL installed, or maybe port 1129 is blocked... Best I can say at this point is your web host and linkpoint might not be compatible. You might need to call the vendor for specifics. – Chains Aug 12 '11 at 21:54
  • Https showing my certificate. Asked host he said they dont block outboud calls and 1129 is open. Any idea with WebServices? – Pirzada Aug 12 '11 at 22:12
0

If using IIS, go to the application pool that's running the site and open Advanced Settings. There you can set "Enable 32-bit Applications" to true. That should fix your problem.

gislikonrad
  • 3,401
  • 2
  • 22
  • 24
  • did what you said but still get that damn error "The request failed with HTTP status 401: Unauthorized." . Anything else? – Pirzada Aug 16 '11 at 20:01
0

What trust level is your application using when its deployed to the production server? If it's running in medium trust, its possible it can't access a component required by the DLL. You can replicate this locally by setting your .net trust level for the site to medium. If setting your local site to medium trust reproduces the issue, then you will need to either get your host to enable full trust, find another host that has full trust, or get a VPS.

James Harris
  • 1,904
  • 11
  • 15
  • Thanks for the reply. I have Full Trust enabled in Web.Config and that what host said to use. . Anything else? – Pirzada Aug 17 '11 at 16:36