silici0/credit-card-class

此包的最新版本(0.0.1)没有可用的许可信息。

0.0.1 2014-11-26 17:24 UTC

This package is auto-updated.

Last update: 2024-09-27 06:44:41 UTC


README

这是一个简单的PHP类,用于准备和验证信用卡/借记卡详情。通常这发生在它们传递给支付网关进行处理之前。

使用示例

$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
}

数据准备

此类对您的卡片数据进行一些简单的准备。这包括从以下内容中移除非数字字符,包括空格:

  • 卡片号码
  • CVC/CV2值
  • 卡片有效期

验证检查

此类还检查:

  • 卡片尚未过期
  • 已提供有效的CVC/CV2安全码
  • 卡片号码通过Luhn检查