gettingstarted
[Top] [All Lists]

RE: Credit Card Processing possible?

To: "'Getting Started'" <gettingstarted at lists dot realsoftware dot com>
Subject: RE: Credit Card Processing possible?
From: "Donn Edwards" <vmusic at spamcop dot net>
Date: Fri, 29 Apr 2005 23:29:26 +0200
Delivered-to: gettingstarted at lists dot realsoftware dot com
Importance: Normal
Organization: Black and White Inc
I can't answer the main part of your question, but you can validate credit
card numbers (i.e. Is the number bogus? But not check if it has funds)
Using this VB code:

I have pasted it below and I hope the word wrapping doesn't make it
completely unusable. I haven't translated it yet into RB code, but it
shouldn't take too long ;-)

>>>>

' Written by Daniel Krusky
'
http://www.planet-source-code.com/xq/ASP/txtCodeId.22178/lngWId.1/qx/vb/scri
pts/ShowCode.htm

Public Type CreditCardStats
    IsValidNumber As Boolean
    CreditCardCo As Integer
    CheckSum As String
    TotalSum As String
End Type

'In order to save some time, we declare a public const
'consisting of 20 zeros.
'This is done so that left padding of the inversed credit
'credit card number can be done with ease.
Public Const CreditCardNulls = "00000000000000000000"
Private Function ValidateCreditCardNumber(CreditCardNumber As String) As
CreditCardStats
'// Credit card pre-authorization function
'   Written by Daniel Krusky
'
http://www.planet-source-code.com/xq/ASP/txtCodeId.22178/lngWId.1/qx/vb/scri
pts/ShowCode.htm
'   Version 1.68.35 (c) 2003 Black and White Inc
Dim CCNumTemp() As Byte
Dim CCNumVal() As Byte
Dim x As Integer
    CCNumVal() = CreditCardNumber
    CreditCardNumber = ""
    For x = 0 To UBound(CCNumVal)
        Select Case IsNumeric(Chr(CCNumVal(x)))
            Case False
            Case True
                CreditCardNumber = CreditCardNumber & Chr(CCNumVal(x))
        End Select
    Next x
    If CreditCardNumber = "" Then CreditCardNumber = "0"
    Select Case Len(CreditCardNumber)
        Case 13
            Select Case Left$(CreditCardNumber, 1)
                Case "4"
                    ValidateCreditCardNumber.CreditCardCo = 2
                Case Else
                    ValidateCreditCardNumber.CreditCardCo = 0
            End Select
        Case 14
            Select Case Left$(CreditCardNumber, 2)
                Case "30"
                    Select Case Left$(CreditCardNumber, 3)
                        Case "300"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case "301"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case "302"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case "303"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case "304"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case "305"
                            ValidateCreditCardNumber.CreditCardCo = 4
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case "36"
                    ValidateCreditCardNumber.CreditCardCo = 4
                Case "38"
                    ValidateCreditCardNumber.CreditCardCo = 4
                Case Else
                    ValidateCreditCardNumber.CreditCardCo = 0
            End Select
        Case 15
            Select Case Left$(CreditCardNumber, 2)
                Case "34"
                    ValidateCreditCardNumber.CreditCardCo = 3
                Case "37"
                    ValidateCreditCardNumber.CreditCardCo = 3
                Case "20"
                    Select Case Left$(CreditCardNumber, 4)
                        Case "2014"
                            ValidateCreditCardNumber.CreditCardCo = 6
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case "21"
                    Select Case Left$(CreditCardNumber, 4)
                        Case "2149"
                            ValidateCreditCardNumber.CreditCardCo = 6
                        Case "2131"
                            ValidateCreditCardNumber.CreditCardCo = 7
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case "18"
                    Select Case Left$(CreditCardNumber, 4)
                        Case "1800"
                            ValidateCreditCardNumber.CreditCardCo = 7
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case Else
                    ValidateCreditCardNumber.CreditCardCo = 0
            End Select
        Case 16
            Select Case Left$(CreditCardNumber, 1)
                Case "3"
                    ValidateCreditCardNumber.CreditCardCo = 7
                Case "4"
                    ValidateCreditCardNumber.CreditCardCo = 2
                Case "5"
                    Select Case Left$(CreditCardNumber, 2)
                        Case "51"
                            ValidateCreditCardNumber.CreditCardCo = 1
                        Case "52"
                            ValidateCreditCardNumber.CreditCardCo = 1
                        Case "53"
                            ValidateCreditCardNumber.CreditCardCo = 1
                        Case "54"
                            ValidateCreditCardNumber.CreditCardCo = 1
                        Case "55"
                            ValidateCreditCardNumber.CreditCardCo = 1
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case "6"
                    Select Case Left$(CreditCardNumber, 4)
                        Case "6011"
                            ValidateCreditCardNumber.CreditCardCo = 5
                        Case Else
                            ValidateCreditCardNumber.CreditCardCo = 0
                    End Select
                Case Else
                    ValidateCreditCardNumber.CreditCardCo = 0
            End Select
        Case Else
            ValidateCreditCardNumber.CreditCardCo = 0
    End Select
    Select Case ValidateCreditCardNumber.CreditCardCo
        Case 0
        Case Else
            'LUHN Formula (Mod 10)
            Dim MultiplyByTwo As Boolean
            Dim CCNumTempNum As Integer
            For x = 1 To Len(CreditCardNumber)
                Select Case MultiplyByTwo
                    Case False
                        MultiplyByTwo = True
                        CCNumTempNum = Mid$(Right$(CreditCardNumber, x), 1,
1)
                    Case True
                        MultiplyByTwo = False
                        CCNumTempNum = (Mid$(Right$(CreditCardNumber, x), 1,
1) * 2)
                End Select
                Select Case CCNumTempNum
                    Case 9
                    Case 8
                    Case 7
                    Case 6
                    Case 5
                    Case 4
                    Case 3
                    Case 2
                    Case 1
                    Case 0
                    Case Else
                        CCNumTempNum = (Int(CCNumTempNum / 10) +
(CCNumTempNum Mod 10))
                End Select
                ValidateCreditCardNumber.CheckSum = CCNumTempNum &
