PHP code example of coatesap / credit-card-validator

1. Go to this page and download the library: Download coatesap/credit-card-validator 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/ */

    

coatesap / credit-card-validator example snippets




$cardDetails = array(
    'number' =>'4929000000006',
    'expiryYear' => 2013,
    'expiryMonth' => 5,
    'code' => '123'
);

$card = new Coatesap\Payment\Card();
$card->populate($cardDetails);

if (!$card->isValid($message)) {
    // show error message (set by reference)
    echo 'There is a problem with your card details: ' . $message;
} else {
    // get the prepped, validated card data as an array
    $cardData = $card->toArray();
    // send $cardData to payment gateway
}