Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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_AUTHROIZEDAUTHORIZED") 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);