Thursday 6 November 2014

Assigning Items to Shipping Groups In ATG

                   when ever first order is created,it has an empty shipping group,this will serves as default shipping group,this default shipping group is defined by a property defaultShippingGroupType in OrderTools component.
OrderTools.properties
defaultShippingGroupType=hardgoodShippingGroup
1.If there is a only one shipping group,if you add any commerce item to order that item is part of default shipping group.
Ex1:
Shipping group : default shipping group.
Commerce Items : ci1,ci2,ci3,ci4
Order : all the items will set to default shipping group
2.if there is any other shipping groups in order,then the items we have to explicitly assigned to one of the existed shipping groups.
Ex2:
Shipping group : sgp1,sgp2
Commerce Items : ci1,ci2,ci3
Order : so order contains 3 items and 2 shipping groups
1. ci1 and ci2 we are setting to sgp1
2. c i3 setting to sgp2
Before order is checked every item in the order must and should part of shipping group(s),this requirement check by the validateForCheckout pipeline,validateForCheckout pipeline validates a different part of theOrder as complete.

In validateForCheckout pipelinechain we have one processor validateShippingGroupsForCheckout,this processor validates the shipping groups in the order.As per the ATG,shipping group will complete when ever it met the below criteria.

I..name, address, city, state, and postal code these fields should not be empty in ShippingGroup

II.All of the items in order should be assigned to shipping group,for this some requirements are there.

            If there is only one ShippingGroup in the Order and no relationships exist between that ShippingGroup and the commerce items in the Order, then the shipping of all commerce items in the Order implicitly is accounted for by that ShippingGroup.

             If there is only one ShippingGroup in the Order and relationships exist between that ShippingGroup and the commerce items in the Order, or if there is more than one ShippingGroup in the Order, then every CommerceItem in the Order must have its shipping explicitly accounted for with one or more ShippingGroupCommerceItemRelationship objects, as follows:

              *1.If a CommerceItem has a ShippingGroupCommerceItemRelationship of type ShippingQuantityRemaining, then the item’s shipping is accounted for regardless of whether it has other shipping relationships. This is because a “remaining” relationship type covers any quantity of the CommerceItem that is not accounted for by other shipping relationships.

              *2.If a CommerceItem has one or more ShippingGroupCommerceItemRelationship objects of type ShippingQuantity, but no relationship of typeShippingQuantityRemaining, then the total quantity of the CommerceItem covered by the relationships must be equal to or greater than the quantity in theCommerceItem.
The range property in the ShippingGroupCommerceItemRelationship identifies which particular items out of the total quantity of a CommerceItem are associated with a given ShippingGroup.

Wednesday 5 November 2014

Pipeline Customization in ATG


Pipeline is a collection of processors which executes sequentially.

 Step 1 : Updated commercepipeline.xml to add new processor class

 Step 2 : Here we are injecting the new processor class as the sepcond processor in the updateOrder chain.
 Step 3 :we have to Register the new processor as a nucleus component.



 Step 4 :we have to create Custom Processor class that should be an implementation of PipelineProcessor
 Step 5 :Restart your ATG  Server.

Explanation :
OOTB : \config\atg\commerce\commercepipeline.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <pipelinemanager>
       <pipelinechain name="updateOrder" transaction="TX_REQUIRED" headlink="updateOrderObject">
        <pipelinelink name="updateOrderObject" transaction="TX_MANDATORY">
            <processor jndi="/atg/commerce/order/processor/SaveOrderObject"/>
            <transition returnvalue="1" link="updateCommerceItemObjects"/>
        </pipelinelink>

        <pipelinelink name="updateCommerceItemObjects" transaction="TX_MANDATORY">
            <processor jndi="/atg/commerce/order/processor/SaveCommerceItemObjects"/>
            <transition returnvalue="1" link="updateShippingGroupObjects"/>
        </pipelinelink>
..........
   </pipelinemanager>
 
 
Step 1 and Step2 :Customization/Configuration:
   <pipelinemanager>
       <pipelinechain name="updateOrder" transaction="TX_REQUIRED" headlink="updateOrderObject">
        <pipelinelink name="updateOrderObject" transaction="TX_MANDATORY">
            <processor jndi="/atg/commerce/order/processor/SaveOrderObject"/>
            <transition returnvalue="1" link="checkInventoryObject"/>
        </pipelinelink>