ValidateCreditCardNumber.CheckSum
                ValidateCreditCardNumber.TotalSum =
IIf(ValidateCreditCardNumber.TotalSum = "", "0",
ValidateCreditCardNumber.TotalSum) + CCNumTempNum
                DoEvents
            Next x
            Select Case (ValidateCreditCardNumber.TotalSum Mod 10)
                Case 0
                    ValidateCreditCardNumber.IsValidNumber = True
                Case Else
                    ValidateCreditCardNumber.IsValidNumber = False
                    ValidateCreditCardNumber.CreditCardCo = 0
            End Select
    End Select
End Function

Public Function xCreditCardCompany(ByVal strCardno As String) As String
'// Returns credit card company and/or validity
'   Written by Mark Duhaime, Modified by Donn Edwards
'   Version 1.68.35 (c) 2003 Black and White Inc
'
http://www.planet-source-code.com/xq/ASP/txtCodeId.13444/lngWId.1/qx/vb/scri
pts/ShowCode.htm
Dim strCCNumber As String, strCardType As String
Dim ccReturn As CreditCardStats
    strCCNumber = Trim(strDigits(strCardno))
    strCCNumber = Replace(strCCNumber, "/", "")
    strCCNumber = Replace(strCCNumber, "-", "")
    strCCNumber = Trim(Replace(strCCNumber, " ", ""))
    strCardType = ""
    If xIsLen(strCCNumber) Then
        strCardType = "."
        ccReturn = ValidateCreditCardNumber(strCCNumber)
        'Check the credit card company. If the credit card company is ""
        'then the card is deemed invalid. With some minor changes to the
        'ValidateCreditCardNumber function in modCCPreAuth, you can change
        'this so that it will still return the CreditCardNumber, and use
        'the ccReturn.IsValidNumber boolean type data to return TRUE or
