[
https://issues.apache.org/jira/browse/OFBIZ-767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12476855
]
Jacopo Cappellato commented on OFBIZ-767:
-----------------------------------------
Am I wrong or OFBiz already supports this?
I think that the code is already written in the
OrderPaymentPreference.securityCode field and then removed by the sysytem alter
the transaction is done.
One quick way to enamble it is this:
1) add the following input field to the billsettings.ftl file (order component):
<input type="text" size="4" class="inputBox"
name="securityCode_${paymentMethod.paymentMethodId}" value=""/>
2) add the following code to the CheckOutEvents.getSelectedPaymentMethods(...):
String securityCode = request.getParameter("securityCode_" +
paymentMethods[i]);
if (securityCode != null && securityCode.length() > 0) {
paymentMethodInfo.put("securityCode", securityCode);
}
the trick here is that you'll have to change the paymentMethodInfo from a list
to a map
3) in CheckOutHelper.setCheckOutPaymentInternal(...) you'll have to retrieve
the cvv value from the above map; here is the method from an older modified
version of OFBiz:
public List setCheckOutPaymentInternal(Map selectedPaymentMethods, List
singleUsePayments, String billingAccountId, Double billingAccountAmt) {
List errorMessages = new ArrayList();
String errMsg = null;
if (singleUsePayments == null) {
singleUsePayments = new ArrayList();
}
// set the payment method option
if (selectedPaymentMethods != null && selectedPaymentMethods.size() >
0) {
// clear out the old payments
cart.clearPayments();
if (billingAccountId != null && billingAccountAmt != null &&
!billingAccountId.equals("_NA_")) {
// set cart billing account data and generate a payment method
containing the amount we will be charging
cart.setBillingAccount(billingAccountId,
billingAccountAmt.doubleValue());
} else if ("_NA_".equals(billingAccountId)) {
// if _NA_ was supplied, erase all billing account data
cart.setBillingAccount(null, 0.0);
}
// TODO: the following code needs some review (JAC20061213)
// if checkoutPaymentId == EXT_BILLACT, then we have billing
account only, so make sure we have enough credit
if (selectedPaymentMethods.containsKey("EXT_BILLACT") &&
selectedPaymentMethods.size() == 1) {
double accountCredit =
this.availableAccountBalance(cart.getBillingAccountId());
double amountToUse = cart.getBillingAccountAmount();
// if an amount was entered, check that it doesn't exceed
availalble amount
if (amountToUse > 0 && amountToUse > accountCredit) {
errMsg =
UtilProperties.getMessage(resource,"checkhelper.insufficient_credit_available_on_account",
(cart != null ? cart.getLocale() :
Locale.getDefault()));
errorMessages.add(errMsg);
} else {
// otherwise use the available account credit (The user
might enter 10.00 for an order worth 20.00 from an account with 30.00. This
makes sure that the 30.00 is used)
amountToUse = accountCredit;
}
// check that the amount to use is enough to fulfill the order
double grandTotal = cart.getGrandTotal();
if (grandTotal > amountToUse) {
cart.setBillingAccount(null, 0.0); // erase existing
billing account data
errMsg =
UtilProperties.getMessage(resource,"checkhelper.insufficient_credit_available_on_account",
(cart != null ? cart.getLocale() :
Locale.getDefault()));
errorMessages.add(errMsg);
} else {
// since this is the only selected payment method, let's
make this amount the grand total for convenience
amountToUse = grandTotal;
}
// associate the cart billing account amount and EXT_BILLACT
selected payment method with whatever amount we have now
// 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));
}
}
Set paymentMethods = selectedPaymentMethods.keySet();
Iterator i = paymentMethods.iterator();
while (i.hasNext()) {
String checkOutPaymentId = (String) i.next();
// get the selected amount to use
Double paymentAmount = null;
String securityCode = null;
if (selectedPaymentMethods.get(checkOutPaymentId) != null) {
Map checkOutPaymentInfo = (Map)
selectedPaymentMethods.get(checkOutPaymentId);
paymentAmount = (Double) checkOutPaymentInfo.get("amount");
securityCode = (String)
checkOutPaymentInfo.get("securityCode");
}
boolean singleUse =
singleUsePayments.contains(checkOutPaymentId);
cart.addPaymentAmount(checkOutPaymentId, paymentAmount,
singleUse);
ShoppingCart.CartPaymentInfo cpi =
cart.getPaymentInfo(cart.selectedPayments() - 1);
cpi.securityCode = securityCode;
}
} else if (cart.getGrandTotal() != 0.00) {
// only return an error if the order total is not 0.00
errMsg =
UtilProperties.getMessage(resource,"checkhelper.select_method_of_payment",
(cart != null ? cart.getLocale() : Locale.getDefault()));
errorMessages.add(errMsg);
}
return errorMessages;
}
Hope it helps
> Add support for cvvNumber field in CreditCard entity
> ----------------------------------------------------
>
> Key: OFBIZ-767
> URL: https://issues.apache.org/jira/browse/OFBIZ-767
> Project: OFBiz (The Open for Business Project)
> Issue Type: Improvement
> Components: accounting
> Affects Versions: SVN trunk
> Reporter: Ashish Vijaywargiya
> Priority: Trivial
> Attachments: CvvNumber_Field_Support.patch
>
>
> Hi,
> I have added support for cvvNumber field in CreditCard entity.
> In future , If somebody wants to use this field in his/her custom
> form/application.
> Any comments are most welcome.
> Thanks & Regards
> Ashish Vijaywargiya
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.