Wednesday, January 2, 2013

Invoice Payment : ATG

 

Enabling the InvoiceRequestProcessor:


The InvoiceRequestProcessor does the work of creating invoices, based on the InvoiceRequestInfo object it receives. InvoiceRequestProcessor is then used by the ATG Business Commerce PaymentManager, just like the credit card and gift certificate processors.

The InvoiceRequestProcessor holds authorize(), debit(), and credit() methods. Authorize() and credit() are empty; you can add any business logic your site needs for these procedures. The debit() method invokes the InvoiceManager’s createInvoice() method, which creates a new invoice from the order and other information, then sends a JMS message indicating that the invoice was created.

To enable invoice payment, add a line to the PaymentNameToChainNameMap configuration file, located at /atg/commerce/payment/PaymentManager:

paymentGroupToChainNameMap=\
  atg.commerce.order.CreditCard=creditCardProcessorChain,\
  atg.commerce.order.GiftCertificate=giftCertificateProcessorChain,\
  atg.commerce.order.StoreCredit=storeCreditProcessorChain,\
  atg.commerce.order.Invoice=invoiceRequestProcessorChain

 
If you want to add further validation logic to your invoice processing, you should extend the InvoiceRequestProcessor.authorize() method.

Using the Invoice Manager:


The InvoiceManager class provides high-level access for creating, manipulating, saving and deleting Invoice objects in the Invoice Repository. Each action leads to execution of a pipeline chain, described later in this section. The InvoiceManager methods are:

addInvoice:
Adds a new Invoice repository item to the repository.

createInvoice:
Creates a new Invoice repository item.

findInvoicesByPropertyValue:
earches the repository for invoices having a particular set of property values.

getInvoiceForUpdate:
Gets the invoice with the specified repository id.

getInvoicesForInvoiceNumber:
Loads all invoices with a given invoice number. This method returns a list because an invoice number may not be unique. It is possible to have several invoices with the same invoice number but different repository id’s, for example if a new invoice is generated to reflect partial payment of an order and a reduction in the balance due. In most cases, however, this method returns a list containing only a single invoice.

getNextInvoiceNumber:
Generates the next unique invoice number to use.

loadInvoice:
Loads the invoice identified by a given repository id and executes the loadInvoice pipeline chain. See Invoice Pipelines for more information.

removeInvoice:
Removes the specified invoice from the repository.

updateInvoice:
Updates invoice properties in the invoice repository and sets the repository item’s lastModified property to the current date and time.

Invoice Pipelines


The InvoiceManager class executes pipelines whenever an invoice is created, loaded, updated, or removed. Each pipeline chain receives an object of type InvoicePipelineArgs as a parameter. InvoicePipelineArgs provides getInvoice() and getInvoiceManager() methods. You can also subclass InvoicePipelineArgs and alter the pipeline’s expected type if you need additional methods.

The chains are defined in the PipelineManager at /atg/commerce/invoice/pipeline/InvoicePipelineManager. Out of the box

addInvoice, updateInvoice, removeInvoice are important pipelineChains for invoice payment.

No comments:

Popular Posts