Kernel::System::CreditCard

NAME

Kernel::System::CreditCard

DESCRIPTION

All credit card functions.

PUBLIC INTERFACE

new()

create an object. Do not use it directly, instead use:

    use Kernel::System::ObjectManager;
    local $Kernel::OM = Kernel::System::ObjectManager->new();
    my $CreditCardObject = $Kernel::OM->Get('Kernel::System::CreditCard');

MaskCreditCard()

mask all (matched) credit cards in a text, the mask character is defined in SysConfig "CreditCard::MaskedCharacter" setting.

the cards could have different separators like ' ', '-' '+', '/' '.' ',' ':' or no separator. the cards format could be 4-4-4-4, 4-4-4-3, 4-4-4-2 and 4-4-4-1 or 4-6-5 (for AmEx).

    my $MaskedText = $CreditCardObject->MaskCreditCard(
        Text        => $Text,                              # original text with exposed credit card
        JustWarning => 0,                                  # || 1, to mask or just show a warning
                                                           #    message next to the credit card
                                                           #    number. Default: 0
    );

for a given text like: 'The number 4153-4678-9333-2834 is from a visa card'

the result should be like: 'The number 5153-46**-****-2834 is from a visa card' (using '*' as the mask character).

or: 'The number 4153-4678-9333-2834 Do not use Credit Card Numbers is from a visa card' (using JustWarning parameter = 1 and ' Do not use Credit Card Numbers' as the SysConfig warning text setting).

VerifyCreditCard()

verify if the credit card is valid using the Luhn algorithm http://en.wikipedia.org/wiki/Luhn_algorithm

    my $Success = $CreditCardObject->VerifyCreditCard(
        CreditCard => 1234567890123         # any number
    );

    returns:
    $Success = 1;                           # || undef if number does not pass verification
                                            #   algorithm

the following code was inspired in the code presented in rosettacode.org http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Perl under GNU Free Documentation License 1.2.

Scroll to Top