1

我编译了一个简单的 ASP.NET 项目来测试第一个数据全局网关 API 集成。

有人告诉我该怎么做,因为我已经尝试了一切。

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>

如果我使用虚拟目录,则会出现错误:这是在何时生成的

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

已经完成了

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

测试:

Windows 7 ultimate 64 bit

根目录下的项目有:

default.aspx 
status.aspx
111222333.pem

斌:

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

Web.Config 只是显示这个以确保:

<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>
4

4 回答 4

4

很抱歉延迟回复您。下面是我使用的代码。特别是看看 BuildOrderService 如何设置证书。

回复

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

设置

--XML文件--

<?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>

- 代码 -

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

交易

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
于 2011-08-15T21:33:41.637 回答
0
  1. 检查您是否将商家欢迎电子邮件中的数字证书正确复制到网络服务器上的 .PEM 文件中。将文件的路径与您提供给安全支付网关的路径和文件名进行比较。
  2. 32 位与 64 位的问题:
  3. 检查解决方案平台是否在 Visual Studio 中设置为 x86,然后再次编译应用程序。
  4. 可能由无法使用 API 处理的 PEM 文件引起。
    • 尝试:复制现有 PEM 文件并使用记事本重新格式化。在第 66 个字符位置添加换行符
于 2011-08-10T19:54:28.600 回答
0

如果使用 IIS,请转到运行该站点的应用程序池并打开“高级设置”。在那里,您可以将“启用 32 位应用程序”设置为 true。那应该可以解决您的问题。

于 2011-08-16T16:04:49.117 回答
0

您的应用程序在部署到生产服务器时使用的信任级别是什么?如果它以中等信任运行,它可能无法访问 DLL 所需的组件。您可以通过将站点的 .net 信任级别设置为中等来在本地复制它。如果将您的本地站点设置为中等信任会重现该问题,那么您将需要让您的主机启用完全信任,找到另一个具有完全信任的主机,或者获取 VPS。

于 2011-08-17T15:54:30.797 回答