<pipelinelink name="checkInventoryObject" transaction="TX_MANDATORY">
            <processor jndi="/inventory/processor/ProcCheckInventory"/>
            <transition returnvalue="1" link="updateCommerceItemObjects"/>
       </pipelinelink>

        <pipelinelink name="updateCommerceItemObjects" transaction="TX_MANDATORY">
            <processor jndi="/atg/commerce/order/processor/SaveCommerceItemObjects"/>
            <transition returnvalue="1" link="updateShippingGroupObjects"/>
        </pipelinelink>
...........
   </pipelinemanager>
 
Step3 : ProcCheckInventory.properties(/inventory/processor/ProcCheckInventory)
        $class=/info/atgblog/inventory/processor/ProcCheckInventory

Step4 :ProcCheckInventory.java

        public class ProcCheckInventory extends ApplicationLoggingImpl implements PipelineProcessor {

          public int[] getRetCodes() {
       return new int{1,2};
        }
  public int runProcess(final Object pParam, final PipelineResult pResult)
throws Exception {
// check inventory and return the status accordingly
return 1;
   }
       }




Tuesday 4 November 2014

ATG Local Set Up


 Required Softwares
  Oracle 11g XE

  ATG10.1.1
  Jboss-eap-5.1  
  SqlDeveloper
  Eclipse 
Step 1: Create a connection with system/admin in Sql developer,system is just like a administrator   hence using system schema will create our own schema/user 



Step 2: In system, create a table space like atgtablespace.DBF with the help of following query and create a User in that table space and grant permissions to that user like,hence all our tables will store in our own schema under the path C:\oraclexe\app\oracle\oradata\XE

atg_dev.
create tablespace atg_tablespace
logging
datafile 'C:/oraclexe/app/oracle/oradata/XE/atgtablespace.DBF'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
create user atg_dev identified by atg_dev default tablespace atg_tablespace;
grant connect,resource,dba to atg_dev;
commit;
Step 3:
Create a new database connection with 
   Connectionname: atg_dev
   Username: atg_dev        paassword:atg_dev



Step 4: 
   For getting all OOTB tables into our schema we have to run those tables into our own schema
In atg_dev, Execute below scripts sequence order from the sql developer.
\ATG\ATG10.1.1\DAS\sql\install\oracle\das_ddl.sql
\ATG\ATG10.1.1\DPS\sql\install\oracle\dps_ddl.sql
\ATG\ATG10.1.1\DSS\sql\install\oracle\dss_ddl.sql
\ATG\ATG10.1.1\DCS\sql\install\oracle\dcs_ddl.sql


Step 5: We need to create ds file like atg_ds. xml in the folder 
C:\jboss-eap-5.1\jboss-as\server\dev\deploy 
  <?xml version="1.0" encoding="UTF-8"?>
<datasources>
<!-- @version $Id: //product/CIM/version/10.1.1/plugins/Base/filetemplate/jboss-open-ds.xml#1 $$Change: 690623 $-->
<xa-datasource>
          <jndi-name>ATGProductionDS</jndi-name>
          <isSameRM-override-value>false</isSameRM-override-value>
          <min-pool-size>5</min-pool-size>
          <max-pool-size>100</max-pool-size>
          <blocking-timeout-millis>5000</blocking-timeout-millis>
          <idle-timeout-minutes>15</idle-timeout-minutes>
          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
 <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:xe</xa-datasource-property>


          <xa-datasource-property name="User">atg_training</xa-datasource-property>
          <xa-datasource-property name="Password">atg_training</xa-datasource-property>
          <!-- Uncomment the following if you are using Oracle 9i
          <xa-datasource-property name="oracle.jdbc.V8Compatible">true</xa-datasource-property>
         -->
          <exception-sorter-class-name>
              org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
          </exception-sorter-class-name>
    </xa-datasource>
<!-- @version $Id: //product/CIM/version/10.1.1/plugins/Base/filetemplate/jboss-oraclethin-xa-ds.xml#1 $$Change: 690623 $-->
</datasources>
<!-- @version $Id: //product/CIM/version/10.1.1/plugins/Base/filetemplate/jboss-close-ds.xml#1 $$Change: 690623 $-->
    
