PHP code example of silici0 / credit-card-class

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

    

silici0 / credit-card-class example snippets


$card_details = array(
	'number' =>'4929000000006', 
	'expiry_year' => 2013,
	'expiry_month' => 5,
	'code' => '123'
);

$card = new Card();
$card->populate($card_details);

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