Saif Khan

{ I am Saif } "Knowledge is power, information is free, share it!"
posts - 24, comments - 111, trackbacks - 0

My Links

News

Archives

.NET

Hardware

Networking

Using Gestpaycrypt.dll in Asp.net to process foreign Credit Cards

I've been meaning to publish this for a while now.

My quest in setting up payment processing for one of our European sites led me to writing this article. Since I speak only “English”,  it was indeed a quest getting information on this .dll since all of the documentation found was either in “Italian” or some other foreign language, although, some of the documentation is in “English”, provided by http://easynolo.it (providers of the Gestpaycrypt.dll, and yes, I stand corrected).

 

The documentation available at the time of writing this article shows how to use the .dll in Java and native ASP (not asp.net).

 

The Gestpaycrypt.dll is written in Java and requires some Java runtime files installed on your desktop or server to get this baby up and running.

 

Note: This documentation will show you how to use the Gestpaycrypt.dll in Windows environment using Asp.net 1.0 or 2.0 via Visual Studio 2003 or Visual Studio 2005 or any of the Express editions.

 

The good stuff!


First you need to make sure that your Windows machine (used for development) is ready for the Geytpaycrypt.dll. Proceed …

 

  • Make sure that “Msjava.dll” is installed on your machine. To find this puppy navigate to “C:\Windows\System32\msjava.dll”. If it’s not found don’t panic.
  • Make sure that “C:\Windows\Java” directory has the following folders:
    • Classes
    • Packages
    • Trustlib
  • In the “Classes” folder there must be an “osp.cer” certificate. If it’s not found don’t panic.
  • In the “Packages” folder there should be quite a few ZIP files and a “Data” folder with some files in it. I’ll list just a few. If nothing is found don’t panic.
    • E179JBT7.ZIP
    • MRZ9VBZB.ZIP
    • UM3TVV1B.ZIP
    • AD7NRBTJ.ZIP
    • KPVNFNXV.ZIP
    • PBNT7LBN.ZIP
    • UPNDBNT7.ZIP

 

Don’t delete any of these files if they are present as they are needed to run java applications.


NOT FOUND! Oh my!


If any of the above files are not found then you will need to install or reinstall your Java runtime environment. Proceed …


Install


If this is a fresh install of the runtime then go to the following link listed below

 

http://www.java.com/en/download/manual.jsp

 

To download the Java Runtime files. You will need to select your download based on your Operating System (Windows of course). After the download is complete proceed to installing it following all the instructions then do the famous Windows refresh after a hangover ……a restart!…or reboot! or whatever you call it.

 

 

Re Install


Simply uninstall any of the Java Runtime listed in “Add or Remove Programs”. Do a restart and then down and install the runtime file(s) from the link above.

 

Msjava.dll

 

If msjava.dll is missing you will need to have that installed. I recommend you install the Microsoft Java Virtual Machine to get this file. You can download the MSJVM from here

 

http://java-virtual-machine.net/download.html

 

There are quite a few links. I used http://visiteinteractive.free.fr/VM_java/msjavx86.exe

 

Then proceed to install. After the installation reboot and then check for the msjava.dll and make sure the folders within “C:\Windows\Java” have the files (or at least some of them listed above) present. If all is well up to this point then your box is ready for the Gestpaycrypt.dll.

 

Note all the above need to be done on the web server as well. In most hosting environment this is already setup. But if you run into problems after publishing to the web server then you will need to contact your web hosting provider.

  

 

Gestpaycrypt.dll


Download the .dll file from http://easynolo.it. You will need to register as a member of their site, which is pretty easy if you understand the foreign language. If you are like me, only English speaking, then not to worry… Google to the rescue! Use the language translation tool on Google to translate the webpage from Italian to English and you are set.

 

After you’ve finished downloading the file place it in your application folder. What I usually do is create a “C:\common” folder on my development box(s) and then put all my .dll files in there. That way multiple application can use the same files and also I create the same on my web server (If you are in control of your own web server) so my Web Server will match my development machine. For .net dll, if they are “signed” then just put them in the GAC folder.

 

