com.ibm.commerce.payment.commands
Class DoRefundPMCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.command.BusinessPolicyCommandImpl
                          |
                          +--com.ibm.commerce.payment.commands.DoRefundPMCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, DoRefundPolicyCmd, ECCommand, ECTargetableCommand, TaskCommand

public class DoRefundPMCmdImpl
extends BusinessPolicyCommandImpl
implements DoRefundPolicyCmd

This DoRefundPolicy business policy command implementation class is the default implementation class for refunding payment through WebSphere Commerce Payments. (The original payment method of the Order may be different)

Parameters:

Parameter Name Type Descriptions
abRMA RMAAccessBean The RMAAccessBean for the Return Merchandise Authorization (RMA) record
abOrder OrderAccessBean The OrderAccessBean of the order associated with the RMA
bdRefundAmount BigDecimal The amount of the refund in the currency of the Order.
errorViewName String Optional error view name passed in by the Caller.

Behavior:

Default Error View Name:

ErrorCodes:

This command uses the following AccessBeans:

This command does not call other TaskCommand.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
policyId, requestProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.payment.commands. DoRefundPolicyCmd
COPYRIGHT, defaultCommandClassName, ERRTASK_NAME, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECTargetableCommand
COPYRIGHT
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
DoRefundPMCmdImpl()
           
 
Method Summary
protected  void checkCurrencyAndGetChargeAmount()
          Checks the currency of the Order and the Store default currency.
protected   AccountAccessBean getAccount()
          Returns the AccountAccessBean representing the Account associated with the trading agreement specified by the RMA (Return Merchandise Authorization).
protected  java.lang.Long getAccountId()
          Returns the ID of the Account associated with the trading agreement specified by the RMA (Return Merchandise Authorization).
protected  java.math.BigDecimal getChargeAmount()
          Returns the charge amount.
protected  java.lang.String getChargeAmountCurrency()
          Returns the currency of the charge amount.
protected  java.lang.String getCurrencyExponent()
          Returns the currency exponent.
protected  java.lang.String getErrorViewName()
          Returns the name of the error view to use for reporting error.
protected  OrderAccessBean getOrder()
          Returns the OrderAccessBean representing the Order.
protected  java.math.BigInteger getPMRefundAmount()
          Returns the refund amount normalized for input to WebSphere Commerce Payments.
protected  java.math.BigDecimal getRefundAmount()
          Returns the refund amount.
protected   RMAAccessBean getRMA()
          Returns the RMA AccessBean representing the Return Merchandise Authorization record that authorizes the return of the merchandise.
 boolean isReadyToCallExecute()
          This method is called by the Command Framework to check if all basic mandatory parameters have been set for this command.
 void performExecute()
          Performs the main business logic of the command.
 void reset()
          Resets the instance variables of the command.
protected  void retrieveActiveAccountIdFromOrder()
          Retrieves the Account ID from the Trading Agreement associated with the RMA (Return Merchandise Authorization).
protected  void setAccountId(java.lang.Long nAccountId)
          Sets the accountId property of the command.
protected  void setChargeAmount(java.math.BigDecimal nChargeAmount)
          Sets the chargeAmount property of the command.
protected  void setChargeAmountCurrency(java.lang.String sCurrency)
          Sets the chargeAmountCurrency property of the command.
protected  void setCurrencyExponent(java.lang.String astrCurrencyExponent)
          Sets the currencyExponent.
 void setErrorViewName(java.lang.String sEVN)
          Sets the error view to be used to report error.
protected  void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
          Sets the numeric currency code
 void setOrder( OrderAccessBean ab)
          Sets the order property of the command.
protected  void setPMRefundAmount(java.math.BigInteger biPMRefundAmount)
          Sets the refund amount normalized for input to WebSphere Commerce Payments.
 void setRefundAmount(java.math.BigDecimal refundAmount)
          Sets the refundAmount property of the command.
 void setRMA( RMAAccessBean ab)
          Sets the RMA AccessBean representing the Return Merchandise Authorization record.
