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)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@637395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2008-03-15 11:31:20 +00:00
parent 0eaffca0cf
commit 9fc42f2bce
11 changed files with 171 additions and 14 deletions
+2
View File
@@ -92,3 +92,5 @@ no_sales=No sales saved
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.
+2
View File
@@ -93,3 +93,5 @@ order_not_found=N\u00b0 de transaction inconnu !
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.
+2
View File
@@ -80,3 +80,5 @@ clerk=Clerk:
draw=Dr:
term=Term:
total_report=TOTALS REPORT
SECURITYCODE=Enter security code:
POSTALCODE=Enter the billing postal code:
+2
View File
@@ -80,3 +80,5 @@ clerk=Vendeur :
draw=Tiroir :
term=Terminal :
total_report=TOTAUX
SECURITYCODE=Enter votre code :
POSTALCODE=Entrez le code postal :
@@ -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>
@@ -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>
+26
View File
@@ -705,6 +705,32 @@ public class PosTransaction implements Serializable {
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();
+2 -1
View File
@@ -37,7 +37,8 @@ public class Input implements KeyboardReceiver, KeyListener {
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();
+2 -1
View File
@@ -141,6 +141,7 @@ public class Msr extends GenericDevice {
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 @@ public class Msr extends GenericDevice {
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);
@@ -99,6 +99,12 @@ public class MenuEvents {
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])) {
+75 -12
View File
@@ -109,7 +109,11 @@ public class PaymentEvents {
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 @@ public class PaymentEvents {
// 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 @@ public class PaymentEvents {
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 @@ public class PaymentEvents {
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 @@ public class PaymentEvents {
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 @@ public class PaymentEvents {
}
}
}
private static synchronized void processNoPayment(PosScreen pos, String paymentMethodTypeId) {
PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
@@ -352,7 +414,8 @@ public class PaymentEvents {
// 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])) {