Then run regsvr32 to register the file. Simply click on “Start” > “Run” and type regsvr32 “c:\path to the Gestpaycrypt.dll”. See image below

 

Gestpay_1

 


Another cool way from the “good old days” is to keep a shortcut of the “Regsvr32.dll” file (which can be found in C:\Windows\system32 folder) on the desktop and simply drag the .dll file you want to register on top of the shortcut and that’s it! You can also add the shortcut to the “Send To” items and then all you have to do is right click on the .dll and “Sent To > Regsvr32.dll”… pretty cool huh!

To un-register the .dll simply click on “Start” > “Run” and type regsvr32 /u “c:\path to the Gestpaycrypt.dll”. See image below

 

 

Gestpay_2

After you get the message box saying the that the .dll file was successfully registered you are ready to start using the Gestpaycrypt.dll

 

Note: The .dll registration above is not used for registering and un-registering .dll files created in .net.

 

 

Using the Gestpaycrypt.dll in ASP.NET


In your Asp.net application you will need to add a reference to the .dll file.

 

Right click on your project in the Solution explorer within Visual Studio and select “Add Reference”.  Select the “Browse Tab” and navigate to the Gestpaycrypt.dll and click “OK”. After the reference is added, it’s time for coding. Ah! Not fully. You need to understand some requirements from the merchant.

 

By now you should have a merchant account setup to use the Gestpaycrypt.dll. The merchant will settle processed credit cards and deposit the settlement to your bank account, after taking out their charges of course. From the account you can set quite a few configurations, as well as run reports.

 

The data passed to the merchant via the Gestpaycrypt.dll are encrypted parameters. The merchant account needs to be configured to expect those parameters. E.g. if you will be passing the customer’s email address, you have to set it up as an expected parameter so that the merchant account will expect the parameter. You have to option during the configuration to make it a “required parameter” as well.

 

Once you have your parameters covered you also have to configure your source IP address. That is the address where the Gestpaycrypt.dll call is executed from. These needs to be your IP (Public IP address, see below) address during testing and the web server IP (Public IP address, see below) address after you have uploaded the site. In a web farm environment you will need to add a few of the farm’s IP addresses. This IP Address thing is a security feature as the merchant will know the call is coming from you and only you, who should also be the holder of the merchant account specified. Pretty cool!

To know what is your public IP go to the website http://whatismyip.com. The address listed in your browser is your public IP. To get the IP of your web server , if it’s a private server then login and go to the same website as above or get the IP address of your domain e.g. mysite.com, which will be running the Gestpaycrypt.dll. From your command prompt, type nslookup mysite.com. The IP address returned is the IP of your website.

 

 

The data you send to the merchant is encrypted using Gestpaycrypt.dll encryption standards and are sent to them via a querystring. There are 2 querystrings used in the process “a” and “b”. The same querystrings will be returned with the results from the merchant.

 

·        “a” will hold the merchant account number.

·        “b” will hold the encrypted data with all your information about the customer.

 

Here is the code to to start playing with. First I have a GestPaycryptPayment Class to collect the information to process and a GestPaycryptResponse which will hold the response data. Ignore the GestPaycryptHelper Class for now as I didn't get a chance to extend this further. Perhaps when I have some time to spare I'll see what I can do. In the mean time, just pluck out what you need to get started. Don't forget at add your reference to the Interop of the GetsPaycrypt.dll. If you need the dll just drop me a mail.

Imports System
Imports GestPaycrypt

