Title: JavaDeveloper Tutorial
1Java Developer Tutorial
2CyberSource Component for JAVA
- Access all CyberSource Services
- 100 Pure Java
- Supports Multi Threaded Applications
- Available for Java 1.1.7 and Java 1.2.x
- Packaged for Unix and NT
3Getting Started
- Register - www.cybersource.com/register
- Download Java CDK ICS2 Developers Guide -
www.cybersource.com/support - Extract zip or jar file
- Run Ecert - java Ecert ltmerchant IDgt
- Edit Test Program
- Compile and Run Test
4Simple Web Order Form Requirements
- Collect Customer Payment Info
- Format CyberSource Request
- Transmit Request
- Process Response
- Message Customer
- Record Response
5Transaction Flow Diagram
Customer Browser
Merchant Server
Payment Processor
Cybersource
Billing Info
ics_auth
Auth Req
auth_rflag
Customer Message
Auth
6Application Diagram
Display Payment Info Form to Customer
Customer Approves Transaction
Card Declined. Ask Customer for another Credit
Card
rcode 0
Transaction Declined?
rcode 1, -1
rcode -1
Processing Error?
Log Transaction Info for Later Processing Message
Customer that they will Receive Final
Conformation via Email
rcode 1
Continue Processing Order
7Customer Order Form
8Create Connection Object
public void createICSClient() // create ICS
client object try client
new ICSClient("ICS2Test",certDir
"ICS2Test.pvt", certDir
"ICS2Test.crt","CyberSource_SJC_US",
certDir "CyberSource_SJC_US.crt", new
URL("http//ics2test.ic3.com"))
catch(Exception e)
System.out.println("ICS connect Error " e)
9Create Order Offer Object
offer new ICSClientOffer() // create offer
object //add Line Item public void
addLineItem(String ProductName,String
ProductCode, String ProductSKU,double
Amount,int Quantity,String PackerCode)
offer.setProductName(ProductName)
offer.setProductCode(ProductCode)
offer.setMerchantProductSKU(ProductSKU)
offer.setAmount(Amount) offer.setQuantity(Q
uantity) offer.setPackerCode(PackerCode)
10Create Request Object
private ICSClientRequest icsRequest
icsRequest.addApplication(ICSServiceName) //
request a service(s) icsRequest.setMerchantR
efNo(merchantRefNo) icsRequest.setMerchantI
D(merchantID) icsRequest.setCustomerFirstNa
me(firstName) icsRequest.setCustomerLastNam
e(lastName) icsRequest.setCustomerEmailAddr
ess(email) icsRequest.setCustomerPhone(phon
e) icsRequest.setBillAddress1(shipAddr1)
icsRequest.setBillCity(city)
icsRequest.setBillState(state)
icsRequest.setBillZip(zip)
icsRequest.setBillCountry(country)
icsRequest.setCustomerCreditCardNumber(cardNum)
icsRequest.setCustomerCreditCardExpirationMon
th(cardExpMonth) icsRequest.setCustomerCred
itCardExpirationYear(cardExpYear)
icsRequest.setCurrency(currency)
11Send Request and Receive Response
public int processICSTrans(ICSClientRequest
icsRequest) returnCode 0
try reply
client.send(icsRequest) returnCode
reply.getReplyCode()
catch(Exception e) System.out.println(e
) return returnCode
12Process Record Response
returnCode processICSTrans(icsReques
t) // proccess ICS request
if(returnCode 1 ) // check if request
accepted // Accepted
writeAcceptedMessage(response)
writeLogFile(logDir "accepted.log",
reply.toString()) // write reply to log
else ...
13Handle Decline and Error Messages
else
if(returnCode 0 ) // check if request
declined
// Declined
writeDeclinedMessage(response)
writeLogFile(logDir "declined.log",
reply.toString()) // write reply to log
else // rcode -1
// A Processing
Error Occured - Log for Later Attempt
writeAcceptedMessage(response)
writeLogFile(logDir "proc_error.log",
reply.toString()) // write reply to log
14Additional Application Considerations
- Add a Shopping Cart
- Calling Fraud, Tax, DAV if needed
- Semi Real-Time Authorization option
- Error Handling - Alerts, Logs
- Database Integration
15Cybersource Java API - Tips
- ICSClentRequest Class convenience methods i.e.
getReplyCode() - ICSMessage Class methods
- ICSMessage.setField(String, String)
- ICSMessage.getField(String)
16Cybersource Java API - more info
- ICS Dev Guide - Appendix J
- Java Doc
- Sample Code in test directory
- Partner Extranet Message Board