In this Datasource file we need to change URL, username, Password as per our data base schema
   
     URL: jdbc:oracle:thin:@localhost:1521:xe
     Username: atg_dev
      Password: atg_dev
JNDI Name: We can give anything but same name we need to mention in JTDataSource property file of your component.  <Jndi-name>ATGProductionDS</Jndi-name>
Step 6: In the module we need to create JTDataSource.properties file in the path atg/dynamo/service/jdbc/JTDataSource.properties
  
 Need to Give following code in atg/dynamo/service/jdbc/JTDataSource.properties
    $class=atg.nucleus.JNDIReference
    JNDIName=java:/ATGProductionDS


Step 7Create deploy.bat and run.bat in your module.



Deploy.bat
   set ATG_HOME=C:\xxx\ATG\ATG10.1.1\home
set ATG_ROOT=C:\xxx\ATG\ATG10.1.1
set DYNAMO_HOME=C:\xxx\ATG\ATG10.1.1\home
set DYNAMO_ROOT=C:\xxx\ATG\ATG10.1.1
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_35
set JBOSS_HOME=C:\jboss-eap-5.1\jboss-as
set PATH=%PATH%;%JAVA_HOME%\bin;%JBOSS_HOME%\bin;
set CLASSPATH=%JBOSS_HOME%\lib;%JAVA_HOME%\lib;
cd %ATG_HOME%\bin
runAssembler %JBOSS_HOME%\server\dev\deploy\Atg.ear -m DafEar.Admin Training

Run.bat
set ATG_HOME=C:\xxx\ATG\ATG10.1.1\home
set ATG_ROOT=C:\xxx\ATG\ATG10.1.1
set DYNAMO_HOME=C:\xxx\ATG\ATG10.1.1\home
set DYNAMO_ROOT=C:\xxx\ATG\ATG10.1.1
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_35
set JBOSS_HOME=C:\jboss-eap-5.1\jboss-as
set PATH=%PATH%;%JAVA_HOME%\bin;%JBOSS_HOME%\bin;
set CLASSPATH=%JBOSS_HOME%\lib;%JAVA_HOME%\lib;
cd C:\jboss-eap-5.1\jboss-as\bin
run -c dev -b localhost | ATGLogColorizer_v1_2
Note: If you want to change the port number 
   Go to--> C:\jboss-eap-5.1\jboss-as\server\dev\deploy\jbossweb.sar\server.xml
Then create a new atg project in eclipse.

Then have to run deploy.bat like below





Then run.bat just like same.   
Before starting the application we have to change the port number because 8080 is already using by the oracle server hence we have to change the port in the locations.
C:\xxx\jboss-eap-5.1\jboss-as\server\dev\deploy\jbossweb.sar
Dev our own path 


<Connector protocol="HTTP/1.1" port="8888" address="${jboss.bind.address}" 
               connectionTimeout="20000" redirectPort="8443" />
And also in default folder path also 
C:\xxx\jboss-eap-5.1\jboss-as\server\dev\default\jbossweb.sar
<Connector protocol="HTTP/1.1" port="8888" address="${jboss.bind.address}" 
               connectionTimeout="20000" redirectPort="8443" />




ATG Interview Questions

Interview Questions related to ATG :
Q)How to create Component?
A) we can create it in 2 ways,
I) using ACC
II)by creating java+properties file in our module/Eclipse

Q)how to create custom Repository?
a)we have to create component/properties file
$class=atg.adapter.gsa.GSARepository
$scope=global
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory
dataSource=/atg/dynamo/service/jdbc/JTDataSource
definitionFiles=/com/my/myRepository.xml
idGenerator=/atg/dynamo/service/IdGenerator
transactionManager=/atg/dynamo/transaction/TransactionM
anager

Explanantion : have to tell all the properties in our component
Class is GSARepository OOTB it will do all oprations getitem, getiteforupdate

XMLToolsFactory : for parsing xml
definitionFiles : items info will keep here

idGenerator : for generating unique ids

transactionManager : for transation purpose either to commit or roll back i particular transaction/task