Namespace SaifKhan.PaymentProcessing

    Public Enum eGestPaycryptCurrencyCode
        Dollar = 1
        Pound = 2
        Euro = 242
        Italian = 18
    End Enum

    Public Enum eGestPaycryptLanguageCode
        Italian = 1
        English = 2
        Spanish = 3
        French = 4
        German = 5
    End Enum

    Public Class GestPaycryptHelper

        Sub New()

        End Sub

        Sub New(ByVal shopLogin As String, ByVal payment As GestPaycryptPayment)

            Dim oGestPayCrypt As GestPaycrypt.GestPaycrypt = New GestPaycrypt.GestPaycrypt

            With oGestPayCrypt
                .SetShopLogin(shopLogin.Trim)
                .SetAmount(payment.Amount)
                .SetCurrency(payment.Currency)
                .SetLanguage(payment.Language)
                .SetShopTransactionID(payment.OrderNumber)
                .SetBuyerName(payment.CardHolderName)
                .SetBuyerEmail(payment.CardHolderEmail)
                .setcardNumber(payment.CardNumber)
            End With


        End Sub

    End Class

    Public Class GestPaycryptPayment

        Private _currency As eGestPaycryptCurrencyCode
        Private _amount As String = String.Empty
        Private _transactionID As String = String.Empty
        Private _cardNumber As String = String.Empty
        Private _expMonth As String = String.Empty
        Private _expYear As String = String.Empty
        Private _buyerName As String = String.Empty
        Private _buyerEmail As String = String.Empty
        Private _language As eGestPaycryptLanguageCode
        Private _customInformation As String = String.Empty

        Public Property Currency() As eGestPaycryptCurrencyCode
            Get
                Return _currency
            End Get
            Set(ByVal value As eGestPaycryptCurrencyCode)
                _currency = _currency
            End Set
        End Property

        Public Property Amount() As String
            Get
                Return _amount
            End Get
            Set(ByVal value As String)
                _amount = value
            End Set
        End Property

        Public Property OrderNumber() As String
            Get
                Return _transactionID
            End Get
            Set(ByVal value As String)
                _transactionID = value
            End Set
        End Property

        Public Property CardNumber() As String
            Get
                Return _cardNumber
            End Get
            Set(ByVal value As String)
                _cardNumber = value
            End Set
        End Property

        Public Property CardExpMonth() As String
            Get
                Return _expMonth
            End Get
            Set(ByVal value As String)
                _expMonth = value
            End Set
        End Property

        Public Property CardExpYear() As String
            Get
                Return _expYear
            End Get
            Set(ByVal value As String)
                _expYear = value
            End Set
        End Property

        Public Property CardHolderName() As String
            Get
                Return _buyerName
            End Get
            Set(ByVal value As String)
                _buyerName = value
            End Set
        End Property

        Public Property CardHolderEmail() As String
            Get
                Return _buyerEmail
            End Get
            Set(ByVal value As String)
                _buyerEmail = value
            End Set
        End Property

        Public Property Language() As eGestPaycryptLanguageCode
            Get
                Return _language
            End Get
            Set(ByVal value As eGestPaycryptLanguageCode)
                _language = value
            End Set
        End Property

        Public Property CustomInformation() As String
            Get
                Return _customInformation
            End Get
            Set(ByVal value As String)
                _customInformation = value
            End Set
        End Property

    End Class

    Public Class GestPaycryptResponse
        Private _transactionResult As String = String.Empty
        Private _authorizationCode As String = String.Empty
        Private _bankTransactionID As String = String.Empty
        Private _errorCode As String = String.Empty
        Private _errorDescription As String = String.Empty
        Private _alertCode As String = String.Empty
        Private _alertDescription As String = String.Empty

        Public Property ResponseTransactionResult() As String
            Get
                Return _transactionResult
            End Get
            Set(ByVal value As String)
                _transactionResult = value
            End Set
        End Property

        Public Property ResponseAuthorizationCode() As String
            Get
                Return _authorizationCode
            End Get
            Set(ByVal value As String)
                _authorizationCode = value
            End Set
        End Property

        Public Property ResponseBankTransactionID() As String
            Get
                Return _bankTransactionID
            End Get
            Set(ByVal value As String)
                _bankTransactionID = value
            End Set
        End Property

        Public Property ResponseErrorCode() As String
            Get
                Return _errorCode
            End Get
            Set(ByVal value As String)
                _errorCode = value
            End Set
        End Property

        Public Property ResponseErrorDescription() As String
            Get
                Return _errorDescription
            End Get
            Set(ByVal value As String)
                _errorDescription = value
            End Set
        End Property

        Public Property ResponseAlertCode() As String
            Get
                Return _alertCode
            End Get
            Set(ByVal value As String)
                _alertCode = value
            End Set
        End Property

        Public Property ResponseAlertDescription() As String
            Get
                Return _alertDescription
            End Get
            Set(ByVal value As String)
                _alertDescription = value
            End Set
        End Property


    End Class

