fuente FW_ValidCreditCard

fuente FW_ValidCreditCard

Postby MOISES » Sat Feb 29, 2020 2:26 pm

Hola:

¿En qué archivo está su código fuente? Gracias.
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: fuente FW_ValidCreditCard

Postby nageswaragunupudi » Sat Feb 29, 2020 6:58 pm

Source code is not available.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: fuente FW_ValidCreditCard

Postby MOISES » Sat Feb 29, 2020 8:33 pm

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.
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: fuente FW_ValidCreditCard

Postby TecniSoftware » Sun Mar 01, 2020 2:29 pm

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
Alejandro Cebolido
Buenos Aires, Argentina
User avatar
TecniSoftware
 
Posts: 235
Joined: Fri Oct 28, 2005 6:29 pm
Location: Quilmes, Buenos Aires, Argentina

Re: fuente FW_ValidCreditCard

Postby karinha » Tue Mar 03, 2020 1:11 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7846
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: fuente FW_ValidCreditCard

Postby TecniSoftware » Tue Mar 03, 2020 2:19 pm

Ejemplo funcional, valida Visa, American Express, Diners y MasterCard.


Code: Select all  Expand view  RUN

#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
User avatar
TecniSoftware
 
Posts: 235
Joined: Fri Oct 28, 2005 6:29 pm
Location: Quilmes, Buenos Aires, Argentina

Re: fuente FW_ValidCreditCard

Postby karinha » Tue Mar 03, 2020 3:20 pm

Alejandro, perfecto. Muchas gracias.

C:\FWH..\SAMPLES\CREDCARD.PRG by Alejandro Cebolido Buenos Aires, Argentina.

Code: Select all  Expand view  RUN

#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
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7846
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: fuente FW_ValidCreditCard

Postby Silvio.Falconi » Wed Mar 04, 2020 9:00 am

nageswaragunupudi wrote:Source code is not available.

there's no data information, so the frinds want see the source code

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests

cron