Author: jacopoc
Date: Tue Oct 16 08:25:38 2007
New Revision: 585172
URL: http://svn.apache.org/viewvc?rev=585172&view=rev
Log:
Completed implementation (in controller's event and user interface) for
security code for credit cards.
Issue # OFBIZ-767
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl
ofbiz/trunk/applications/order/webapp/ordermgr/entry/checkoutoptions.ftl
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=585172&r1=585171&r2=585172&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
Tue Oct 16 08:25:38 2007
@@ -43,6 +43,8 @@
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.webapp.stats.VisitHandler;
+import javolution.util.FastMap;
+
/**
* Events used for processing checkout and orders.
*/
@@ -171,7 +173,7 @@
request.setAttribute("_ERROR_MESSAGE_",
UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount",
UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ?
cart.getLocale() : Locale.getDefault())));
return "error";
}
- selectedPaymentMethods.put("EXT_BILLACT", billingAccountAmt);
+ selectedPaymentMethods.put("EXT_BILLACT",
UtilMisc.toMap("amount", billingAccountAmt, "securityCode", null));
}
if (UtilValidate.isEmpty(selectedPaymentMethods)) {
@@ -190,7 +192,7 @@
String gcPaymentMethodId = (String)
gcResult.get("paymentMethodId");
Double gcAmount = (Double) gcResult.get("amount");
if (gcPaymentMethodId != null) {
- selectedPaymentMethods.put(gcPaymentMethodId, gcAmount);
+ selectedPaymentMethods.put(gcPaymentMethodId,
UtilMisc.toMap("amount", gcAmount, "securityCode", null));
if
("Y".equalsIgnoreCase(request.getParameter("singleUseGiftCard"))) {
singleUsePayments.add(gcPaymentMethodId);
}
@@ -289,6 +291,12 @@
if (paymentMethods != null) {
for (int i = 0; i < paymentMethods.length; i++) {
+ Map paymentMethodInfo = FastMap.newInstance();
+
+ String securityCode = request.getParameter("securityCode_" +
paymentMethods[i]);
+ if (UtilValidate.isNotEmpty(securityCode)) {
+ paymentMethodInfo.put("securityCode", securityCode);
+ }
String amountStr = request.getParameter("amount_" +
paymentMethods[i]);
Double amount = null;
if (amountStr != null && amountStr.length() > 0 &&
!"REMAINING".equals(amountStr)) {
@@ -301,7 +309,8 @@
return null;
}
}
- selectedPaymentMethods.put(paymentMethods[i], amount);
+ paymentMethodInfo.put("amount", amount);
+ selectedPaymentMethods.put(paymentMethods[i],
paymentMethodInfo);
}
}
Debug.logInfo("Selected Payment Methods : " + selectedPaymentMethods,
module);
@@ -328,7 +337,7 @@
request.setAttribute("_ERROR_MESSAGE_",
UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount",
UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ?
cart.getLocale() : Locale.getDefault())));
return "error";
}
- selectedPaymentMethods.put("EXT_BILLACT", billingAccountAmt);
+ selectedPaymentMethods.put("EXT_BILLACT", UtilMisc.toMap("amount",
billingAccountAmt, "securityCode", null));
}
if (selectedPaymentMethods == null) {
@@ -381,7 +390,7 @@
String gcPaymentMethodId = (String) gcResult.get("paymentMethodId");
Double gcAmount = (Double) gcResult.get("amount");
if (gcPaymentMethodId != null) {
- selectedPaymentMethods.put(gcPaymentMethodId, gcAmount);
+ selectedPaymentMethods.put(gcPaymentMethodId,
UtilMisc.toMap("amount", gcAmount, "securityCode", null));
if
("Y".equalsIgnoreCase(request.getParameter("singleUseGiftCard"))) {
singleUsePayments.add(gcPaymentMethodId);
}
@@ -808,7 +817,7 @@
request.setAttribute("_ERROR_MESSAGE_",
UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount",
UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ?
cart.getLocale() : Locale.getDefault())));
return "error";
}
- selectedPaymentMethods.put("EXT_BILLACT", billingAccountAmt);
+ selectedPaymentMethods.put("EXT_BILLACT",
UtilMisc.toMap("amount", billingAccountAmt, "securityCode", null));
}
if (UtilValidate.isEmpty(selectedPaymentMethods)) {
@@ -820,6 +829,9 @@
String newPaymentMethodId = (String)
request.getAttribute("paymentMethodId");
if(! UtilValidate.isEmpty(newPaymentMethodId)) {
selectedPaymentMethods.put(newPaymentMethodId, null);
+ if (!selectedPaymentMethods.containsKey(newPaymentMethodId)) {
+ selectedPaymentMethods.put(newPaymentMethodId,
UtilMisc.toMap("amount", null, "securityCode", null));
+ }
}
// The selected payment methods are set
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=585172&r1=585171&r2=585172&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Tue Oct 16 08:25:38 2007
@@ -240,7 +240,8 @@
cart.clearPayments();
if (UtilValidate.isNotEmpty(billingAccountId)) {
- Double billingAccountAmt =
(Double)selectedPaymentMethods.get("EXT_BILLACT");
+ Map billingAccountMap =
(Map)selectedPaymentMethods.get("EXT_BILLACT");
+ Double billingAccountAmt =
(Double)billingAccountMap.get("amount");
// set cart billing account data and generate a payment method
containing the amount we will be charging
cart.setBillingAccount(billingAccountId, (billingAccountAmt !=
null? billingAccountAmt.doubleValue(): 0.0));
// copy the billing account terms as order terms
@@ -295,7 +296,7 @@
// XXX: Note that this step is critical for the billing
account to be charged correctly
if (amountToUse > 0) {
cart.setBillingAccount(billingAccountId, amountToUse);
- selectedPaymentMethods.put("EXT_BILLACT", new
Double(amountToUse));
+ selectedPaymentMethods.put("EXT_BILLACT",
UtilMisc.toMap("amount", new Double(amountToUse), "securityCode", null));
}
}
@@ -317,14 +318,20 @@
// get the selected amount to use
Double paymentAmount = null;
+ String securityCode = null;
if (selectedPaymentMethods.get(checkOutPaymentId) != null) {
- paymentAmount = (Double)
selectedPaymentMethods.get(checkOutPaymentId);
+ Map checkOutPaymentInfo = (Map)
selectedPaymentMethods.get(checkOutPaymentId);
+ paymentAmount = (Double) checkOutPaymentInfo.get("amount");
+ securityCode = (String)
checkOutPaymentInfo.get("securityCode");
}
boolean singleUse =
singleUsePayments.contains(checkOutPaymentId);
ShoppingCart.CartPaymentInfo inf =
cart.addPaymentAmount(checkOutPaymentId, paymentAmount, singleUse);
if (finAccountId != null) {
inf.finAccountId = finAccountId;
+ }
+ if (securityCode != null) {
+ inf.securityCode = securityCode;
}
}
} else if (cart.getGrandTotal() != 0.00) {
Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl?rev=585172&r1=585171&r2=585172&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl
(original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl Tue
Oct 16 08:25:38 2007
@@ -103,6 +103,7 @@
<span class="tabletext">
CC: ${Static["org.ofbiz.party.contact.ContactHelper"].formatCreditCard(creditCard)}
<#if
paymentMethod.description?has_content>(${paymentMethod.description})</#if>
+
${uiLabelMap.OrderCardSecurityCode} <input type="text" size="5"
maxlength="10" name="securityCode_${paymentMethod.paymentMethodId}" value=""/>
</span>
</td>
<td align="right"><a
href="/partymgr/control/editcreditcard?party_id=${orderParty.partyId}&paymentMethodId=${paymentMethod.paymentMethodId}"
target="_blank" class="buttontext">${uiLabelMap.CommonUpdate}</a></td>
Modified:
ofbiz/trunk/applications/order/webapp/ordermgr/entry/checkoutoptions.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/checkoutoptions.ftl?rev=585172&r1=585171&r2=585172&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/checkoutoptions.ftl
(original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/checkoutoptions.ftl
Tue Oct 16 08:25:38 2007
@@ -390,6 +390,7 @@
<span
class="tabletext">CC: ${Static["org.ofbiz.party.contact.ContactHelper"].formatCreditCard(creditCard)}</span>
<a
href="javascript:submitForm(document.checkoutInfoForm, 'EC',
'${paymentMethod.paymentMethodId}');"
class="buttontext">${uiLabelMap.CommonUpdate}</a>
<#if
paymentMethod.description?has_content><br/><span
class="tabletext">(${paymentMethod.description})</span></#if>
+
${uiLabelMap.OrderCardSecurityCode} <input type="text" size="5"
maxlength="10" name="securityCode_${paymentMethod.paymentMethodId}" value=""/>
</td>
</tr>
</#if>