Programing

신용 카드 유효 기간 최대 연도

lottogame 2020. 6. 15. 08:19
반응형

신용 카드 유효 기간 최대 연도


다양한 온라인 서비스는 신용 카드와 관련하여 최대 유효 기간에 대해 다른 값을 갖습니다.

예를 들어 :

  • 베이스 캠프 : +15 년 (2025)
  • 아마존 : +20 년 (2030)
  • 페이팔 : +19 년 (2029)

여기서 합리적인 최대 값은 얼마입니까? 공식적인 지침이 있습니까?


신용 카드 발급 기관이 발급 한 카드가 만료 될 때 각각을 선택할 수 있으므로 공식적인 지침은 없습니다. 사실 그들은 오랫동안 카드를 발행 해 왔습니다. 만기일을 얼마나 멀리 잡아야하는지 결정하려는 경우, 안전한 쪽에서 실수를하여 고객에게 몇 년을 선택하십시오. 그렇게하면 나중에 응용 프로그램을 증명할 수 있습니다.

참고로, 많은 신용 카드 발급 기관은 신용 카드 구매 승인 여부를 결정할 때 만료 날짜를 사용하지 않습니다. 따라서 잘못된 날짜가 제공되는 것이 걱정된다면 프로세서는 궁극적으로 거래 승인 여부에 대한 최종 결정을 내릴 것이므로 걱정하지 않아도됩니다.

2017 년 7 월 : 거의 50 년이 지난 카드를 사용하는 최종 사용자가 있습니다.


현재 날짜에 + 15-20 년을 동적으로 추가하거나 연도에 대한 텍스트 상자 입력을 제공합니다 (개인적으로 연도 목록을 스크롤하는 것보다 두 자리 숫자를 입력하는 것이 더 빠릅니다).


이론 상한으로서, 카드 소지자의 예상 수명 이상을 고려할 필요는 없습니다. Wikipedia는 살아있는 사람의 전기 에 대한 편집 표준에서 이것을 수행합니다 .

신뢰할만한 소식통이 개인의 사망을 확인하지 않는 한 115 년 전에 태어난 개인은이 정책의 적용을받습니다. 115 세 이상의 사람들은 가장 나이가 많은 사람들이 목록에없는 한 사망 한 것으로 추정됩니다.

따라서 코드에서 현재 연도를 조회하고 115를 더한 다음이를 신용 카드 만료 날짜의 이론 상한으로 사용하십시오. 해당 코드를 다시 만질 필요가 없습니다.


다음은 CC 유효성 검사를 위해 다가오는 연도의 사용자 정의 가능한 목록을 표시하는 데 사용할 수있는 Javascript 코드 스 니펫입니다.

    var yearsToShow = 20;
    var thisYear = (new Date()).getFullYear();
    for (var y = thisYear; y < thisYear + yearsToShow; y++) {
      var yearOption = document.createElement("option");
      yearOption.value = y;
      yearOption.text = y;
      document.getElementById("expYear").appendChild(yearOption);
    }
          <label for="expiration">Expiration Date</label>
          <span id="expiration">
            <select id="expMonth" name="expMonth">
              <option disabled="true">Month</option>
              <option value="1">Jan</option>
              <option value="2">Feb</option>
              <option value="3">Mar</option>
              <option value="4">Apr</option>
              <option value="5">May</option>
              <option value="6">Jun</option>
              <option value="7">Jul</option>
              <option value="8">Aug</option>
              <option value="9">Sep</option>
              <option value="10">Oct</option>
              <option value="11">Nov</option>
              <option value="12">Dec</option>
            </select>
            <select id="expYear" name="expYear">
            </select>
          </span>


잘 부탁합니다, @Alistair.

다음은 ASP.NET MVC의 월 및 연도 생성입니다. 이것을 뷰 모델에 추가하십시오.

public IList<SelectListItem> Months = new List<SelectListItem>() { 
    new SelectListItem() { Text="Jan", Value="01" },
    new SelectListItem() { Text="Feb", Value="02" },
    new SelectListItem() { Text="Mar", Value="03" },
    new SelectListItem() { Text="Apr", Value="04" },
    new SelectListItem() { Text="May", Value="05" },
    new SelectListItem() { Text="Jun", Value="06" },
    new SelectListItem() { Text="Jul", Value="07" },
    new SelectListItem() { Text="Aug", Value="08" },
    new SelectListItem() { Text="Sep", Value="09" },
    new SelectListItem() { Text="Oct", Value="10" },
    new SelectListItem() { Text="Nov", Value="11" },
    new SelectListItem() { Text="Dec", Value="12" },
};
public IEnumerable<SelectListItem> Years
{
    get
    {
        return new SelectList(Enumerable.Range(DateTime.Today.Year, 15));
    }
}

And this to your view:

<fieldset>
    <legend>Card expiration</legend>
    <div style="float: left;">
        <div class="editor-label">
            @Html.LabelFor(model => model.ExpirationMonth)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ExpirationMonth, Model.Months)
            @Html.ValidationMessageFor(model => model.ExpirationMonth)
        </div>
    </div>
    <div style="float: left;">

        <div class="editor-label">
            @Html.LabelFor(model => model.ExpirationYear)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ExpirationYear, Model.Years)
            @Html.ValidationMessageFor(model => model.ExpirationYear)
        </div>
    </div>
</fieldset>

While the second example runs twice as quickly as the first you are still getting the date and extracting the year from it 20 times rather than 40 times. A better unrolling of the loop is:

$StartDate=date('Y');
$EndDate=$StartDate+21;
for($i=$StartDate;$i<$EndDate;$i++){
    echo "<option value='".$i."'>".substr($i,2)."</option>\n";

That will be about 20 times faster than the twice as fast example and also addresses a minor bug in the original code in that the year could change from one fetching of the date to the next leading to unexpected, though in this case harmless, results.


<?php 
$y = gmdate("Y");
$x = 20;
$max = ($y + $x);
while ($y <= $max) {
echo "<option value='$y'>$y</option>";
$y = $y + 1;
}
?>

If you want a solution that does not yield three-digit years 2100+ you must modulo the date, accordingly you must fill with leading zero for xx00-xx09 years to not get single digit years.

This will be very important starting in 2080.

<?php
    for($i=0;$i<=20;$i++){
        $aktDate = sprintf("%02d", ((date('y')+$i)%100));
        echo "<option value=\"{$aktDate}\">{$aktDate}</option>\n";
    }
?>

After reading the OP's upper validity of 20 years for Amazon, I wrote this simple solution in PHP:

<select name='Expiry-Year'>
    <option value="">yy</option>
    <?php
    for($i=0;$i<21;$i++){
        echo "<option value='".(date('Y')+$i)."'>".(date('y')+$i)."</option>\n";
    }
    ?>
</select>

This has greatly reduced the number of these new-year requests to remove last year from a form.

A leaner version of the loop runs ~twice as quickly:

<select name='Expiry-Year'>
    <option value="">yy</option>
    <?php
    for($i=date('Y');$i<date('Y')+21;$i++){
        echo "<option value='".$i."'>".substr($i,2)."</option>\n";
    }
    ?>
</select>

<script type="text/javascript">
  var select = $(".card-expiry-year"),
  year = new Date().getFullYear();

  for (var i = 0; i < 20; i++) {
      select.append($("<option value='"+(i + year)+"' "+(i === 0 ? "selected" : "")+">"+(i + year)+"</option>"))
  }
</script> 

참고URL : https://stackoverflow.com/questions/2500588/maximum-year-in-expiry-date-of-credit-card

반응형