Credit Cards Recognition Function with PHP

Credit Cards Recognition Function with PHP

  • 5,741 Kez Okundu
  • PHP & MySQL
  • 4 Yorum
  • 2020-05-09 14:06:07

Sometimes in virtual pos integrations, we can use the API information. You may be asked to specify the card type ( Visa, Mastercard, Amex, Discover, Dinners, Enroute, Jbc ) when sending the data, or you want to show the user which card type it is or you need the card type for some other reason. We can use a function that can detect card types using Regex.

Let's share our small but effective function :)

function kartTipi($number){
		$number=str_replace(" ", "", $number);

		$cardType = array(
			"visa"       => "/^4[0-9]{12}(?:[0-9]{3})?$/",
			"mastercard" => "/^5[1-5][0-9]{14}$/",
			"amex"       => "/^3[47][0-9]{13}$/",
			"discover"   => "/^6(?:011|5[0-9]{2})[0-9]{12}$/",
			"dinners"    => "/^[300-305]d{11}$/",
			"dinners"    => "/^3[68]d{12}$/",
			"enroute"    => "/^2(014|149)d{11}$/",
			"jbc"    	 => "/^3d{15}$/",
			"jbc"    	 => "/^(2131|1800)d{11}$/",
			"troy"    	 => "/^(?:9792|65\d{2}|36|2205)\d{12}$/",
		);

		foreach ($cardType as $key => $value) {
			if (preg_match($value,$number))
			{
				$type= $key;
				break;
			}else{
				$type= false;
			}
		}
		return $type;
	}

You can convert very simple codes into any shape you want.

Its usage is;

$cardNo="4546711234567894"; // VISA Test Kartı

switch (kartTipi($cartNo)) {
      case 'visa':
           echo "Bu bir visa karttır.";
      break;

      case 'mastercard':
           echo "Bu bir mastercard karttır.";
      break;

      default:
            echo "Kart tipi bulunamadı.";
      break;
    }

Hope it will be fayal.

Stay With Love and Knowledge ...

 

Necati ErBıyık
@Necati ErBıyık demiş ki ;

Bu değerli bilgi için Teşekür ediyorumMnnettarım...

Azer
@Azer demiş ki ;

super bilgi tesekkurler

Metin ÖZTÜRK
@Metin ÖZTÜRK demiş ki ;

peki troy kart kodlarını nasıl ekleriz buna

admin
@admin demiş ki ;

Troy kartları için fonksiyon güncellenmiştir.

