atg.commerce.csr.order
Class CSRPaymentGroupRemainingAmount

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.commerce.csr.order.CSRPaymentGroupRemainingAmount
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, atg.servlet.ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class CSRPaymentGroupRemainingAmount
extends atg.servlet.DynamoServlet

This droplet returns payment group's remaining and maximum allowed amount.

This droplet is used in the billing, order view, order review pages and email display the remaining amount.
Also this droplet is used to enforce a maximum allowed amount limitation in the billing page.

The max allowed amount is served as parameter to serve a special need in the billing page. In the billing page
For a payment group, the user can enter any amount. But for the PaymentGroup backed by the claimable item,
the user can't enter more than the remaining or max allowed amount item.

Let us assume that user created an order for $1000.00 and used a store credit $200.00 (but the total amount on the store
credit is $500.00). Out of the $500.00, for this order the user used up $200.00 and paid the remaining with a
credit card. After assigning right amount for the order, the user submitted the order. Then after submitting the order, the user wanted
to edit the same order, added more items and to pay with the store credit. Technically the remaining amount on this store credit is
$300.00, but the maximum allowed amount that the user can enter in the text box could be up to $500.00. This parameter is to satisfy both use
cases such as new order and order modification.

This droplet could be customized to return the remaining and maximum allowed amount for additional payment group types.
Currently this droplet is used to get the remaining and maximum allowed amount for Store Credit and Gift Certificate.

This droplet takes in payment group and order as input parameters.

The parameters to the PaymentGroupRemainingAmount droplet are:

paymentGroup
This parameter is required for this droplet. This parameter is used to obtain the remaining and max allowed amount.
order
This is an optional parameter and this parameter is added for future use. The custom extensions may need to
work with the order.
output
This oparam is always rendered.
remainingAmount
The remaining amount is calculated for the payment group and returned in this parameter.
The remaining amount is only calculated for store credit and gift certificates.
Basically the this parameter returns the PaymentGroup remaining amount that is backed
by the claimable item. For more information see getRemainingAmount(PaymentGroup, Order).
maxAllowedAmount
The max allowed amount is calculated for the payment group and returned in this parameter.
Currently this parameter is used only in the billing page. The billing page requires a special
computation while editing the submitted order. For more information
see getMaxAllowedAmount(double, PaymentGroup, Order).
The max allowed amount is only calculated for store credit and gift certificates.


Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String MAX_ALLOWED_AMOUNT
           
protected  atg.commerce.claimable.ClaimableManager mClaimableManager
           
protected  CSRAgentTools mCSRAgentTools
           
static java.lang.String MY_RESOURCE_NAME
           
static double NO_LIMIT
           
static atg.nucleus.naming.ParameterName ORDER
           
static atg.nucleus.naming.ParameterName OUTPUT
           
static atg.nucleus.naming.ParameterName PAYMENT_GROUP
           
static java.lang.String REMAINING_AMOUNT
           
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CSRPaymentGroupRemainingAmount()
           
 
Method Summary
 atg.commerce.claimable.ClaimableManager getClaimableManager()
          Returns the claimableManager
 CSRAgentTools getCSRAgentTools()
          Returns the CSRAgentTools
protected  double getMaxAllowedAmount(double pRemainingAmount, atg.commerce.order.PaymentGroup pPaymentGroup, atg.commerce.order.Order pOrder)
          This method returns the maximum allowed amount for a payment group.
protected  atg.commerce.order.Order getOrder(atg.servlet.DynamoHttpServletRequest pRequest)
          This method gets the Order from the request.
protected  atg.commerce.order.PaymentGroup getPaymentGroup(atg.servlet.DynamoHttpServletRequest pRequest)
          This method gets the PaymentGroup from the request.
 double getRemainingAmount(atg.commerce.order.PaymentGroup pPaymentGroup, atg.commerce.order.Order pOrder)
          This method only returns the remaining amount for the Store Credit and Gift Certificate.
 void service(atg.servlet.DynamoHttpServletRequest pRequest, atg.servlet.DynamoHttpServletResponse pResponse)
          This method first calls getRemainingAmount(PaymentGroup, Order) to determine the payment group's remaining amount
and then it calls the getMaxAllowedAmount(double, PaymentGroup, Order) to compute the maximum allowed amount.
 void setClaimableManager(atg.commerce.claimable.ClaimableManager pClaimableManager)
          Sets the claimableManager
 void setCSRAgentTools(CSRAgentTools pAgentTools)
          Sets the CSRAgentTools
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

MY_RESOURCE_NAME

public static final java.lang.String MY_RESOURCE_NAME
See Also:
Constant Field Values

PAYMENT_GROUP

public static final atg.nucleus.naming.ParameterName PAYMENT_GROUP

ORDER

public static final atg.nucleus.naming.ParameterName ORDER

OUTPUT

