Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

Create AuthorizeNet Exception and Address Class

How do you create the AuthorizeNet Exception Class and or additional classes such as Address??
for this question
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21148339.html


Public Structure Address
        Dim Address As String
        Dim City As String
        Dim State As String
        Dim ZipCode As String
        Dim EnteredBy As String
        Dim LastModifiedBy As String
        Dim LastModifiedDateTime As Date
End Structure
0
luckyinc
Asked:
luckyinc
  • 3
1 Solution
 
AerosSagaCommented:
Public Class CreditCardException
    Inherits Exception

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal exception As String)
        MyBase.New(exception)
    End Sub
End Class

Public Class BankTransferException
    Inherits Exception

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal exception As String)
        MyBase.New(exception)
    End Sub
End Class

Public Class AuthorizeNetException
    Inherits Exception

    Public Sub New()
    End Sub

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub
End Class

Public Class PaymentCustomerInformationException
    Inherits Exception

    Public Sub New()
    End Sub

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub
End Class

Public Class AddressException
    Inherits Exception

    Public Sub New()
    End Sub

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub
End Class
------------------------------------------------------------------------------------------------------------------------
Imports System.Text.RegularExpressions
Imports System.Data.SqlClient

'This Address class differs from the one in the Customer class for reasons pertaining to
'   Authorize.NET transactions (including the removal / addition of some fields as well as
'   changing lengths of fields
Public Class Address

    Friend _FirstName As String
    Friend _LastName As String
    Friend _Company As String
    Friend _Address As String
    Friend _City As String
    Friend _State As String
    Friend _Zip As String

#Region " Properties "
    Public Property FirstName() As String
        Get
            Return _FirstName
        End Get
        Set(ByVal Value As String)
            If Not Regex.IsMatch(Value, "^[A-Za-z ]{1,50}$") Then
                Throw New AddressException("The first name must consist of letters and spaces not exceeding 50 characters in length.")
            End If
            _FirstName = Value
        End Set
    End Property

    Public Property LastName() As String
        Get
            Return _LastName
        End Get
        Set(ByVal Value As String)
            If Not Regex.IsMatch(Value, "^[A-Za-z\- ]{1,50}$") Then
                Throw New AddressException("The last name must consist of letters and spaces not exceeding 50 characters in length.")
            End If
            _LastName = Value
        End Set
    End Property

    Public Property Company() As String
        Get
            Return _Company
        End Get
        Set(ByVal Value As String)
            If Not Regex.IsMatch(Value, "^[A-Za-z0-9\.&\- ]{1,50}$") Then
                Throw New AddressException("The company must consist of letters and spaces not exceeding 50 characters in length.")
            End If
            _Company = Value
        End Set
    End Property

    Public Property Address() As String
        Get
            Return _Address
        End Get
        Set(ByVal Value As String)
            If Not Regex.IsMatch(Value, "^[A-Za-z0-9\.,#\- ]{1,60}$") Then
                Throw New AddressException("The address field must consist of letters and spaces not exceeding 60 characters in length.")
            End If
            _Address = Value
        End Set
    End Property

    Public Property City() As String
        Get
            Return _City
        End Get
        Set(ByVal Value As String)
            If Not Regex.IsMatch(Value, "^[A-Za-z0-9\.\- ]{1,40}$") Then
                Throw New AddressException("The city must consist of letters and spaces not exceeding 50 characters in length.")
            End If
            _City = Value
        End Set
    End Property

    Public Property State() As String
        Get
            Return _State
        End Get
        Set(ByVal Value As String)
            'If Not Regex.IsMatch(Value, "^[A-Za-z]{2}$") Then
            'Throw New AddressException("The state must consist of two letters.")
            'End If
            _State = Value
        End Set
    End Property

    Public Property Zip() As String
        Get
            Return _Zip
        End Get
        Set(ByVal Value As String)
            'If Not Regex.IsMatch(Value, "^\d{5}(-\d{4})?$") Then
            'Throw New AddressException("The zip must consist of five digits.")
            'End If
            _Zip = Value
        End Set
    End Property
#End Region

#Region " Constructors "
    Friend Sub New()
    End Sub

    Public Sub New(ByVal FirstName As String, ByVal LastName As String, ByVal Address As String, _
        ByVal City As String, ByVal State As String, ByVal Zip As String)

        Me.FirstName = FirstName
        Me.LastName = LastName
        Me.Address = Address
        Me.City = City
        Me.State = State
        Me.Zip = Zip

    End Sub

    Public Sub New(ByVal Company As String, ByVal Address As String, ByVal City As String, _
        ByVal State As String, ByVal Zip As String)

        Me.Company = Company
        Me.Address = Address
        Me.City = City
        Me.State = State
        Me.Zip = Zip

    End Sub
#End Region

End Class

HTH's
0
 
luckyincAuthor Commented:
Thanks so much!!!!  I might have a few more questions in a few days!!

LuckyInc
0
 
luckyincAuthor Commented:
For Instance, PaymentCustomerInformation Class has an optional value....how do you allow an optional field?

0
 
MikeMCSDCommented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now