protected  void setupNumericCurrencyCodeAndPMRefundAmount()
          Retrieves the numeric currency code from the SETCURR Table and converts the refund amount to a normalized form required for input to WebSphere Commerce Payments.
protected  void updateOrderPaymentMethod()
          Updates ORDPAYMTHD table with refund information.
 
Methods inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command. BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 

Constructor Detail

DoRefundPMCmdImpl

public DoRefundPMCmdImpl()
Method Detail

checkCurrencyAndGetChargeAmount

protected void checkCurrencyAndGetChargeAmount()
                                        throws javax.ejb.CreateException,
                                               javax.ejb.FinderException,
                                               javax.naming.NamingException,
                                               java.rmi.RemoteException,
ECException
Checks the currency of the Order and the Store default currency. Converts the refund amount to the Store default currency and stores in ChargeAmount if the two currencies are different. Otherwise, stores the refund amount as-is in the ChargeAmount.
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException
ECException

getAccount

protected AccountAccessBean getAccount()
Returns the AccountAccessBean representing the Account associated with the trading agreement specified by the RMA (Return Merchandise Authorization).
Returns:
the AccountAccessBean

getAccountId

protected java.lang.Long getAccountId()
Returns the ID of the Account associated with the trading agreement specified by the RMA (Return Merchandise Authorization).
Returns:
the account ID

getChargeAmount

protected java.math.BigDecimal getChargeAmount()
Returns the charge amount.

The charge amount is the refund amount converted to the default currency of the Store. If the default currency of the Store is the same as the currency of the order, then the charge amount is the same as the refund amount.

Returns:
the charge amount

getChargeAmountCurrency

protected java.lang.String getChargeAmountCurrency()
Returns the currency of the charge amount.
Returns:
the alpha currency code representing the currency of the charge amount
See Also:
getChargeAmount

getCurrencyExponent

protected java.lang.String getCurrencyExponent()
Returns the currency exponent.
Returns:
the currency exponent for the currency of the order

getErrorViewName

protected java.lang.String getErrorViewName()
Returns the name of the error view to use for reporting error.
Returns:
the error view name

getOrder

protected OrderAccessBean getOrder()
Returns the OrderAccessBean representing the Order. This is the OrderAccessBean passed in to the command.
Returns:
the OrderAccessBean

getPMRefundAmount

protected java.math.BigInteger getPMRefundAmount()
Returns the refund amount normalized for input to WebSphere Commerce Payments.
Returns:
the normalized refund amount
See Also:
setPMRefundAmount

getRefundAmount

protected java.math.BigDecimal getRefundAmount()
Returns the refund amount. This is the refund amount passed in to the command.
Returns:
the amount to be refunded

getRMA

protected RMAAccessBean getRMA()
Returns the RMA AccessBean representing the Return Merchandise Authorization record that authorizes the return of the merchandise.
Returns:
the RMAAccessBean

isReadyToCallExecute

public boolean isReadyToCallExecute()
This method is called by the Command Framework to check if all basic mandatory parameters have been set for this command. This is done before the Framework calls the performExecute method of the command.
Overrides:
isReadyToCallExecute in class AbstractECTargetableCommand
Returns:
true if we can execute the command; false otherwise.

performExecute

public void performExecute()
                    throws ECException
Performs the main business logic of the command.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException

reset

public void reset()
Resets the instance variables of the command. The reset() method will reset all instance variables. If the command includes any output values that are accessible via getters, then make sure those values are no longer needed before calling this method to reset the instance variables of the command.

This is useful if the command instance is to be called multiple times with different command parameters.

Overrides:
reset in class AbstractECTargetableCommand

retrieveActiveAccountIdFromOrder

protected void retrieveActiveAccountIdFromOrder()
                                         throws javax.ejb.CreateException,
                                                javax.ejb.FinderException,
                                                javax.naming.NamingException,
                                                java.rmi.RemoteException,
