Está en la página 1de 5

How to build a Payment Integration with

ATG Commerce
ATG Commerce performs credit card processing, address verification, and tax calculation through an
integration with a third party system. If your site uses CyberSource or CyberCash for credit card
processing then you'll find integrations shipped with your ATG Commerce distribution. Similarly, if you
are using CyberSource or TaxWare for your tax calculations, you can use one of the provided
integrations.
Credit Card Processing
ATG Commerce has been designed to rely on three possible operations to be performed for all credit
card processing operations, they include:
Authorize
Debit
Credit
ATG Commerce expects all of these operations to be performed by an implementation of
atg.payment.creditcard.CreditCardProcessor.
Note: For an example of a CreditCardProcessor see atg.integration.cybersource.CyberSourceCreditCard

Credit Card Classes
There are three important classes to consider when building a credit card payment integration.
CreditCardProcessor
This is the only required class for any payment integration. The CreditCardProcessor has 4 methods to
implement.
CreditCardStatus authorize(CreditCardInfo);
CreditCardStatus debit(CreditCardInfo, CreditCardStatus);
CreditCardStatus credit(CreditCardInfo, CreditCardStatus);
CreditCardStatus credit(CreditCardInfo);
Each of these methods will be explained below.
CreditCardInfo
The atg.payment.creditcard.CreditCardInfo interface is used to describe a particular amount on a
particular credit card. It has the following properties.
paymentId - The Id of the Credit Card's payment group in the Order.
amount - The amount being charged to the credit card
creditCardNumber - The Credit Card Number
creditCardType - The type of Credit Card (e.g. Visa)
expirationMonth -
expirationDayOfMonth -
expirationYear -
currencyCode -
billingAddress -
order -
ATG Commerce will pass an implementation of this interface to any call it makes on the credit card
processor. (atg.payment.creditcard.GenericCreditCardInfo)
CreditCardStatus
The atg.payment.creditcard.CreditCardStatus represents the result of one of the operations on the
CreditCardProcessor. It has the following properties:
authorizationExpiration - If this status is result of a call to authorize method, this
filed will give you the date of the authorization's expiration.
avsCode - If the payment system performed address verification
this field will store the result of that verification.
avsDescriptiveResult - If an address verification was performed, this will
describe the result.
transactionId - The transaction Id assigned by the payment system.
transactionSuccess - If the transaction succeeded, this will be true.
transactionTimeStamp - The date and time of the transaction.
errorMessage - If there was an error, this should be the descriptive
message from the payment system.
ATG Commerce expects an implementation of this interface as the result of each method on the credit
card processor.
Implementing the CreditCardProcessor
There are three kinds of operations that the credit card processor can perform a given credit card. The
work done by each method is very similar. All of them will require a connection to your external
payment system.





authorize()
When an order is first placed with ATG Commerce system, the credit card authorized to ensure the
customer has enough credit to make the purchase. When it is appropriate, ATG Commerce will call the
authorize() method on your new CreditCardProcessor. The authorize() method will need to perform the
following tasks.
1. Create a request for your payment system. This will be a class that will be provided with your
payment system product.
2. Copy the information from given CreditCardInfo into this request object.
3. Call the authorize() method on the Payment System.
4. Copy the results of this method into a new CreditCardStatus instance and return the status.
(Either using the CreditCardStatusImpl provided by ATG Commerce, or your own implementation)
debit()
Sometime during or after fulfillment of an order, the credit card will actually be charged the amount of
the order. This is done using the debit() method of CreditCardProcessor. The debit() method will need to
perform the following tasks:
1. Create a request for your payment system. This will be a class that is provided with your
payment system product.
2. Copy the information from given CreditCardInfo into this request object. You will also need to
copy the information from the given CreditCardStatus. This will be the CreditCardStatus that was
returned by a prior call to authorize. Your payment system may want to match the debit to the
authorize.
3. Call the debit method on the payment system.
4. Copy the results of this method into a new CreditCardStatus instance and return the status.
(Either using the CreditCardStatusImpl provided by ATG Commerce, or your own implementation)
credit()
If fulfillment needs to credit a credit card or a customer service representative needs to add a credit for
any reason, the credit() method on CreditCardProcessor is used. This method needs perform the
following tasks:
1. Create a request for your payment system. This will be a class that is provided with your
payment system product.
2. Copy the information from the given CreditCardInfo into this request object. You will also need
to copy information from the given CreditCardStatus. This will the CreditCardStatus that was
returned by a prior call to debit. Your payment system may want to match the credit to the
debit.
3. Call the credit method on the payment system.
4. Copy the result of this method into a new CreditCardStatus instance and return the status.
(Either using the CreditCardStatusImpl provided by ATG Commerce, or your own implementation)

Configuration
Now that you have a fully implemented CreditCardProcessor, you will need to configure ATG Commerce
to use it. These are the configuration changes that are required. The specific paths and file names used
below with the word "example" in them are from the example integration included with this document.
You should use your actual integration instead.
1. Create a Nucleus.properties file for your credit card processor.
localconfig/example/payment/MyCreditCardProcessor.properties
$class=example.payment.MyCreditCardProcessor
#Any settings required to communicate with your payment system
2. Tell the PaymentManager to use your new processor.
localconfig/atg/commerce/payment/PaymentManager.properties
creditCardProcessor=/example/payment/MyCreditCardProcessor
At this point, your ATG Commerce site will begin using your new payment integration.

También podría gustarte