[OFBiz] SVN: r6950 - trunk/applications/order/src/org/ofbiz/order/order

jonesde@svn.ofbiz.org jonesde at svn.ofbiz.org
Wed Mar 8 14:42:00 CST 2006


Author: jonesde
Date: 2006-03-08 14:41:57 -0600 (Wed, 08 Mar 2006)
New Revision: 6950

Modified:
   trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Log:
Fixed (hopefully) issue with purchasing digital products in ecommerce; now using system user to create invoice to avoid all of the permission problems; in other words based on the customer's actions the system is automatically doing some things on behalf of the customer that the customer should never be allowed to do manually, as the system account was meant for

Modified: trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java	2006-03-08 18:59:21 UTC (rev 6949)
+++ trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java	2006-03-08 20:41:57 UTC (rev 6950)
@@ -2575,10 +2575,16 @@
 
             if (invoiceItems) {
                 // invoice all APPROVED digital goods
-                Map invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", digitalItems, "userLogin", userLogin);
+                
+                // do something tricky here: run as a different user that can actually create an invoice, post transaction, etc
                 Map invoiceResult = null;
                 try {
+                    GenericValue permUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
+                    Map invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", digitalItems, "userLogin", permUserLogin);
                     invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext);
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, "ERROR: Unable to invoice digital items", module);
+                    return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemWithInvoiceCreationDigitalItemsNotFulfilled", locale));
                 } catch (GenericServiceException e) {
                     Debug.logError(e, "ERROR: Unable to invoice digital items", module);
                     return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemWithInvoiceCreationDigitalItemsNotFulfilled", locale));



More information about the Svn mailing list