public static final atg.nucleus.naming.ParameterName OUTPUT

REMAINING_AMOUNT

public static final java.lang.String REMAINING_AMOUNT
See Also:
Constant Field Values

MAX_ALLOWED_AMOUNT

public static final java.lang.String MAX_ALLOWED_AMOUNT
See Also:
Constant Field Values

NO_LIMIT

public static final double NO_LIMIT
See Also:
Constant Field Values

mClaimableManager

protected atg.commerce.claimable.ClaimableManager mClaimableManager

mCSRAgentTools

protected CSRAgentTools mCSRAgentTools
Constructor Detail

CSRPaymentGroupRemainingAmount

public CSRPaymentGroupRemainingAmount()
Method Detail

getClaimableManager

public atg.commerce.claimable.ClaimableManager getClaimableManager()
Returns the claimableManager

Returns:
the claimableManager

setClaimableManager

public void setClaimableManager(atg.commerce.claimable.ClaimableManager pClaimableManager)
Sets the claimableManager

Parameters:
pClaimableManager - the claimableManager to set

getCSRAgentTools

public CSRAgentTools getCSRAgentTools()
Returns the CSRAgentTools

Returns:
the CSRAgentTools

setCSRAgentTools

public void setCSRAgentTools(CSRAgentTools pAgentTools)
Sets the CSRAgentTools

Parameters:
pAgentTools - the CSRAgentTools to set

service

public void service(atg.servlet.DynamoHttpServletRequest pRequest,
                    atg.servlet.DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
This method first calls getRemainingAmount(PaymentGroup, Order) to determine the payment group's remaining amount
and then it calls the getMaxAllowedAmount(double, PaymentGroup, Order) to compute the maximum allowed amount.

After computing the remaining and maximum allowed amount, both parameters are served with the output
oparam.

Overrides:
service in class atg.servlet.DynamoServlet
Parameters:
pRequest - the HTTP request
pResponse - the HTTP response
Throws:
javax.servlet.ServletException
java.io.IOException

getMaxAllowedAmount

protected double getMaxAllowedAmount(double pRemainingAmount,
                                     atg.commerce.order.PaymentGroup pPaymentGroup,
                                     atg.commerce.order.Order pOrder)
                              throws atg.commerce.CommerceException
This method returns the maximum allowed amount for a payment group.
This method only supports store credit and gift certificate. You need to extend this method
if you want to compute maximum allowed amount for any other payment group type.

The maximum allowed amount is used in the billing page. In the billing page the user
can enter the maximum allowed amount for any payment group. This amount is used to restrict the
user not to enter more than the maximum allowed amount in the text box.

Currently the max allowed amount is used only in the billing page.
The maximum amount is computed as follows:

  • If the remaining amount is -1, then returns -1
  • If the claimables are configured NOT to honor the strict authorization (false),
    then returns remaining amount as max amount.
  • Otherwise max amount = payment group's authorized amount + remaining amount

Parameters:
pRemainingAmount - the remaining amount of a payment group
pPaymentGroup - the payment group which is used to calculated the maximum allowed amount.
pOrder - This is provided as an optional parameter. if there is any future need, you may make use this parameter.
Returns:
double the maximum allowed amount of a payment group.
Throws:
atg.commerce.CommerceException

getRemainingAmount

public double getRemainingAmount(atg.commerce.order.PaymentGroup pPaymentGroup,
                                 atg.commerce.order.Order pOrder)
                          throws atg.commerce.CommerceException
This method only returns the remaining amount for the Store Credit and Gift Certificate. If you want to compute remaining
amount for any other payment group type, you need to extend this method.

For other payment group type, this method returns -1 (which is considered as no limit).

First this method gets the store credit and gift certificate numbers from the payment group and gets the claimable item,
then method calls CSRAgentTools.getRemainingAmount(RepositoryItem) to get the
amount for store credits and gift certificate.

Parameters:
pPaymentGroup - The payment group which is used get the remaining amount. In case of store credit and gift certificate
the store credit and gift certificate numbers are retrieved from the payment group and then the remaining
amount is calculated.
pOrder - This is provided as an optional parameter. if there is any future need, you may make use this parameter.
Returns:
returns remaining amount. For unsupported payment group types, this method returns -1 (which is considered as no limit).
Throws:
atg.commerce.CommerceException
See Also:
CSRAgentTools#getRemainingAmount(RepositoryItem)} This method is called to get the remaining amount for the claimables.

getPaymentGroup

protected atg.commerce.order.PaymentGroup getPaymentGroup(atg.servlet.DynamoHttpServletRequest pRequest)
This method gets the PaymentGroup from the request.

Returns:
an PaymentGroup value

getOrder

protected atg.commerce.order.Order getOrder(atg.servlet.DynamoHttpServletRequest pRequest)
This method gets the Order from the request.

Returns:
an Order value