Q)How the module dependency happened in ATG ?
A)DAS DPS DSS DCS : from left to right
We maintained it in MANIFEST.MF file
Manifest-Version: 1.0
ATG-Config-Path: config/
ATG-Required: DAS DPS DSS DCS DAS
ATG-J2EE: j2ee-apps/testJ2ee
ATG-EAR-Module: j2ee-apps/testJ2ee
ATG-Class-Path: bin

Q)how the ATG will understand/initialize the components mean from which
path?
in MANIFEST.MF file we have to mention the ATG-Config-Path from here
ATG will pick the components and it will initialize.

Q)Scopes in ATG?
A) mainly we have 3 types of Scopes

1. Request

2. Session

3. Global

Global is the default scope

Every Nucleus component has a $scope property that controls the number of instances of the bean. You can specify scope (global, session, or request) when you create or edit a component 

Global :If a component has a global scope, there is one instance of the component for all users. (This means that the state of the component is the same for all users of the application.)

Session :If a component has a session scope, then every user gets a separate copy of the component that persists for the duration of that user's session. 

Request:If a component has a request scope, then simultaneous requests will each see a different copy of the component. This is true even if two requests from the same session come in at the same time.


Q)what is Nucleus?
A)first as component it will act then after its initialization over
it will act as Container to initialize all the components

Q)Differences between the item-type and Component-item-type in
definition(xml)file?
A)
i)When your property in the item-descriptor needs
to hold only one value which is of type of any other repository
item, use 'item-type=”item name”' attribute.

ii)when your property needs to hold a collection
(set/array/map/list) of items of type of any other repository item,
use data-type = "set/array/map/list" and
component-item-type=”another Item name” to specify what type each
one of the element in the collection

Ex : 

i)<item name=”student” >
        <propety name=”std name” item-type=”name” />
     </item>
<item name=”name”>
     <proeprty name=”student name”/>
</item>

ii)<item name=”student” >
    <propety name=”std classes” data-type=”set”component-item-type=”classes”/>
   </item>
  <item name=”classes”>
<proeprty name=”class name”/>
<proeprty name=”section name”/>
<proeprty name=”teachers name”/>
   </item>

Q)How connection will give from ATG module to DB
A)/atg/dynamo/service/jdbc/JTDataSource.properties
Using JTDataSource component will maintain the Schema/DB connection

Q)What are all the OOTB formhandlers you used in your application tell me 6?
A)mainly i used in my application level
i)CartModifierFormHandler
ii)PaymentGroupFormHandler
iii)ShippingGroupFormHandler
iv)CommitOrderFormHandler
v)GenericFormHandler
vi)ProfileFormHandler

Q)To write custom Droplet which OOTB class you will extend?
A) DynamoServlet we have to extend as a super class.

Q)How to write a Simple component not a droplet and from handler?
A)We have to write properties file and respective Java class.that class
will contain only fields and getters&setters,it should extends
GenericService

Q)How you will get a parameter in droplet which you give/assign it
in Jsp level.
A)by using getparameter() method

Q)which class will extend by every class in our ATG layer like object
class in Java.
A)here also Object class is the super most class, and every class will
extends GenericService

Q)How can i resolve/initialize a particular component with out
injecting in any component.
A)ATG provides one method resolveName(component name we have to provide)
in GenericService class using it we can initialse the componenet.


Q)What are all the input parameters for ForEach Droplet?
A)array,elementName,indexName....

Q)How we can achive Inheritence in ATG Repository level?
A)
sub-type-property="type"
super-type=”super item”

Ex : <item-descriptor name="shippingGroup" sub-type-property="type" />
<item-descriptor name="hardgoodShippingGroup" super-type="shippingGroup" />

Here hardgoodShippingGroup is the subitem(like class) shippingGroup is the super Item(class)
Hence all the features/properties of shippingGroup we can get it in hardgoodShippingGroup
item also.

Q)when or in which scenario i will go for ItemLookupDroplet?
A)to get complete item by providing id as a input parameter to that
droplet
ex : 
mylookup.properties
$class=atg.repository.servlet.ItemLookupDroplet
itemDescriptor=stdinfo
repository=/com/my/MyForm1Repository

Mylookup.jsp

<dsp:droplet name="/com/my/StudentLookUp">
       <dsp:param name="id" param="stdid"/>
               <dsp:param name="element" name="stdInfo"/>
                   <dsp:oparam name="output">
                             student id : <dsp:valueof param="element.stdid" />
                             student name : <dsp:valueof param="element.studentname" />
                  </dsp:oparam>
