Announcement

Collapse
No announcement yet.

Mask all but last four of credit card

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mask all but last four of credit card

    Anyone know how to mask all but last four of a credit card (or any datatype field) in a form?

  • #2
    Depends on what you want to do. With substr you can strip the last 4 postions, add * to it and display.
    Last edited by aducom; 02-11-2013, 02:35 PM.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      I am able to do this from MYSQL CLI and in Naviacat but SC is not working with it. Could you show me a simple example and where to put it in a form for a field?

      Comment


      • #4
        I assume you want to extract the data from the table and present it on the form? Safest way is to create 1 new field on your form and make the cc field invisible. then in the onload event of the form you get something like:

        $string={creditcard};
        {mynewfield}='***'.$string[strlen($string)-4];
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          I just got it to work with this.
          SELECT
          CONCAT(
          REPEAT('X', CHAR_LENGTH(cardnumber) - 4),
          SUBSTRING(cardnumber, -4)
          ) AS test1
          FROM ccard_payments
          WHERE payment_id = '{payment_id}'

          In the Grid Lookup of a new blank field with Label ticked.
          Thank you for your input. I need to also try to make your way work which I have yet to get it to.

          Comment


          • #6
            There's nothing wrong in your solution. Only argue against it might be that it might not be supported in every database.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              I got your solution working with this:

              $string={cardnumber};
              {card_number}='XXXX-XXXX-XXXX-'.$string[strlen($string)-4].$string[strlen($string)-3]
              .$string[strlen($string)-2].$string[strlen($string)-1];

              I really wanted to do this with event so I could enhance with if/else according to logged in user privilege.
              I am now also using this on form that has SSN number but when no SSN exists, it throws error.

              Thank you so much for the solution!

              Comment

              Working...
              X