svn commit: r637395 - in /ofbiz/trunk: applications/accounting/entitydef/ applications/accounting/src/org/ofbiz/accounting/payment/ applications/order/entitydef/ applications/order/src/org/ofbiz/order/shoppingcart/ framework/base/ specialpurpose/pos/co...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r637395 - in /ofbiz/trunk: applications/accounting/entitydef/ applications/accounting/src/org/ofbiz/accounting/payment/ applications/order/entitydef/ applications/order/src/org/ofbiz/order/shoppingcart/ framework/base/ specialpurpose/pos/co...

jleroux@apache.org
Author: jleroux
Date: Sat Mar 15 04:31:20 2008
New Revision: 637395

URL: http://svn.apache.org/viewvc?rev=637395&view=rev
Log:
A patch from Chris Lombardi "POS: credit card data compliance" 'https://issues.apache.org/jira/browse/OFBIZ-1674) - OFBIZ-1674
+ a file which was missing in a previous commit (base component-load.xml)

Added:
    ofbiz/trunk/framework/base/component-load.xml   (with props)
    ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml   (with props)
    ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml   (with props)
Modified:
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
    ofbiz/trunk/applications/order/entitydef/entitymodel.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
    ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
    ofbiz/trunk/specialpurpose/pos/config/pos.properties
    ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Input.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Msr.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PaymentEvents.java

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Sat Mar 15 04:31:20 2008
@@ -2868,6 +2868,7 @@
       <field name="gatewayCode" type="short-varchar"></field>
       <field name="gatewayFlag" type="short-varchar"></field>
       <field name="gatewayAvsResult" type="short-varchar"></field>
+      <field name="gatewayCvResult" type="short-varchar"></field>
       <field name="gatewayScoreResult" type="short-varchar"></field>
       <field name="gatewayMessage" type="long-varchar"></field>
       <field name="transactionDate" type="date-time"></field>

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Sat Mar 15 04:31:20 2008
@@ -465,7 +465,7 @@
         if (paymentPreference.get("securityCode") != null) {
             processContext.put("cardSecurityCode", paymentPreference.get("securityCode"));
         }
-
+        
         // get the billing information
         getBillingInformation(orh, paymentPreference, processContext);
 
@@ -1727,8 +1727,9 @@
     
             // set the avs/fraud result
             response.set("gatewayAvsResult", context.get("avsCode"));
+            response.set("gatewayCvResult", context.get("cvCode"));
             response.set("gatewayScoreResult", context.get("scoreCode"));
-    
+
             // set the auth info
             response.set("amount", context.get("processAmount"));
             response.set("referenceNum", context.get("authRefNum"));
@@ -1769,6 +1770,7 @@
             if (context != null && authResult.booleanValue()) {
                 orderPaymentPreference.set("statusId", "PAYMENT_AUTHORIZED");
                 orderPaymentPreference.set("securityCode", null);
+                orderPaymentPreference.set("track2", null);                
             } else if (context != null && !authResult.booleanValue()) {
                 orderPaymentPreference.set("statusId", "PAYMENT_DECLINED");
             } else {

Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Sat Mar 15 04:31:20 2008
@@ -940,7 +940,15 @@
               verification code; also note that this field is longer than needed to accommodate encryption.
           </description>
       </field>
+      <field name="track2" type="long-varchar" encrypt="true">
+          <description>NOTE: THIS SHOULD NEVER BE PERSISTED OUTSIDE THE SCOPE OF A SINGLE TRANSACTION,
+              TYPICALLY ONLY FOR AUTHORIZATION PURPOSES, SHOULD BE REMOVED IMMEDIATELY FOLLOWING USE;
+              this is raw track2 data, exactly as read by the magnetic swipe reader;
+              also note that this field is longer than needed to accommodate encryption.
+          </description>
+      </field>
       <field name="presentFlag" type="indicator"></field>
+      <field name="swipedFlag" type="indicator"></field>
       <field name="overflowFlag" type="indicator"></field>
       <field name="maxAmount" type="currency-amount"></field>
       <field name="processAttempt" type="numeric"></field>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sat Mar 15 04:31:20 2008
@@ -1525,11 +1525,12 @@
             }
         }
         inf.singleUse = isSingleUse;
+        inf.isPresent = isPresent;
         if (replace) {
             paymentInfo.remove(inf);
         }
         paymentInfo.add(inf);