</dsp:droplet>

Here by passing id(studentid) as input parameter i am getting student
item(what ever i mentioned in component level
itemDescriptor=stdinfo)here stdinfo is an item which is having other
properties stdid and studentname.

Q)If i want to make one repository property as no Not Null what i have
to do?
A)To make it one property as a Not NULL in repository level i will
make it as required=true
ex:
<property name="textKey" column-name="text_key" data-type="string" required="true" />

Q)if i want to make a relation multi how many table i have to create
in repository level?
A)we have to make sure that, three tables are required
i)one is primary table
a)it will contain multi table
ii)reference for the multi table

ex :
<item-descriptor name="state">
    <table name="stateInfo" id-column-name="stateid" type="primary">
     <property name="stateid" column-name="STATE_ID"
    <property name="statename" column-name="STATE_NAME" data-type="String">
    </table>

    <table name="state_cities" id-column-name="stateid" type="multi">
     <property name="cities" column-name="CITIES" data-type="set" component-item-type="city"/>
   </table>

</item-descriptor>


<item-descriptor name="city" >
     <table name="cityInfo" id-column-name="cityid" type="primary">
        <property name="cityid" column-name="CITY_ID"   data-type="String"/>
       <property name="cityname" column-name="CITY_NAME" data-type="String"/>
    </table>
</item-descriptor>

Explanation : here i am doing state contain multiple cities,to achive
this i am using multi table concept by creating 3 table

Q)I created my repository but i am unable to see it in ACC/BCC to
create/modify/remove a particular item in my Repository,to achieve
this what i have to do?
A)in ContentRepositories.properties component we have to map/add our own custom repositor
to the property initialRepositories then only we can able to do see/create/update/remove
our items which are presented in our custom repository.

ex: ContentRepositories.properties
initialRepositories+=/com/myown/MyRepository,


Q)When Nucleus started/initialize that time i want to initialize some
of my custom components how we can do it?
in Initial.properties component we have to mention/map/add our custom component to
initialServices property
Ex : 
/atg/dynamo/Initial.properties
initialServices+=/atg/dynamo/service/ServerLockManager,\

Commerce Questions:
Q)when the order object will create?
A) when ever we calling ShoppingCart.current the will get current
order

Q)How to create our own/custom CommerceItem?
A)
Explanation : orderrepository.xml
Step 1
 have to customize in item in orderrepository.xml
<item-descriptor name="commerceItem" >
     <table name="my_commerce_item" type="auxiliary" id-column-         name="commerce_item_id">
            <property name="myproperty1" column-name="MYPROPERTY1" data-type=”String” />
            <property name="myproperty2" column-name="MYPROPERTY2"
data-type=”String” />
      </table>
<item-descriptor>

commerceItem item is there in OOTB level the same we are using but
we are creating auxiliary table(to add our custom properties) by giving
reference of OOTB primary table id using
id-column-name=commerce_item_id

Step2 : 
Mapping is required in /atg/commerce/order/OrderTools.properties

OrderTools.properties

beanNameToItemDescriptorMap+=com.common.commerce.order.MyCommerce
ItemImpl\=commerceItem
commerceItemTypeClassMap+=default\=com.common.commerce.order.MyCo
mmerceItemImpl

In OrderTools component we have to mapping item what ever we did in repository level with the JavaBean class.
beanNameToItemDescriptorMap : javaBean to ItemDescriptor mapping
commerceItemTypeClassMap : commerceItemType(commerceItem we did
in repository) to Class Mapping

Step3 :
 the JavaBean class what ever we created it must Extend the
CommerceItemImpl OOTB class

public class MyCommerceItemImpl extends CommerceItemImpl{
Fields(myproperty1,myproperty2) and respective getters/setters.
}

What ever the values we are setting to myproperty1,myproperty2 it will
set in CommerceItem level in order.