FALSE
        'depending on if the card is valid or not respectively.
        Select Case ccReturn.CreditCardCo
          Case 0 ' INVALID
              'Frame1(0).Visible = True
              'Frame1(1).Visible = False
              'Label1(4).Caption = ""
              strCardType = "Unknown or invalid card type"
          Case 1 ' Mastercard
              'Frame1(0).Visible = False
              'Frame1(1).Visible = True
              strCardType = "Mastercard/Eurocard"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 2 ' VISA
              'Frame1(0).Visible = False
              'Frame1(1).Visible = True
              strCardType = "Visa"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 3 ' American Express
              'Frame1(0).Visible = False
                strCardType = "American Express"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 4 ' Diners Club / Carte Blanche
              'Frame1(0).Visible = False
              'Frame1(1).Visible = True
              strCardType = "Diners Club/Carte Blanche"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 5 ' Discover
              'Frame1(0).Visible = False
              'Frame1(1).Visible = True
              strCardType = "Discover"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 6 ' enRoute
              'Frame1(0).Visible = False
              strCardType = "enROUTE"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
          Case 7 ' JCB
              'Frame1(0).Visible = False
              'Frame1(1).Visible = True
              strCardType = "JCB"
              'display the checksum validity data
              'Label1(6).Caption = ccReturn.CheckSum
        End Select
        If ccReturn.IsValidNumber Then
            xCreditCardCompany = strCardType
        Else
            xCreditCardCompany = "error"
        End If
    Else
        xCreditCardCompany = " "
    End If
End Function

Public Function strDigits(ByVal pstrText As String, Optional ByVal
blnDecimal As Boolean = False, Optional strExtra As String = "") As String
'// Extract just the 0-9 digits from a string
'   Version 1.76.33 (c) 1999-2004 Black and White Inc
'Dim nLevel as integer
'nLevel = DbugIn("strDigits " & pstrText)
Dim strTemp As String
Dim lngI As Long
    strTemp = ""
    For lngI = 1 To Len(pstrText)
        If InStr(1, "1234567890" & strExtra & IIf(blnDecimal, ".+-", ""),
Mid$(pstrText, lngI, 1)) > 0 Then
            strTemp = strTemp & Mid$(pstrText, lngI, 1)
        End If
    Next lngI
    strDigits = strTemp
'dbugout nLevel strTemp
End Function
<<<<

HTH!

> -----Original Message-----
> From: gettingstarted-bounces at lists dot realsoftware dot com 
> [mailto:gettingstarted-bounces at lists dot realsoftware dot com] On 
> Behalf Of Scriptdude
> Sent: 29 April 2005 09:40 pm
> To: gettingstarted at lists dot realsoftware dot com
> Subject: Credit Card Processing possible?
> 
> 
> After a week of exploring all the rich features of this 
> amazing program 
> I have still one important question.
> 
> As far as I can see I can program everything we need here at 
> the office 
> in RB, but I need confirmation about 1 thing... will I be able to 
> communicate with Credit Card terminals and standard bankcard readers 
> from within my application? So that means: sending the amount to the 
> terminal, processing it and receiving payment confirmation.
> 
> I need to build a reservationsystem, but we do get customers at the 
> counter and we accept bank cards and creditcards. It would be nice if 
> there was a way to communicate with these devices within the 
> reservationsystem so everything is automated.
> 
> I already figured out how to work with the Cash register, so that's a 
> big plus. Just tell me it's possible and I'll find out how 
> when I need 
> to start coding it. For now I just want to know *IF* it's 
> possible so I 
> won't be dissapointed when I completed 80% of the application :-)
> 
> Thanks!
> 
> Dimitri
> 
> _______________________________________________
> Unsubscribe or switch delivery mode: 
> <http://www.realsoftware.com/support/listmanager/>
> 
> Search the archives of this list here: 
> <http://support.realsoftware.com/listarchives/lists.html>
> 

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>