YORUM YAPMAK İSTER MİSİN?

    Sponsor Reklamlar
    Son Yorumlar
    Etiket Bulutu
    C#PopupFormOtomatikProgramBaşlatmaBaşlangıçBasitEkran Koruyucuc#ekran görüntüsümail göndermeexedllbirleştirmekIL MergePhpMSSQL BAĞLANTIGerçekIPRealTextBinaryConvertÇalışmaSüreHesaplamakBulmakCssjQueryHtmlScroll TopYukarı ÇıkOnMinimizeControlBoxSimge DurumunaKüçültInternetGetConnectedStateİnternetBağlantıKontrolŞifre MatikPassword GeneratorHash ŞifrelemeMD5SHA1SHA256SHA384SHA512Asimetrik ŞifrelemeRSASimetrik ŞifrelemeKriptoŞifrelemeAlgoritmaDESRC2RijndaelTripleDESKeyLogKlavye DinleTuş YakalamaGlobal HookDialogResultÇıkış MesajıUyarı MesajıFormClosingMySQLConnector/NetKullanımSoruCheckBoxListViewÇoklu SilmebiosdramexploitkontrolgüvenlikinteljavascriptrowhammerscriptPHPAdmin PanelResponsiveXtbadminFreeÜcretsizWifiWirelessKeysŞifreAnahtarPasswordKablosuz AğDepolamaŞifreler NeredeKablosuz ŞifreAndroidTelefonNasılYazılırProgramlama DiliHesap MakinesiSEONedirNasıl YapılırAnalizGoogleLinkÖzgünMobilKonuResim Robots.txtSite MapŞifreli GirişŞifreli FormŞifre KoymaŞifreli AçılışCompilingDebuggingDerlemeKarma ModMixed ModeApp.ConfigKurbanBayramMübarek OlsunBlogScriptYonetimAdminPanelText EditorMSHTMLEditorYazıDüzenleyiciEasyAppKolayUygulamaÇalıştırmaAkıllı TelefonKlavyeiOSKeyboardEl YazısıCalculatorMyScriptHand WritingDosya YöneticisiFile ExplorerFTPBluetoothRootTask ManagerGörev YöneticisiSystemTargetWeb Application PentestErrorShowHideHataGösterGizlePDOSelectInsertUpdateDeleteConnectSeçimEklemeSilmeGüncellemeMsSQLVeritabanıÇeviriçiDatabaseConverterDbConvertMaskeli IPGerçek IPTarayıcı Tespitİşletim Sistemi TespitTekil Ziyaretçi BilgileriAktif Ziyaretçi BilgileriZiyaretçi SayacıVirüsTemizlemeFirewallServiceSecurityServiceTimeServicePentestGüvenliksızma TestiuniscanwindowslinuxperlDosyaKlasörListelemekFileFolderListInternetDownloadUploadSpeedMonitorServisMsconfigStartupRunServiceIOSMatematikDenklemÇözümKameraKablosuzinternetHotspotPaylaşımAyarlarKaliLinuxSharedTerminalÖsymDuyuruTimeTimeZoneDateZamanTarihdate()time()FreelancerSerbestÇalışanJobsİşlerWebSiteVersionSürümGeçişUbuntuSunucuApachephpinfo()phpversion()FonksiyonHerseyiKopyalacopyallcopySızma TestiSQLMapWindowsPython810HotSpotWi-FiWlannetshhostednetworkAutoWlanJsGeri SayımTextAreaOtomatik KayıtSayacSaniyeCountDownXtbadminV2AjaxJavaScriptNumaraFormatPhoneNumberFormatTelefonNumarasıDebuggerDetectUnpackerDisassemblerSecurityReverseEngineeringAlgorithmMacDKHOSCTFCapture The FlagForensicTriviaIntelligenceCRC32CRYPTPASSWORD_HASHWin10StoreMağazaMicrosoftReInstallWSLPowerShellPOSTCyberSiberAdli BilişimHackerUSBCDLiveToolsBruterNmapMSSQL ServerMS SQL ExpressMS AccessOracleIBM DB2SybaseInterbaseInformixExceldBase DbfVisual FoxProMySQLConnectionŞifreleri BulCMDLaZagneEthernetTuxCutNetCutNetKillPerformansCronTabCronJobRestartStopStartBashShellWireSharkFlagUSOMBTKBase64QRÇözümlerWriteUpWrite-UpFinalReconOSINTToolScannerWebsiteSiber GüvenlikPhishingVPNWannacryMobileDeviceFunctionMobil AlgılaMobil TespitisMobilephp mobilJavascriptYazı EfektKayan YazıText EffectsearchBoxinputclassplaceholdersetIntervalsetTimeoutJSpreventBackwindowpushStatehistoryonloadblock browser back buttonVPN Nediranonimtorucuz ürünucuzurunum.commarket kıyaslaürün kıyaslakıyaslakarşılaştıra101şokhappy centermigroscarrefoursabizim marketkıyasürün fiyatıfiyat kıyaslaucuz fiyatfiyat sorVideoEmbedPlayerVideoIDgetVideoIDIframeCreditCardCard DetectKart AlgılaKart TespitKredi Kartı TespitVisaMastercardAIOpenAIChatGPTYapay Zekaquickchatkrispbeatovencleanvoicepodcastleflairillustrokepatternedstockimgcopymonkeyocoyaunbouncevidyotrymaverickquickchatpuzzlelabssounddrawcleanupresumewordedlookatheresanaiforthatsynthesiadescriptotterinkforall