PHP code example of arntech / card

1. Go to this page and download the library: Download arntech/card library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arntech / card example snippets


use ARNTech\Card\Model\Financial\Card as FinancialCard;
use ARNTech\Card\Model\Financial\Virtual\Card as VirtualCard;
use ARNTech\Card\Model\CardNumber;
use ARNTech\Card\Model\LuhnCardNumber;

$testCardNumber = '44823300xxxx2314'; // this should be a valid card number
$cardExpiration = '0222';
$card = new CardNumber('1111');
echo $card; //prints 1111xxxxxxxx1111
echo $card->getType();//prints 1
echo $card->getTypeTest();//prints Airlines
echo $card->getPlainNumber();//prints 1111 - it's not advised to use it unless explicitly needed

$card = new CardNumber('01111');//throws an exception

$card = new LuhnCardNumber('1111');//throws an exception as the card does not validate Luhn Algorithm
$card = new LuhnCardNumber($testCardNumber);//passes luhn validation
//LuhnCardNumber extends CardNumber

$card = new FinancialCard($testCardNumber, $cardExpiration);//passes luhn validation
echo json_encode($card); //prints {"number":"4482xxxxxxxx2314","expiration":"02-2022"}
$card = new FinancialCard($testCardNumber, '02/21');//passes luhn validation
echo json_encode($card); //prints {"number":"4482xxxxxxxx2314","expiration":"02-2021"}
echo $card->getNumber()->getVendor();//prints 1
echo $card->getNumber()->getVendorName();//prints Visa

$card = new VirtualCard($testCardNumber, $cardExpiration, '123');
//VirtualCard extends FinancialCard
echo $card->isExpired()?'true':'false';//prits false
echo json_encode($card);//prints {"number":"4482xxxxxxxx2314","expiration":"02-2022","cvv2":"123"}
$card=new VirtualCard($testCardNumber, $cardExpiration, '1234');//throws Cvv2Exception