diff --git a/pos/config/XuiLabels.properties b/pos/config/XuiLabels.properties
index 5682f4f8b..5cae7c1b1 100644
--- a/pos/config/XuiLabels.properties
+++ b/pos/config/XuiLabels.properties
@@ -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.
diff --git a/pos/config/XuiLabels_fr.properties b/pos/config/XuiLabels_fr.properties
index d0b2ff3dc..b47e09d7c 100644
--- a/pos/config/XuiLabels_fr.properties
+++ b/pos/config/XuiLabels_fr.properties
@@ -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.
diff --git a/pos/config/pos.properties b/pos/config/pos.properties
index a8ea8ffa4..aeee2ccdc 100644
--- a/pos/config/pos.properties
+++ b/pos/config/pos.properties
@@ -80,3 +80,5 @@ clerk=Clerk:
draw=Dr:
term=Term:
total_report=TOTALS REPORT
+SECURITYCODE=Enter security code:
+POSTALCODE=Enter the billing postal code:
diff --git a/pos/config/pos_fr.properties b/pos/config/pos_fr.properties
index 45fe7cebc..2b343560c 100644
--- a/pos/config/pos_fr.properties
+++ b/pos/config/pos_fr.properties
@@ -80,3 +80,5 @@ clerk=Vendeur :
draw=Tiroir :
term=Terminal :
total_report=TOTAUX
+SECURITYCODE=Enter votre code :
+POSTALCODE=Entrez le code postal :
diff --git a/pos/screens/default/dialog/error/invalidexpirationdate.xml b/pos/screens/default/dialog/error/invalidexpirationdate.xml
new file mode 100644
index 000000000..bcbce0e68
--- /dev/null
+++ b/pos/screens/default/dialog/error/invalidexpirationdate.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
diff --git a/pos/screens/default/dialog/error/invalidsecuritycode.xml b/pos/screens/default/dialog/error/invalidsecuritycode.xml
new file mode 100644
index 000000000..71906b182
--- /dev/null
+++ b/pos/screens/default/dialog/error/invalidsecuritycode.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
diff --git a/pos/src/org/ofbiz/pos/PosTransaction.java b/pos/src/org/ofbiz/pos/PosTransaction.java
index 50ffe2c8a..54c2bea7d 100644
--- a/pos/src/org/ofbiz/pos/PosTransaction.java
+++ b/pos/src/org/ofbiz/pos/PosTransaction.java
@@ -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();
diff --git a/pos/src/org/ofbiz/pos/component/Input.java b/pos/src/org/ofbiz/pos/component/Input.java
index 3d97add35..4560af06f 100644
--- a/pos/src/org/ofbiz/pos/component/Input.java
+++ b/pos/src/org/ofbiz/pos/component/Input.java
@@ -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();
diff --git a/pos/src/org/ofbiz/pos/device/impl/Msr.java b/pos/src/org/ofbiz/pos/device/impl/Msr.java
index fc667b8b0..921567361 100644
--- a/pos/src/org/ofbiz/pos/device/impl/Msr.java
+++ b/pos/src/org/ofbiz/pos/device/impl/Msr.java
@@ -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);
diff --git a/pos/src/org/ofbiz/pos/event/MenuEvents.java b/pos/src/org/ofbiz/pos/event/MenuEvents.java
index 26a0f261a..c6ae4ea22 100644
--- a/pos/src/org/ofbiz/pos/event/MenuEvents.java
+++ b/pos/src/org/ofbiz/pos/event/MenuEvents.java
@@ -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])) {
diff --git a/pos/src/org/ofbiz/pos/event/PaymentEvents.java b/pos/src/org/ofbiz/pos/event/PaymentEvents.java
index 2f2bf87a4..6832195da 100644
--- a/pos/src/org/ofbiz/pos/event/PaymentEvents.java
+++ b/pos/src/org/ofbiz/pos/event/PaymentEvents.java
@@ -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])) {