Author: jaz
Date: Mon Mar 26 21:41:12 2007 New Revision: 522744 URL: http://svn.apache.org/viewvc?view=rev&rev=522744 Log: changes to allow financial accounts to be used as payment methods without having to actually create payment records, by using payment method type FIN_ACCOUNT and using the (already existing) finAccountId on OrderPaymentPreference Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?view=diff&rev=522744&r1=522743&r2=522744 ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Mon Mar 26 21:41:12 2007 @@ -569,16 +569,11 @@ private static GenericValue getPaymentSettings(GenericValue orderHeader, GenericValue paymentPreference, String paymentServiceType, boolean anyServiceType) { GenericDelegator delegator = orderHeader.getDelegator(); GenericValue paymentSettings = null; - GenericValue paymentMethod = null; - try { - paymentMethod = paymentPreference.getRelatedOne("PaymentMethod"); - } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting PaymentMethod from OrderPaymentPreference", module); - } - if (paymentMethod != null) { + String paymentMethodTypeId = paymentPreference.getString("paymentMethodTypeId"); + + if (paymentMethodTypeId != null) { String productStoreId = orderHeader.getString("productStoreId"); - String paymentMethodTypeId = paymentMethod.getString("paymentMethodTypeId"); - if (productStoreId != null && paymentMethodTypeId != null) { + if (productStoreId != null) { paymentSettings = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, paymentMethodTypeId, paymentServiceType, anyServiceType); } } @@ -607,23 +602,26 @@ private static String getBillingInformation(OrderReadHelper orh, GenericValue paymentPreference, Map toContext) throws GenericEntityException { // gather the payment related objects. + String paymentMethodTypeId = paymentPreference.getString("paymentMethodTypeId"); GenericValue paymentMethod = paymentPreference.getRelatedOne("PaymentMethod"); - if (paymentMethod != null && paymentMethod.getString("paymentMethodTypeId").equals("CREDIT_CARD")) { + if (paymentMethod != null && "CREDIT_CARD".equals(paymentMethodTypeId)) { // type credit card GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard"); GenericValue billingAddress = creditCard.getRelatedOne("PostalAddress"); toContext.put("creditCard", creditCard); toContext.put("billingAddress", billingAddress); - } else if (paymentMethod != null && paymentMethod.getString("paymentMethodTypeId").equals("EFT_ACCOUNT")) { + } else if (paymentMethod != null && "EFT_ACCOUNT".equals(paymentMethodTypeId)) { // type eft GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount"); GenericValue billingAddress = eftAccount.getRelatedOne("PostalAddress"); toContext.put("eftAccount", eftAccount); toContext.put("billingAddress", billingAddress); - } else if (paymentMethod != null && paymentMethod.getString("paymentMethodTypeId").equals("GIFT_CARD")) { + } else if (paymentMethod != null && "GIFT_CARD".equals(paymentMethodTypeId)) { // type gift card GenericValue giftCard = paymentMethod.getRelatedOne("GiftCard"); toContext.put("giftCard", giftCard); + } else if ("FIN_ACCOUNT".equals(paymentMethodTypeId)) { + toContext.put("finAccountId", paymentPreference.getString("finAccountId")); } else { // add other payment types here; i.e. gift cards, etc. // unknown payment type; ignoring. @@ -668,6 +666,7 @@ List othExpr = UtilMisc.toList(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, "EFT_ACCOUNT")); othExpr.add(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, "CREDIT_CARD")); othExpr.add(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, "GIFT_CARD")); + othExpr.add(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, "FIN_ACCOUNT")); EntityCondition con1 = new EntityConditionList(othExpr, EntityJoinOperator.OR); EntityCondition statExpr = new EntityExpr("statusId", EntityOperator.EQUALS, "PAYMENT_SETTLED"); 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?view=diff&rev=522744&r1=522743&r2=522744 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Mon Mar 26 21:41:12 2007 @@ -286,6 +286,17 @@ Iterator i = paymentMethods.iterator(); while (i.hasNext()) { String checkOutPaymentId = (String) i.next(); + String finAccountId = null; + + if (checkOutPaymentId.indexOf("|") > -1) { + // split type -- ID|Actual + String[] splitStr = checkOutPaymentId.split("\\|"); + checkOutPaymentId = splitStr[0]; + if ("FIN_ACCOUNT".equals(checkOutPaymentId)) { + finAccountId = splitStr[1]; + } + Debug.log("Split checkOutPaymentId: " + splitStr[0] + " / " + splitStr[1], module); + } // get the selected amount to use Double paymentAmount = null; @@ -294,7 +305,10 @@ } boolean singleUse = singleUsePayments.contains(checkOutPaymentId); - cart.addPaymentAmount(checkOutPaymentId, paymentAmount, singleUse); + ShoppingCart.CartPaymentInfo inf = cart.addPaymentAmount(checkOutPaymentId, paymentAmount, singleUse); + if (finAccountId != null) { + inf.finAccountId = finAccountId; + } } } else if (cart.getGrandTotal() != 0.00) { // only return an error if the order total is not 0.00 Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=522744&r1=522743&r2=522744 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Mon Mar 26 21:41:12 2007 @@ -1434,38 +1434,40 @@ } /** adds a payment method/payment method type */ - public void addPaymentAmount(String id, Double amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) { + public CartPaymentInfo addPaymentAmount(String id, Double amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) { CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, true); inf.singleUse = isSingleUse; if (replace) { paymentInfo.remove(inf); } paymentInfo.add(inf); + + return inf; } /** adds a payment method/payment method type */ - public void addPaymentAmount(String id, Double amount, boolean isSingleUse) { - this.addPaymentAmount(id, amount, null, null, isSingleUse, false, true); + public CartPaymentInfo addPaymentAmount(String id, Double amount, boolean isSingleUse) { + return this.addPaymentAmount(id, amount, null, null, isSingleUse, false, true); } /** adds a payment method/payment method type */ - public void addPaymentAmount(String id, double amount, boolean isSingleUse) { - this.addPaymentAmount(id, new Double(amount), isSingleUse); + public CartPaymentInfo addPaymentAmount(String id, double amount, boolean isSingleUse) { + return this.addPaymentAmount(id, new Double(amount), isSingleUse); } /** adds a payment method/payment method type */ - public void addPaymentAmount(String id, Double amount) { - this.addPaymentAmount(id, amount, false); + public CartPaymentInfo addPaymentAmount(String id, Double amount) { + return this.addPaymentAmount(id, amount, false); } /** adds a payment method/payment method type */ - public void addPaymentAmount(String id, double amount) { - this.addPaymentAmount(id, new Double(amount), false); + public CartPaymentInfo addPaymentAmount(String id, double amount) { + return this.addPaymentAmount(id, new Double(amount), false); } /** adds a payment method/payment method type */ - public void addPayment(String id) { - this.addPaymentAmount(id, null, false); + public CartPaymentInfo addPayment(String id) { + return this.addPaymentAmount(id, null, false); } /** returns the payment method/payment method type amount */ @@ -4095,6 +4097,7 @@ public static class CartPaymentInfo implements Serializable, Comparable { public String paymentMethodTypeId = null; public String paymentMethodId = null; + public String finAccountId = null; public String securityCode = null; public String postalCode = null; public String[] refNum = new String[2]; @@ -4189,6 +4192,7 @@ opp.set("presentFlag", isPresent ? "Y" : "N"); opp.set("overflowFlag", overflow ? "Y" : "N"); opp.set("paymentMethodId", paymentMethodId); + opp.set("finAccountId", finAccountId); opp.set("billingPostalCode", postalCode); opp.set("maxAmount", amount); if (refNum != null) { @@ -4198,7 +4202,7 @@ if (securityCode != null) { opp.set("securityCode", securityCode); } - if (paymentMethodId != null) { + if (paymentMethodId != null || "FIN_ACCOUNT".equals(paymentMethodTypeId)) { opp.set("statusId", "PAYMENT_NOT_AUTH"); } else if (paymentMethodTypeId != null) { // external payment method types require notification when received |
Free forum by Nabble | Edit this page |