Step4 : How to set values to our custom CommerceItem
MyCartModifierFormHandler.java
             List<CommerceItem> commerceItems = order.getCommerceItems();
            for (CommerceItem commerceItem : commerceItems) {
                         if (commerceItem instanceof CommerceItemImpl){
                               commerceItemImpl = (MyCommerceItemImpl)commerceItem;
                               commerceItemImpl.setproperty(“myproperty1”,”some”);
                               commerceItemImpl.setproperty(“myproperty1”,”some”);
                         }
             }

Step5 : check the CommerceItem property in order level we will find
these two properties(in repository/DB level) also.
The same way we have to fallow for custom ConfigurableCommerceItem
and subSkuCommerceItem.

Q)Adding more items to CommerceItem is it possible?
A)No we can add only one type item(with more quantity) to order in
CommerceItem level, to achieve this mean add more items to order we
will go for ConfigurableCommerceItem concept instead of CommerceItem.

Q)How can i have to add an item as configurableCommerceItem to order?
A)have to call AddConfigurableItemToOrder() will use to add an item
to Order as a ConfigurableCommerceItem.
if you want to add an item as a commerceItem means will go for
AddItemToOrder() method in CartModifierFormHandler these methods are
available.

Q)How you can add subskuitem to order?
A)As a commerceItem we cant add more than one type of item,same type
of items we can add any number of items, but if we want to add different
type of items we have to go for ConfigurableCommerceItem.
For ConfigurableCommerceItem will add subskuitem.

EX :

 as a commerceItem :Computer(all peripherals from same vendor) is the CommerceItem
I can add to any number of items of type Computer
Ex: 

as a configurable commerce item :Computer(all peripherals from diff vendor) is the
ConfigurableCommerceItem,mean mouse is one item,keyboard is another
item(/Repository Item)
Code Snippet :

MyConfigurableCommerceItem configurableCommerceItem=MyConfigurableCommerceItem)
    getOrder.getCommerceItem(getconfigurableCommerceItemId());
    MySubSkuCommerceItem subSkuCommerceItem = (MySubSkuCommerceItem)
 getCommerceItemManager().createCommerceItem(“mousepointer”,“skuid”,null,”prod id”,null, “quantity”, null, null,null);

getCommerceItemManager().addSubItemToConfigurableItem(configurabl
eCommerceItem, subSkuCommerceItem);

Then the same configurable item will add to order by calling
AddConfigurableItemToOrder().

getconfigurableCommerceItemId() : will get it from jsp,by iterating
all commerceitems(mean we added configurableCommerceItem) from the
order level and will set it.

Q)How to add our own paymentGroup to order?
A)i will explain by taking GiftCard as a new PaymentMethod
Step1 : orderrepository.xml

<item-descriptor name="paymentGroup" xml-combine="append">
        <table name="dcspp_pay_group" type="primary">
        <property name="type" xml-combine="append" data-type="enumerated">
             <option value="giftCard" code="4" />
        </property>
        </table>
</item-descriptor>

<item-descriptor name="giftCard" super-type="paymentGroup" sub-type-value="giftCard">
         <table name="giftcardInfo" id-column-name="payment_group_id">
               <property name="giftcardNumber" column-name="gift_card_number"
                 display-name-resource="giftcardNumber" data-type="string"/>
               <property name="giftcardPin" column-name="gift_card_pin"
                display-name-resource="giftcardPin" data-type="string"/>
        </table>
</item-descriptor>

 Explanation : for the enumerated property of payment type i am adding one more
type using xml-combine="append",hence we added one more item of type
paymentGroup.
For that item/paymentgroup we added our required properties(numbr and
pin).

Step2 : OrderTools.proeprties
beanNameToItemDescriptorMap+=com.payment.GiftCard\=giftCard
paymentTypeClassMap+=\giftCard\=com.payment.GiftCard

Step3 : our custom payemnt method must extends PaymentGroupImpl

public class GiftCard extends PaymentGroupImpl{
public String mGiftcardNumber;
public String mGiftcardPin;
public String getGiftcardNumber() {
return (String) getPropertyValue("giftcardNumber");
} public void setGiftcardNumber(String pGiftcardNumber) {
setPropertyValue("giftcardNumber", pGiftcardNumber);
} public String getGiftcardPin() {
return (String) getPropertyValue("giftcardPin");
} public void setGiftcardPin(String pGiftcardPin) {
setPropertyValue("giftcardPin", pGiftcardPin);
}
}