ECException
Retrieves the Account ID from the Trading Agreement associated with the RMA (Return Merchandise Authorization).
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException
ECException

setAccountId

protected void setAccountId(java.lang.Long nAccountId)
Sets the accountId property of the command.
Parameters:
nAccountId - the Account ID..

setChargeAmount

protected void setChargeAmount(java.math.BigDecimal nChargeAmount)
Sets the chargeAmount property of the command.

The chargeAmount is the refund amount converted to the default currency of the Store.

Parameters:
nChargeAmount - the amount to be refunded converted to the default currency of the Store

setChargeAmountCurrency

protected void setChargeAmountCurrency(java.lang.String sCurrency)
Sets the chargeAmountCurrency property of the command.
Parameters:
sCurrency - the alpha currency code representing the currency of the charge amount

setCurrencyExponent

protected void setCurrencyExponent(java.lang.String astrCurrencyExponent)
Sets the currencyExponent.
Parameters:
astrCurrencyExponent - the currency exponent of the currency used for the order

setErrorViewName

public void setErrorViewName(java.lang.String sEVN)
Sets the error view to be used to report error. This overrides the default error view of the command.
Specified by:
setErrorViewName in interface DoRefundPolicyCmd
Parameters:
sEVN - the Error View name
See Also:
DoRefundPolicyCmd.ERRTASK_NAME

setNumericCurrencyCode

protected void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
Sets the numeric currency code
Parameters:
astrCurrencyCode - the currency code of the currency used for the order

setOrder

public void setOrder(OrderAccessBean ab)
Sets the order property of the command.
Specified by:
setOrder in interface DoRefundPolicyCmd
Parameters:
ab - the OrderAccessBean representing the Order associated with the Return Merchandise Authorization.

setPMRefundAmount

protected void setPMRefundAmount(java.math.BigInteger biPMRefundAmount)
Sets the refund amount normalized for input to WebSphere Commerce Payments.

The normalized amount is the amount converted to the smallest denomination for the currency. For example, if the refund amount is US $10.95, PMRefundAmount is 1095 in cents, which is the lowest denomination for this currency. If there is no smaller denomination other than the main currency unit for the currency, the normalized amount is the same as the refund amount.


setRefundAmount

public void setRefundAmount(java.math.BigDecimal refundAmount)
Sets the refundAmount property of the command.
Specified by:
setRefundAmount in interface DoRefundPolicyCmd
Parameters:
refundAmount - the amount to be refunded.

setRMA

public void setRMA(RMAAccessBean ab)
Sets the RMA AccessBean representing the Return Merchandise Authorization record.
Specified by:
setRMA in interface DoRefundPolicyCmd
Parameters:
ab - the RMAAccessBean

setupNumericCurrencyCodeAndPMRefundAmount

protected void setupNumericCurrencyCodeAndPMRefundAmount()
                                                  throws javax.ejb.CreateException,
                                                         javax.ejb.FinderException,
                                                         javax.naming.NamingException,
                                                         java.rmi.RemoteException,
ECException
Retrieves the numeric currency code from the SETCURR Table and converts the refund amount to a normalized form required for input to WebSphere Commerce Payments.

The normalized form of the amount is the amount converted to the lowest denomination of the currency. For example, if the amount is US $10.95, the normalized amount is 1095 in cents, which is the lowest denomination for this currency.

Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException
ECException

updateOrderPaymentMethod

protected void updateOrderPaymentMethod()
                                 throws javax.ejb.CreateException,
                                        javax.ejb.FinderException,
                                        javax.naming.NamingException,
                                        java.rmi.RemoteException
Updates ORDPAYMTHD table with refund information.

Creates a new ORDPAYMTHD record for the order with ORDPAYMTHD.refundNumber set to the RMA ID and ORDPAYMTHD.actualAmount set to the negative of the refund amount. Similarly, ORDPAYMTHD.chargeAmount is set to the negative of the refund amount converted to the default currency of the Store.

Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException