You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2008/03/15 01:33:37 UTC

svn commit: r637310 - in /ofbiz/trunk: framework/base/src/base/org/ofbiz/base/test/ framework/base/src/base/org/ofbiz/base/util/ framework/base/testdef/ specialpurpose/pos/src/org/ofbiz/pos/ specialpurpose/pos/src/org/ofbiz/pos/device/impl/

Author: jleroux
Date: Fri Mar 14 17:33:36 2008
New Revision: 637310

URL: http://svn.apache.org/viewvc?rev=637310&view=rev
Log:
Patches from Chris Lombardi "POS: full credit card number is printed on receipt" (https://issues.apache.org/jira/browse/OFBIZ-1687) - OFBIZ-1687

Added:
    ofbiz/trunk/framework/base/testdef/
    ofbiz/trunk/framework/base/testdef/basetests.xml   (with props)
Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/test/BaseUnitTests.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/test/BaseUnitTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/test/BaseUnitTests.java?rev=637310&r1=637309&r2=637310&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/test/BaseUnitTests.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/test/BaseUnitTests.java Fri Mar 14 17:33:36 2008
@@ -21,6 +21,7 @@
 import junit.framework.TestCase;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilFormatOut;
 
 public class BaseUnitTests extends TestCase {
 
@@ -37,5 +38,23 @@
 
         Debug.set(Debug.INFO, true);
         assertTrue(Debug.infoOn());
+    }
+
+    public void testFormatPrintableCreditCard_1(){
+        assertEquals("test 4111111111111111 to ************111", 
+                "************1111", 
+                UtilFormatOut.formatPrintableCreditCard("4111111111111111"));
+    }
+
+    public void testFormatPrintableCreditCard_2(){
+        assertEquals("test 4111 to 4111", 
+                "4111", 
+                UtilFormatOut.formatPrintableCreditCard("4111"));
+    }
+
+    public void testFormatPrintableCreditCard_3(){
+        assertEquals("test null to null", 
+                null, 
+                UtilFormatOut.formatPrintableCreditCard(null));
     }
 }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java?rev=637310&r1=637309&r2=637310&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java Fri Mar 14 17:33:36 2008
@@ -497,4 +497,16 @@
     public static String makeSqlSafe(String unsafeString) {
         return unsafeString.replaceAll("'","''");
     }
+    
+    public static String formatPrintableCreditCard(String original) {
+        if (original == null) return null;
+        if (original.length() <= 4) return original;
+        
+        StringBuffer buffer = new StringBuffer();
+        for(int i=0; i < original.length()-4 ; i++){
+            buffer.append('*');
+        }
+        buffer.append(original.substring(original.length()-4));
+        return buffer.toString();
+    }
 }

Added: ofbiz/trunk/framework/base/testdef/basetests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/testdef/basetests.xml?rev=637310&view=auto
==============================================================================
--- ofbiz/trunk/framework/base/testdef/basetests.xml (added)
+++ ofbiz/trunk/framework/base/testdef/basetests.xml Fri Mar 14 17:33:36 2008
@@ -0,0 +1,26 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<test-suite suite-name="basetests"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
+    <test-case case-name="basetests">
+        <junit-test-suite class-name="org.ofbiz.accounting.test.BaseUnitTests"/>
+    </test-case>
+</test-suite>

Propchange: ofbiz/trunk/framework/base/testdef/basetests.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/base/testdef/basetests.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/base/testdef/basetests.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?rev=637310&r1=637309&r2=637310&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Fri Mar 14 17:33:36 2008
@@ -353,16 +353,14 @@
                 payInfo.put("nameOnCard", nameOnCard);
 
                 String cardNum = cc.getString("cardNumber");
-                String cardStr = cardNum.substring(0, 2);
-                cardStr = cardStr + "****";
-                cardStr = cardStr + cardNum.substring(cardNum.length() - 4);
+                String cardStr = UtilFormatOut.formatPrintableCreditCard(cardNum);
 
                 String expDate = cc.getString("expireDate");
                 String infoString = cardStr + " " + expDate;
                 payInfo.put("payInfo", infoString);
                 payInfo.putAll(cc);
-
-
+                payInfo.put("cardNumber", cardStr);  // masked cardNumber
+                
             } else if ("GIFT_CARD".equals(paymentMethodTypeId)) {
                 GenericValue gc = null;
                 try {

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java?rev=637310&r1=637309&r2=637310&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java Fri Mar 14 17:33:36 2008
@@ -118,7 +118,6 @@
         msrStr.append(decodedData[1]);
         msrStr.append("|");
         msrStr.append(decodedData[3]);
-        Debug.log("Msr Info : " + msrStr.toString(), module);
 
         // implemented validation
         int msrType = MSR_UNKNOWN;