-
+                
         return inf;
     }
 
@@ -4464,9 +4465,11 @@
         public String securityCode = null;
         public String postalCode = null;
         public String[] refNum = new String[2];
+        public String track2 = null;
         public Double amount = null;
         public boolean singleUse = false;
-        public boolean isPresent = false;
+        public boolean isPresent = false;    
+        public boolean isSwiped = false;
         public boolean overflow = false;
 
         public GenericValue getValueObject(GenericDelegator delegator) {
@@ -4574,6 +4577,7 @@
                         GenericValue opp = delegator.makeValue("OrderPaymentPreference");
                         opp.set("paymentMethodTypeId", valueObj.getString("paymentMethodTypeId"));
                         opp.set("presentFlag", isPresent ? "Y" : "N");
+                        opp.set("swipedFlag", isSwiped ? "Y" : "N");
                         opp.set("overflowFlag", overflow ? "Y" : "N");
                         opp.set("paymentMethodId", paymentMethodId);
                         opp.set("finAccountId", finAccountId);
@@ -4587,6 +4591,9 @@
                         if (securityCode != null) {
                             opp.set("securityCode", securityCode);
                         }
+                        if (track2 != null) {
+                           opp.set("track2", track2);
+                        }
                         if (paymentMethodId != null || "FIN_ACCOUNT".equals(paymentMethodTypeId)) {
                             opp.set("statusId", "PAYMENT_NOT_AUTH");
                         } else if (paymentMethodTypeId != null) {
@@ -4610,6 +4617,7 @@
                     GenericValue opp = delegator.makeValue("OrderPaymentPreference");
                     opp.set("paymentMethodTypeId", valueObj.getString("paymentMethodTypeId"));
                     opp.set("presentFlag", isPresent ? "Y" : "N");
+                    opp.set("swipedFlag", isSwiped ? "Y" : "N");
                     opp.set("overflowFlag", overflow ? "Y" : "N");
                     opp.set("paymentMethodId", paymentMethodId);
                     opp.set("finAccountId", finAccountId);
@@ -4621,6 +4629,9 @@
                     }
                     if (securityCode != null) {
                         opp.set("securityCode", securityCode);
+                    }
+                    if (track2 != null) {
+                        opp.set("track2", securityCode);
                     }
                     if (paymentMethodId != null || "FIN_ACCOUNT".equals(paymentMethodTypeId)) {
                         opp.set("statusId", "PAYMENT_NOT_AUTH");

Added: ofbiz/trunk/framework/base/component-load.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/component-load.xml?rev=637395&view=auto
==============================================================================
--- ofbiz/trunk/framework/base/component-load.xml (added)
+++ ofbiz/trunk/framework/base/component-load.xml Sat Mar 15 04:31:20 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<ofbiz-component name="base"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
+    <resource-loader name="main" type="component"/>
+    <classpath type="jar" location="build/lib/*"/>
+    <classpath type="dir" location="config"/>
+    <classpath type="jar" location="lib/*"/>
+
+    <test-suite loader="main" location="testdef/basetests.xml"/>
+</ofbiz-component>

Propchange: ofbiz/trunk/framework/base/component-load.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: ofbiz/trunk/framework/base/component-load.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties Sat Mar 15 04:31:20 2008
@@ -92,3 +92,5 @@
 order_not_found=ORDER NOT FOUND
 problems_reading_card=PROBLEMS READING SWIPED CARD
 product_not_found=PRODUCT NOT FOUND
+INVALID_EXPIRATION_DATE=The expiration date should be 4 digits.
+INVALID_SECURITY_CODE=The security code should be 3 or 4 digits.

Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties Sat Mar 15 04:31:20 2008
@@ -93,3 +93,5 @@
 problems_reading_card=Probl\u00e8me lors de la lecture de la carte
 product_not_found=Produit inconnu !
 promo_page=Ce sera la page des promotions...
+INVALID_EXPIRATION_DATE=La date d'expiration doit comporter 4 chiffres
+INVALID_SECURITY_CODE=Le code doit comporter 3 ou 4 chiffres.

Modified: ofbiz/trunk/specialpurpose/pos/config/pos.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/pos.properties?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/pos.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/pos.properties Sat Mar 15 04:31:20 2008
@@ -80,3 +80,5 @@
 draw=Dr:
 term=Term:
 total_report=TOTALS REPORT
+SECURITYCODE=Enter security code:
+POSTALCODE=Enter the billing postal code:

Modified: ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties Sat Mar 15 04:31:20 2008
@@ -80,3 +80,5 @@
 draw=Tiroir :
 term=Terminal :
 total_report=TOTAUX
+SECURITYCODE=Enter votre code :
+POSTALCODE=Entrez le code postal :

Added: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml?rev=637395&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml (added)
+++ ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml Sat Mar 15 04:31:20 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<XPage>
+    <Components>
+        <Panel name="errorPanel" x="0" y="0" w="400" h="200" style="errorpanel" border="0" alignment="Center">
+            <Button w="400" h="200" name="closeBtn" style="error" content="INVALID_EXPIRATION_DATE" alignment="Center"/>
+        </Panel>
+    </Components>
+</XPage>

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidexpirationdate.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml?rev=637395&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml (added)
+++ ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml Sat Mar 15 04:31:20 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<XPage>
+    <Components>
+        <Panel name="errorPanel" x="0" y="0" w="400" h="200" style="errorpanel" border="0" alignment="Center">
+            <Button w="400" h="200" name="closeBtn" style="error" content="INVALID_SECURITY_CODE" alignment="Center"/>
+        </Panel>
+    </Components>
+</XPage>

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/error/invalidsecuritycode.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=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Sat Mar 15 04:31:20 2008
@@ -705,6 +705,32 @@
         inf.refNum[1] = authCode;
     }
 
+    /* CVV2 code should be entered when a card can't be swiped */
+    public void setPaymentSecurityCode(String paymentId, String refNum, String securityCode) {
+        trace("setting payment security code", paymentId);
+        int paymentIndex = cart.getPaymentInfoIndex(paymentId, refNum);    
+        ShoppingCart.CartPaymentInfo inf = cart.getPaymentInfo(paymentIndex);
+        inf.securityCode = securityCode;
+        inf.isSwiped = false;
+    }
+
+    /* Track2 data should be sent to processor when a card is swiped. */
+    public void setPaymentTrack2(String paymentId, String refNum, String securityCode) {
+        trace("setting payment security code", paymentId);
+        int paymentIndex = cart.getPaymentInfoIndex(paymentId, refNum);    
+        ShoppingCart.CartPaymentInfo inf = cart.getPaymentInfo(paymentIndex);
+        inf.securityCode = securityCode;
+        inf.isSwiped = true;
+    }
+
+    /* Postal code should be entered when a card can't be swiped */
+    public void setPaymentPostalCode(String paymentId, String refNum, String postalCode) {
+        trace("setting payment security code", paymentId);
+        int paymentIndex = cart.getPaymentInfoIndex(paymentId, refNum);    
+        ShoppingCart.CartPaymentInfo inf = cart.getPaymentInfo(paymentIndex);
+        inf.postalCode = postalCode;
+    }
+
     public void clearPayments() {
         trace("all payments cleared from sale");
         cart.clearPayments();

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Input.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Input.java?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Input.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Input.java Sat Mar 15 04:31:20 2008
@@ -37,7 +37,8 @@
     public static final String module = Input.class.getName();
     private static final String[] validFunc = { "CHECK", "CHECKINFO", "CLOSE", "CREDIT", "GIFTCARD", "LOGIN", "MGRLOGIN",
                                                 "MSRINFO", "OPEN", "PAID", "PAID_IN", "PAID_OUT", "PROMOCODE", "QTY",
-                                                "REFNUM", "SHIFT", "TOTAL", "UNLOCK", "VOID"};
+                                                "REFNUM", "SHIFT", "TOTAL", "UNLOCK", "VOID", "TRACK2", "SECURITYCODE",
+                                                "CREDITEXP", "POSTALCODE"};
                                                 
 
     protected Stack functionStack = new Stack();

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=637395&r1=637394&r2=637395&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 Sat Mar 15 04:31:20 2008
@@ -141,6 +141,7 @@
                 if (credInfo == null) {
                     PosScreen.currentScreen.getInput().setFunction("CREDIT", "");
                 }
+                PosScreen.currentScreen.getInput().setFunction("TRACK2", new String(track2));
                 PosScreen.currentScreen.getInput().setFunction("MSRINFO", msrStr.toString());
                 PosScreen.currentScreen.getOutput().print("Credit Card Read");
                 PosScreen.currentScreen.getInput().clearInput();
@@ -164,7 +165,7 @@
 
     private void setPayPanel() {
         if (!"main/paypanel".equals(PosScreen.currentScreen.getName())) {
-            PosScreen pos = PosScreen.currentScreen.showPage("paypanel", false);            
+            PosScreen pos = PosScreen.currentScreen.showPage("paypanel", false);
             pos.getInput().setFunction("TOTAL", "");
             pos.refresh();
             Debug.log("Switched to paypanel.xml; triggered TOTAL function", module);

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java Sat Mar 15 04:31:20 2008
@@ -99,6 +99,12 @@
                 PaymentEvents.setRefNum(pos);
             } else if ("CREDIT".equals(lastFunc[0])) {
                 PaymentEvents.payCredit(pos);
+            } else if ("CREDITEXP".equals(lastFunc[0])) {
+                PaymentEvents.payCredit(pos);
+            } else if ("SECURITYCODE".equals(lastFunc[0])) {
+                PaymentEvents.payCredit(pos);
+            } else if ("POSTALCODE".equals(lastFunc[0])) {
+                PaymentEvents.payCredit(pos);
             } else if ("CHECK".equals(lastFunc[0])) {
                 PaymentEvents.payCheck(pos);
             } else if ("GIFTCARD".equals(lastFunc[0])) {

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PaymentEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PaymentEvents.java?rev=637395&r1=637394&r2=637395&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PaymentEvents.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PaymentEvents.java Sat Mar 15 04:31:20 2008
@@ -109,7 +109,11 @@
         Input input = pos.getInput();
         String[] msrInfo = input.getFunction("MSRINFO");
         String[] crtInfo = input.getFunction("CREDIT");
-
+        String[] track2Info = input.getFunction("TRACK2");
+        String[] securityCodeInfo = input.getFunction("SECURITYCODE");
+        String[] postalCodeInfo = input.getFunction("POSTALCODE");
+        String[] creditExpirationInfo = input.getFunction("CREDITEXP");
+        
         // check for no/external payment processing
         int paymentCheck = trans.checkPaymentMethodType("CREDIT_CARD");
         if (paymentCheck == PosTransaction.NO_PAYMENT) {
@@ -128,13 +132,19 @@
 
         // now for internal payment processing
         if (crtInfo == null) {
+            // set total, if entered
+            input.clearLastFunction();
+            input.setFunction("TOTAL");
             input.setFunction("CREDIT");
             pos.getOutput().print(UtilProperties.getMessage("pos","CREDNO",Locale.getDefault()));
         } else {
             Debug.log("Credit Func Info : " + crtInfo[1], module);
-            if (msrInfo == null) {
+            if (msrInfo == null && (creditExpirationInfo == null))  {
+                //test credit card
                 if (UtilValidate.isNotEmpty(input.value()) && UtilValidate.isCreditCard(input.value())) {
-                    input.setFunction("MSRINFO");
+                    input.clearLastFunction();
+                    input.setFunction("CREDIT");
+                    input.setFunction("CREDITEXP");
                     pos.getOutput().print(UtilProperties.getMessage("pos","CREDEX",Locale.getDefault()));
                 } else {
                     Debug.log("Invalid card number - " + input.value(), module);
@@ -142,14 +152,52 @@
                     input.clearInput();
                     pos.showDialog("dialog/error/invalidcardnumber");
                 }
+            } else if (msrInfo == null && (securityCodeInfo == null) ){
+                // test expiration date
+                if (UtilValidate.isNotEmpty(input.value()) && (input.value().length() == 4)) {
+                    // ask for Security Code, put in SECURITYCODE
+                    input.clearLastFunction();
+                    input.setFunction("CREDITEXP");
+                    input.setFunction("SECURITYCODE");
+                    pos.getOutput().print(UtilProperties.getMessage("pos","SECURITYCODE",Locale.getDefault()));
+                } else {
+                    Debug.log("Invalid expiration date", module);
+                    clearInputPaymentFunctions(pos);
+                    input.clearInput();
+                    pos.showDialog("dialog/error/invalidexpirationdate");
+                }
+            }else if (msrInfo == null && (postalCodeInfo == null) ){
+                // test security code - allow blank for illegible cards
+                if (UtilValidate.isEmpty(input.value()) ||
+                        (UtilValidate.isNotEmpty(input.value()) && (input.value().length() <= 4))) {
+                    // ask for Security Code, put in SECURITYCODE
+                    input.clearLastFunction();
+                    input.setFunction("SECURITYCODE");
+                    input.setFunction("POSTALCODE");
+                    pos.getOutput().print(UtilProperties.getMessage("pos","POSTALCODE",Locale.getDefault()));
+                } else {
+                    clearInputPaymentFunctions(pos);
+                    input.clearInput();
+                    pos.showDialog("dialog/error/invalidsecuritycode");
+                }
             } else {
-                String msrInfoStr = msrInfo[1];
-                if (UtilValidate.isNotEmpty(input.value())) {
-                    if (UtilValidate.isNotEmpty(msrInfoStr)) {
-                        msrInfoStr = msrInfoStr + "|" + input.value();
-                    } else {
-                        msrInfoStr = input.value();
+                String msrInfoStr = null;
+                if (msrInfo == null){
+                    input.clearLastFunction();
+                    input.setFunction("POSTALCODE");
+                    postalCodeInfo = input.getFunction("POSTALCODE");
+                    if(UtilValidate.isNotEmpty(crtInfo[1])){
+                        if(UtilValidate.isNotEmpty(creditExpirationInfo[1])){
+                            // setup keyed transaction
+                            msrInfoStr = crtInfo[1] + "|" + creditExpirationInfo[1];
+                        }else {
+                            msrInfoStr = crtInfo[1];
+                        }                        
                     }
+                } else {  // is swiped
+                    // grab total from input, if available
+                    input.setFunction("TOTAL");
+                    msrInfoStr = msrInfo[1];
                 }
                 input.clearFunction("MSRINFO");
                 input.setFunction("MSRINFO", msrInfoStr);
@@ -165,9 +213,12 @@
                     case 2: // card number & exp date found
                         double amount = 0;
                         try {
-                            amount = processAmount(trans, pos, crtInfo[1]);
+                            String[] totalInfo = input.getFunction("TOTAL");
+                            amount = processAmount(trans, pos, totalInfo[1]);
                             Debug.log("Processing Credit Card Amount : " + amount, module);
                         } catch (GeneralException e) {
+                            Debug.logError("Exception caught calling processAmount.", module);
+                            Debug.logError(e.getMessage(), module);
                         }
 
                         String cardNumber = msrInfoArr[0];
@@ -176,6 +227,17 @@
                         if (pmId != null) {
                             trans.addPayment(pmId, amount);
                         }
+                        if (track2Info != null && UtilValidate.isNotEmpty(track2Info[1])){
+                            // if swiped
+                            trans.setPaymentTrack2(pmId, null, track2Info[1]);
+                        }else{ //keyed
+                            if(securityCodeInfo != null && UtilValidate.isNotEmpty(securityCodeInfo[1])){
+                                trans.setPaymentSecurityCode(pmId, null, securityCodeInfo[1]);
+                            }
+                            if(postalCodeInfo != null && UtilValidate.isNotEmpty(postalCodeInfo[1])){
+                                trans.setPaymentPostalCode(pmId, null, postalCodeInfo[1]);
+                            }
+                        }
                         clearInputPaymentFunctions(pos);
                         pos.refresh();
                         break;
@@ -191,7 +253,7 @@
             }
         }
     }
-
+    
     private static synchronized void processNoPayment(PosScreen pos, String paymentMethodTypeId) {
         PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
 
@@ -352,7 +414,8 @@
     // processed or if an error occurred
     public static synchronized void clearInputPaymentFunctions(PosScreen pos) {
         String[] paymentFuncs = {"CHECK", "CHECKINFO", "CREDIT",
-                                    "GIFTCARD", "MSRINFO", "REFNUM"};
+                                    "GIFTCARD", "MSRINFO", "REFNUM", "CREDITEXP",
+                                    "TRACK2", "SECURITYCODE", "POSTALCODE" };
         Input input = pos.getInput();
         for (int i = 0; i < paymentFuncs.length; i++) {
             while (input.isFunctionSet(paymentFuncs[i])) {