PaymentGroupFormHandler.properties
MyPaymentGroupFormHandler.java
Maintain getters/setters for number and pin

handleGiftCardPayment(req,res){
        getPaymentGroupManager().removeEmptyPaymentGroups(getOrder());
        PaymentGroup paymentGroup =
                                        getPaymentGroupManager().createPaymentGroup("giftCard");
         paymentGroup.setPaymentMethod("giftCard");
        GiftCard giftcard = null;
         getPaymentGroupManager().addPaymentGroupToOrder(getOrder(), paymentGroup);
         List<PaymentGroup> paymentgroups = getOrder().getPaymentGroups();
                   for (PaymentGroup paymentGroup2 : paymentgroups) {
                            if(paymentGroup2 instanceof GiftCard){
                                   giftcard = (GiftCard) paymentGroup2;
                                   giftcard.setPropertyValue("giftcardNumber", getGiftcardNumber());
                                   giftcard.setPropertyValue("giftcardPin",getGiftcardPin());
                            }
                   }
     }


Mygiftcard.jsp

giftcardNumber:<dsp:inputbean="PaymentGroupFormHandler.giftcardNumber" type="text" />
giftCardPin:
<dsp:inputbean="PaymentGroupFormHandler.giftcardPin"/>
<dsp:inputbean="PaymentGroupFormHandler.giftCardPayment" type="submit"/>

Explanation : 
what ever we added(number and pin)in jsp as a input parameter we are setting to
PaymentGroupFormHandler,using getter method we get and setting into our payment
Method(giftcard),addPaymentGroupToOrder() using this method we are adding
custom payment method to Order.
The same way he have to fallow for adding custom Shipping Method also.


Q)Purchase process flow in ATG?
A)Home Page-->PDP Page--->Cart Page ---> shipping Page --> Payment Page --> Order View P Page --> Order Confirmation Page.


Q)What is CommerceItem?
A)CommerceItem is one of teh Repository Item in ATG,it will hold CatalogRefId,Quantity,PriceInfo,Auxiliary Data(ProdcutRef,CatalogRef,Product Id) of the item.

Q)What is Shipping Group?
A)ShippingGroup is one of the repository item(in Order Repository),it will hold the data Actual Ship Date,Description,Ship On Date,Shipping Group Class Type,Shipping Method, State,Submitted Date.

Mainly Contain,where the user want to ship the item what ever he purchased atg will maintain it in ShippingGroup.

Q)What is Payment Group?
Payment group is one of the repository Item in atg, it will hold data of Authorisation Status,Amount Credited||Debited||Authorised.

Q)How do you add an item to cart? 
Using addItemToOrder method of CartModifierFormHandler by passing catalogRefId, quantity and productId in the product details page. 

Q)How do you display items in the cart page? 
We will get the current order from the ShoppingCart component. We will pass the ShoppingCart.current.commerceItems to the ForEach droplet.

Q)How do you update the quantity of a commerce item in the cart page? 
we will call handleSetOrder method of CartModifierFormHandler to update the quantity


Q)How do u remove items from cart ? 
We will set the removalCommerceIds
To remove single item handleRemoveItemFromOrder method of CartModifierFormHandler.

Q)How do u proceed to checkout page? 
We will call to moveToPurchaseInfo method of the CartModifierFormHandler which will execute the moveToPurchaseInfo pipeline chain and check the order and commerce items and validates them.

Q)How do you set the shipping address to the order or shipping group?
 +We use the ShippingGroupDroplet to display all the available shipping addresses. 
+The ShipingGroupDroplet will get the available addresses from the Profile’s shipingAddress and secondaryAddresses properties.
 +Then the user will select the shippingAddress from the list. Then the selected address will be set the current shipping group by calling the handleApplyShippingGroups method of ShippingGroupFormHandler. 
+We can create a shipping group manually by using the ShippingGroupManager.createShippingGroup by passing the address. After that we call ShippingGroupManager.addShippingGroupToOrder method. +And we can get the available shippingGroup by order.getShippingGroups() 
The user will also select the shipping method and set to the shipping group such as NextDay , Two Day or Ground. 
+We will use AvailableShippingMethods droplet which fetches all the shipping methos names from the Shipping calculators. Each Shipping Calculator has a property called shiipingMethod.