Hola:
¿En qué archivo está su código fuente? Gracias.
fuente FW_ValidCreditCard
fuente FW_ValidCreditCard
Saludos / Regards,
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: fuente FW_ValidCreditCard
Entonces será de poca utilidad, ya sea porque no sabemos cómo funciona, o si utiliza un servicio externo, con el riesgo de ciberseguridad y privacidad que esto conlleva.
Then it will be of little use, either because we do not know how it operates, or if it uses an external service, with the risk of cyber security and privacy that this entails.
Then it will be of little use, either because we do not know how it operates, or if it uses an external service, with the risk of cyber security and privacy that this entails.
Saludos / Regards,
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
- TecniSoftware
- Posts: 213
- Joined: Fri Oct 28, 2005 6:29 pm
- Location: Quilmes, Buenos Aires, Argentina
Re: fuente FW_ValidCreditCard
Moises
Yo desarrolle mi propia funcion partiendo de este codigo en visual basic: https://www.analysisandsolutions.com/so ... cvs-vb.htm
Valida el numero e identifica que tarjeta es.
Muchos saludos
Yo desarrolle mi propia funcion partiendo de este codigo en visual basic: https://www.analysisandsolutions.com/so ... cvs-vb.htm
Valida el numero e identifica que tarjeta es.
Muchos saludos
Alejandro Cebolido
Buenos Aires, Argentina
Buenos Aires, Argentina
Re: fuente FW_ValidCreditCard
Alejandro, sería muy amable de tu parte si publicaras el código en fivewin para que todos lo disfruten. Si es posible, si no le causará ningún problema. Gracias
Saludos.
Saludos.
João Santos - São Paulo - Brasil
- TecniSoftware
- Posts: 213
- Joined: Fri Oct 28, 2005 6:29 pm
- Location: Quilmes, Buenos Aires, Argentina
Re: fuente FW_ValidCreditCard
Ejemplo funcional, valida Visa, American Express, Diners y MasterCard.
Code: Select all
#include "FiveWin.ch"
Static oWnd
//----------------------------------------------------------------------------//
Function Main()
DEFINE WINDOW oWnd TITLE "Validacion de tarjetas de credito" ;
MENU BuildMenu() MDI
ACTIVATE WINDOW oWnd
Return NIL
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Test" ACTION TestCard()
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
Return oMenu
//----------------------------------------------------------------------------//
Static Function TestCard()
Local cNumber := Space(20)
Local cCard
If MsgGet( "Validacion de Tarjeta de Credito",;
"Número de tarjeta:",;
@cNumber )
If ValidCard( cNumber, @cCard )
MsgInfo( "Tarjeta válida ingresada es " + cCard )
Else
MsgInfo( "Número de tarjeta erroneo!" )
EndIf
EndIf
Return NIL
//----------------------------------------------------------------------------//
Function ValidCard( cNumber, cCard )
Local nID
Local nLen
Local nValidLen
cNumber := AllTrim( StrTran( cNumber, "-", "" ) )
nLen := Len( cNumber )
nID := Val( Left( cNumber, 4 ) )
If Empty( nID )
Return .F.
EndIf
Do Case
Case ( nID >= 3000 .AND. nID <= 3059 ) .OR.;
( nID >= 3600 .AND. nID <= 3699 ) .OR.;
( nID >= 3800 .AND. nID <= 3889 )
cCard := "Diners Club"
nValidLen := 14
Case ( nID >= 3400 .AND. nID <= 3499 ) .OR.;
( nID >= 3700 .AND. nID <= 3799 )
cCard := "American Express"
nValidLen := 15
Case nID >= 4000 .AND. nID <= 4999
cCard := "Visa"
Do Case
Case nLen > 14
nValidLen := 16
Case nLen < 14
nValidLen := 13
OtherWise
Return .F.
EndCase
Case nID >= 5100 .AND. nID <= 5599
cCard := "MasterCard"
nValidLen := 16
OtherWise
Return .F.
EndCase
If nLen <> nValidLen
Return .F.
EndIf
If Mod10( cNumber )
Return .T.
EndIf
Return .F.
//----------------------------------------------------------------------------//
Static Function Mod10( cNumber )
Local nLen := Len( cNumber )
Local Location
Local Digit
Local Checksum := 0
For Location := 2 - Mod( nLen, 2 ) To nLen Step 2
Checksum := Val( SubStr( cNumber, Location, 1 ) ) + Checksum
Next
For Location := ( Mod( nLen, 2 ) + 1 ) To nLen Step 2
Digit := Val( SubStr( cNumber, Location, 1 ) ) * 2
If Digit < 10
Checksum := Digit + Checksum
Else
Checksum := Digit - 9 + Checksum
EndIf
Next
If Mod( Checksum, 10 ) = 0
Return .T.
EndIf
Return .F.
//----------------------------------------------------------------------------//
Alejandro Cebolido
Buenos Aires, Argentina
Buenos Aires, Argentina
Re: fuente FW_ValidCreditCard
Alejandro, perfecto. Muchas gracias.
C:\FWH..\SAMPLES\CREDCARD.PRG by Alejandro Cebolido Buenos Aires, Argentina.
Saludos.
C:\FWH..\SAMPLES\CREDCARD.PRG by Alejandro Cebolido Buenos Aires, Argentina.
Code: Select all
#include "FiveWin.ch"
REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850
STATIC oWnd
FUNCTION Main()
HB_LANGSELECT( 'PT' ) // Default language is now Portuguese
HB_SETCODEPAGE( "PT850" )
// 1 English, 2 Spanish, 3 French, 4 Portugese, 5 German, 6 Italian
FWSetLanguage( 4 ) // Passar para portugues do Brasil.
DEFINE WINDOW oWnd TITLE "Validacion de tarjetas de credito" ;
MENU BuildMenu() MDI
ACTIVATE WINDOW oWnd CENTERED
RETURN NIL
FUNCTION BuildMenu()
LOCAL oMenu
MENU oMenu
MENUITEM "Teste" ACTION( TestCard() )
MENUITEM "Salida" ACTION( oWnd:End() )
ENDMENU
RETURN oMenu
STATIC FUNCTION TestCard()
LOCAL cNumber := Space( 20 )
LOCAL cCard
IF MsgGet( "Validacion de Tarjeta de Credito", ;
"Número de tarjeta:", ;
@cNumber )
IF ValidCard( cNumber, @cCard )
MsgInfo( "Tarjeta válida ingresada es " + cCard )
ELSE
MsgInfo( "Número de tarjeta erroneo!" )
ENDIF
ENDIF
RETURN NIL
FUNCTION ValidCard( cNumber, cCard )
LOCAL nID
LOCAL nLen
LOCAL nValidLen
cNumber := AllTrim( StrTran( cNumber, "-", "" ) )
nLen := Len( cNumber )
nID := Val( Left( cNumber, 4 ) )
IF Empty( nID )
RETURN .F.
ENDIF
DO CASE
CASE ( nID >= 3000 .AND. nID <= 3059 ) .OR. ;
( nID >= 3600 .AND. nID <= 3699 ) .OR. ;
( nID >= 3800 .AND. nID <= 3889 )
cCard := "Diners Club"
nValidLen := 14
CASE ( nID >= 3400 .AND. nID <= 3499 ) .OR. ;
( nID >= 3700 .AND. nID <= 3799 )
cCard := "American Express"
nValidLen := 15
CASE nID >= 4000 .AND. nID <= 4999
cCard := "Visa"
DO CASE
CASE nLen > 14
nValidLen := 16
CASE nLen < 14
nValidLen := 13
OTHERWISE
RETURN .F.
ENDCASE
CASE nID >= 5100 .AND. nID <= 5599
cCard := "MasterCard"
nValidLen := 16
OTHERWISE
RETURN .F.
ENDCASE
IF nLen <> nValidLen
RETURN .F.
ENDIF
IF Mod10( cNumber )
RETURN .T.
ENDIF
RETURN .F.
STATIC FUNCTION Mod10( cNumber )
LOCAL nLen := Len( cNumber )
LOCAL Location
LOCAL Digit
LOCAL Checksum := 0
FOR Location := 2 - Mod( nLen, 2 ) TO nLen STEP 2
Checksum := Val( SubStr( cNumber, Location, 1 ) ) + Checksum
NEXT
FOR Location := ( Mod( nLen, 2 ) + 1 ) TO nLen STEP 2
Digit := Val( SubStr( cNumber, Location, 1 ) ) * 2
IF Digit < 10
Checksum := Digit + Checksum
ELSE
Checksum := Digit - 9 + Checksum
ENDIF
NEXT
IF Mod( Checksum, 10 ) = 0
RETURN .T.
ENDIF
RETURN .F.
//-> FIN - THE END - FIM
João Santos - São Paulo - Brasil
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: fuente FW_ValidCreditCard
there's no data information, so the frinds want see the source codenageswaragunupudi wrote:Source code is not available.
I think the problem is manage the return arrays
Function test()
* local cardNo:= "-------------------------"
local cardNo:= "-------------------------"
local cIssuer,cInfo
? FW_ValidCreditCard( cardNo, @cIssuer, @cInfo )
?cIssuer
xbrowser cInfo
return nil
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC