Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display last 4 digits of credit card nmber

Status
Not open for further replies.

Roy2008

Programmer
Jun 17, 2008
11
US
How do I mask first 12 digits of CC and display only last 4 digits in a datawindow? The column is varchar, stores both CC and bank checking acct info. I am using PB11.5 build 2506
I tried using dw_1.modify(col1.editmask.mask='************####')After I retrieve it masks first 4 digits instead of last 4.
Any help will be appriciated.
Regards,
 
Use a computed column with the expression:
Code:
if (IsNull(col1[0],'',Right('****************' + Right(col1[0], 4) , 16))

Matt

"Nature forges everything on the anvil of time"
 
Thanks for the response Matt,

When I added the following code I got an error:
if(Isnull(p_account_cc),'',Right('************',Right( p_account_cc,4),16))

The Error:
Expecting NUMBER exression.

Regards,

 
Is p_account_cc a string or a number. If it's a number, you need to put a 'string(p_account_cc)' statement around it.

Matt

"Nature forges everything on the anvil of time"
 
Hey, Thanks for the previous help.
I have a datawindow with a column cc_account_info which is designed to retrieve billing info from a table.
My new requirement is how do I display last 4 digits credit card number by not using computed field.

Any help will be appriciated.
Regards,
 
You can do essentially the same thing as in the computed column with the sql statement which retrieves data from the database. This gives you a column in the datawindow which is already populated with '************1234'. Alternatively you can retrieve the actual card numbers but put a mask in place which only shows the last four digits (the rest being displayed as asterisks).

What db are you using?

Matt

"Nature forges everything on the anvil of time"
 
Example in MS SQLServer
Code:
SELECT  ccNumber, Right('****************' + Right(Convert(varchar(16),ccNumber), 4), 16)
FROM    orderData
this gives the masked string straight from the database.

If you need the actual ccNumber (for use somewhere else) you will need to retrieve it in a separate column (which is not shown in the datawindow).

Matt

"Nature forges everything on the anvil of time"
 
Matt, Thanks for your suggestion.
I use SqlServer 2000 DB.
I am going to implement the SQL select as you suggested.

Please let me know, if I were to use the datawindow editmask column properity what is the syntax am I suppose to put in the mask.
When I use ************#### this syntax as mask, it displays first 4 digits of the CC instead of the last 4.

regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top