Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This page is intended to be the root of cookbooks and/or FAQ (work in progress FAQ and cookbook will perhaps be separated later)

[Changing a field type in Derby|*field type in Derby]*
[Use cvv codes in OFBiz|*cvv codes]*

----
Changing a field type in Derby 

  1. Export the table to xml
  2. Drop the table
  3. Start OFBiz - table recreated with new structure
  4. Import xml data from #1

Advice from Adrian Crum.

----
Use cvv codes in OFBiz

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 enable 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_$

Unknown macro: {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)

Unknown macro: { 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)

Unknown macro: { List errorMessages = new ArrayList(); String errMsg = null; if (singleUsePayments == null){ singleUsePayments = new ArrayList(); }


        // set the payment method option
        if (selectedPaymentMethods != null && selectedPaymentMethods.size() > 0)

Unknown macro: { // 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))

Unknown macro: { // 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)

Unknown macro: { 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() }


else

Unknown macro: { // 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)

Unknown macro: { cart.setBillingAccount(null, 0.0); // erase existing billing account data errMsg = UtilProperties.getMessage(resource,"checkhelper.insufficient_credit_available_on_account", (cart != null ? cart.getLocale() }


else

Unknown macro: { // 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)

Unknown macro: { cart.setBillingAccount(billingAccountId, amountToUse); selectedPaymentMethods.put("EXT_BILLACT", new Double(amountToUse)); }


            }
            Set paymentMethods = selectedPaymentMethods.keySet();
            Iterator i = paymentMethods.iterator();
            while (i.hasNext())

Unknown macro: { 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)

Unknown macro: { // 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() }


        return errorMessages;
    }


Jacopo Cappellato [28/févr./07 11:52 PM]


  • No labels