Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[PHP] Im Shop mit Visa/Master-Card Bezahlen

Empfohlene Antworten

Hallo,

welche Möglichkeiten hat man, um Visa- oder Mastercards auf Gültigkeit zu überprüfen? Wie müssen die Nummern aufgebaut sein?

- Oneside -

vielleicht hilft dir Kreditkartenüberprüfung mit ASP (ist asp, lässt sich aber sicher auch auf php ummodeln). zuerst schau dir vl mal dies an:


************************************************************************

*

* CCVal - Credit Card Validation function.

*

* Copyright (c) 1999 Holotech Enterprises. All rights reserved.

* You may freely modify and use this function for your own purposes. You

* may freely distribute it, without modification and with this notice

* and entire header intact.

*

* This function accepts a credit card number and, optionally, a code for 

* a credit card name. If a Name code is specified, the number is checked

* against card-specific criteria, then validated with the Luhn Mod 10 

* formula. Otherwise it is only checked against the formula. Valid name

* codes are:

*

* mcd - Master Card

* vis - Visa

* amx - American Express

* dsc - Discover

* dnc - Diners Club

* jcb - JCB

*

* A description of the criteria used in this function can be found at

* http://www.beachnet.com/~hstiles/cardtype.html. If you have any 

* questions or comments, please direct them to ccval@holotech.net

*

* Alan Little

* Holotech Enterprises

* http://www.holotech.net/

* September 1999

*

************************************************************************/


function CCVal($Num, $Name = 'n/a') {


// Innocent until proven guilty

$GoodCard = true;


// Get rid of any non-digits

$Num = ereg_replace("[^[:digit:]]", "", $Num);


// Perform card-specific checks, if applicable

switch ($Name) {


case "mcd" :

$GoodCard = ereg("^5[1-5].{14}$", $Num);

break;


case "vis" :

$GoodCard = ereg("^4.{15}$|^4.{12}$", $Num);

break;


case "amx" :

$GoodCard = ereg("^3[47].{13}$", $Num);

break;


case "dsc" :

$GoodCard = ereg("^6011.{12}$", $Num);

break;


case "dnc" :

$GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num);

break;


case "jcb" :

$GoodCard = ereg("^3.{15}$|^2131|1800.{11}$", $Num);

break;

}


// The Luhn formula works right to left, so reverse the number.

$Num = strrev($Num);


$Total = 0;


for ($x=0; $x<strlen($Num); $x++) {

$digit = substr($Num,$x,1);


// If it's an odd digit, double it

if ($x/2 != floor($x/2)) {

$digit *= 2;


// If the result is two digits, add them

if (strlen($digit) == 2) 

$digit = substr($digit,0,1) + substr($digit,1,1);

}


// Add the current digit, doubled and added if applicable, to the Total

$Total += $digit;

}


// If it passed (or bypassed) the card-specific check and the Total is

// evenly divisible by 10, it's cool!

if ($GoodCard && $Total % 10 == 0) return true; else return false;

}


if(CCVal($nummer_card, $name_card))

echo 'Check ist TRUE';

else

echo 'Check ist FALSE';


s'Amstel

vielleicht hilft dir (ist asp, lässt sich aber sicher auch auf php ummodeln)

s'Amstel

Hm das ganze sieht aber auch sehr nach PHP aus.

Auf den ersten Blick würde ich sagen, dass man das 1:1 übernehmen kann,...

Gruß,

Markus

für mich sieht das auch nach php aus. funktioniert das auch 100%ig?

das "ist asp" von mir bezog sich auf den link in meinem posting, nicht den code - der ist php. ob es funktioniert, kann ich dir nicht sagen, ist ungetestet. die im php-source stehende url bietet dir aber ebenfalls eine gute ausgangsbasis für kreditkartencheck-algorithmen.

s'Amstel

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.