What happens after the user hits "Submit" on the Checkout Review Screen
This is more of a note taking page while I go through everything so it will be a little messy today.
The following URL is requested: <@ofbizUrl>processorder</@ofbizUrl>
- request: "processorder" invokes CheckOutEvents.createOrder. If response = "success" continue...
- request: "checkBlacklist" invokes CheckOutEvents.checkOrderBlacklist. If response = "success" continue..
- request: "processpayment" invokes CheckOutEvents.processPayment
Code Block |
---|
String processPayment(HttpServletRequest request, HttpServletResponse response)
|
This method calls:
Code Block |
---|
private static boolean processPayment(HttpServletRequest request)
|
Code Block |
---|
public Map processPayment(GenericValue productStore, GenericValue userLogin, boolean faceToFace, boolean manualHold)
|
request: processorder, invoke: java event: CheckOutEvents: createOrder, responses = sales_order|work_order|error, values = checkBlacklist|checkBlackList|checkoutreview
...
public static Map processPayment(String orderId, BigDecimal orderTotal, String currencyUomId, GenericValue productStore, GenericValue userLogin, boolean faceToFace, boolean manualHold, LocalDispatcher dispatcher, GenericDelegator delegator)
- allPaymentPreferences = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId)) --> allPaymentPreferences = EntityUtil.filterByAnd(allPaymentPreferences, canExpr);
- filters out items with "PAYMENT_CANCELLED"
- if "manualRefNum" has content then it processes/approves the order("serviceTypeEnum" = "PRDS_PAY_EXTERNAL") -->*SERVICE* dispatcher.runSync("processCaptureResult", captCtx)
- then it looks for OrderPaymentPrefernce entries with statusId = "PAYMENT_NOT_AUTH"
- *SERVICE*paymentResult = dispatcher.runSync("authOrderPayments", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin), 180, false);
<service name="authOrderPayments" engine="java"
location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="authOrderPayments" auth="true">
<description>Process (authorizes/re-authorizes) payments for an order</description>
<attribute name="orderId" type="String" mode="IN" optional="false"/>
<attribute name="processResult" type="String" mode="OUT" optional="false"/>
<attribute name="authResultMsgs" type="List" mode="OUT" optional="true"/>
<attribute name="reAuth" type="Boolean" mode="IN" optional="true"/>
</service>
public static Map authOrderPayments(DispatchContext dctx, Map context)
- orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId))
- Map lookupMap = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_AUTH");
- List orderList = UtilMisc.toList("maxAmount");
- paymentPrefs = delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList);
- check to see if it is a re-authorization(PAYMENT_AUTHORIZED) and if so, add it to the paymentPrefs map
- OrderReadHelper orh = new OrderReadHelper(orderHeader);
- BigDecimal totalRemaining = orh.getOrderGrandTotal();
- Authorize each order payment preference -- Iterator payments = paymentPrefs.iterator();
- *SERVICE* results = dispatcher.runSync("authOrderPaymentPreference", authContext)
<service name="authOrderPaymentPreference" engine="java"
location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="authOrderPaymentPreference" auth="true">
<description>Process (authorizes/re-authorizes) a single payment for an order with an optional overrideAmount</description>
<attribute name="orderPaymentPreferenceId" type="String" mode="IN" optional="false"/>
<attribute name="overrideAmount" type="BigDecimal" mode="IN" optional="true"/>
<attribute name="finished" type="Boolean" mode="OUT" optional="false"/>
<attribute name="errors" type="Boolean" mode="OUT" optional="false"/>
<attribute name="messages" type="List" mode="OUT" optional="true"/>
<attribute name="processAmount" type="BigDecimal" mode="OUT" optional="true"/>
</service>
public static Map authOrderPaymentPreference(DispatchContext dctx, Map context)
- orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId));
- orderHeader = orderPaymentPreference.getRelatedOne("OrderHeader");
- OrderReadHelper orh = new OrderReadHelper(orderHeader);
- goes through some stuff to check/set processAttempt
- checks if authorization has already occured ("PAYMENT_AUTHORIZED") is this a re-auth request??
- use overrideAmount or maxAmount??
- Map authPaymentResult = authPayment(dispatcher, userLogin, orh, orderPaymentPreference, totalRemaining, reAuth, transAmount
private static Map authPayment(LocalDispatcher dispatcher, GenericValue userLogin, OrderReadHelper orh, GenericValue paymentPreference, BigDecimal totalRemaining, boolean reauth, BigDecimal overrideAmount) throws GeneralException
- GenericValue paymentSettings = getPaymentSettings(orh.getOrderHeader(), paymentPreference, serviceType, false);
private static GenericValue getPaymentSettings(GenericValue orderHeader, GenericValue paymentPreference, String paymentServiceType, boolean anyServiceType)
- paymentSettings = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, paymentMethodTypeId, paymentServiceType, anyServiceType)
public static GenericValue getProductStorePaymentSetting(GenericDelegator delegator, String productStoreId, String paymentMethodTypeId, String paymentServiceTypeEnumId, boolean anyServiceType)
- storePayment = delegator.findByPrimaryKeyCache("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId));
*back to authPayment*
- Map processContext = new HashMap();
- getBillingInformation(orh, paymentPreference, processContext);
private static String getBillingInformation(OrderReadHelper orh, GenericValue paymentPreference, Map toContext) throws GenericEntityException {
processorResult = dispatcher.runSync(serviceName, processContext, TX_TIME, true);