End Namespace

Now, on the page I am submitting data from, here is my code

Imports SaifKhan.PaymentProcessing

<System.Runtime.InteropServices.ComVisible(True)> _
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As New GestPaycryptPayment

        With p
            .Language = eGestPaycryptLanguageCode.English
            .Currency = eGestPaycryptCurrencyCode.Dollar
            .Amount = "1.00"
            .OrderNumber = "12345"
            .CardHolderName = "Saif Khan"
            .CardHolderEmail = "skhan@mycompany.com"

        End With

        Dim o As GestPaycrypt.GestPaycrypt = New GestPaycrypt.GestPaycrypt


        With o

            .SetShopLogin("999999")
            .SetCurrency(p.Currency)
            .SetLanguage(p.Language)
            .SetAmount(p.Amount)
            .SetShopTransactionID(p.OrderNumber)
            .SetBuyerName(p.CardHolderName)
            .SetBuyerEmail(p.CardHolderEmail)

        End With

        o.Encrypt()

        If o.GetErrorCode = "0" Then
            Dim a As String = o.GetShopLogin
            Dim b As String = o.GetEncryptedString

            Dim s As String = "https://ecomm.sella.it/gestpay/pagam.asp?" & "a=" & a & "&b=" & b
            Response.Redirect(s)

        Else
            Response.Write(o.GetErrorDescription)
        End If
    End Sub
End Class

Here is the response code. This code has to be placed on the response page, which wil be added to the configuration
settings on the easynolo website. This is the page, once the card has been processed, they will connect to on your
site to return the response.

Imports GestPaycrypt

Partial Class ResponseComplete
    Inherits System.Web.UI.Page

    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
        If Not Page.IsPostBack Then
            Dim a As String = Request.QueryString("a").Trim
            Dim b As String = Request.QueryString("b").Trim

            Dim o As GestPaycrypt.GestPaycrypt = New GestPaycrypt.GestPaycrypt

            If o.GetErrorCode <> "0" Then
                Response.Write(o.GetErrorCode)
                Response.Write(o.GetErrorDescription)
            End If

            With o
                .SetShopLogin(a)
                .SetEncryptedString(b)
            End With

            TextBox1.Text = o.GetShopTransactionID
            TextBox2.Text = o.GetTransactionResult
            TextBox3.Text = o.GetAuthorizationCode
            TextBox4.Text = o.GetBankTransactionID

            Response.Write(o.GetErrorDescription)

        End If
    End Sub
End Class

 


That's it! I hope you find some of this information useful. I am sure the code can be totally refactored, however this was just a test and at the same time make it easy for some beginners. Ciao!


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Sunday, January 18, 2009 8:33 PM |

Feedback

Gravatar

# re: Using Gestpaycrypt.dll in Asp.net to process foreign Credit Cards

Sorry about the delay with the code. My laptop just won't boot. Looks like I may need to replace the board. Ouch!
1/27/2009 5:42 AM | Saif Khan
Gravatar

# re: Using Gestpaycrypt.dll in Asp.net to process foreign Credit Cards

Good post. I always visit your site and found lots of beautiful work. Thanks for your all efforts that you do for it
2/2/2011 10:50 PM | casino gambling online
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: