public static void main(String arg[]) throws Exception {
NetSuiteServiceLocator service = null;
NetSuiteBindingStub port = null;
Passport passport = new Passport();
passport.setAccount(NSCredentials.ACCOUNT);
passport.setEmail(NSCredentials.USER_NAME);
passport.setPassword(NSCredentials.USER_PWD);
Preferences preferences = new Preferences();
preferences.setIgnoreReadOnlyFields(true);
RecordRef role = new RecordRef();
role.setInternalId(NSCredentials.ROLE);
passport.setRole(role);
try {
service = new NetSuiteServiceLocator();
port = new NetSuiteBindingStub(new URL(service.getNetSuitePortAddress()), service);
port.setHeader(service.getServiceName().getNamespaceURI(), "passport", passport);
port.setHeader(service.getServiceName().getNamespaceURI(), "preferences", preferences);
} catch (Exception ex) {
ex.printStackTrace();
}
InitializeRecord initializeRecord = new InitializeRecord();
initializeRecord.setType(InitializeType.customerPayment);
InitializeRef initializeRef = new InitializeRef();
initializeRef.setInternalId("4"); // Set Internal Id of Customer
initializeRef.setType(InitializeRefType.customer);
initializeRecord.setReference(initializeRef);
ReadResponse readResponse = port.initialize(initializeRecord);
boolean success = logResponse("add", readResponse.getStatus());
if (success) {
CustomerPayment customerPayment = (CustomerPayment) readResponse.getRecord();
System.out.println(customerPayment);
if(customerPayment.getApplyList().getApply() != null){
int applyListCount = customerPayment.getApplyList().getApply().length;
for(int i = 0;i < applyListCount;i++){
CustomerPaymentApply customerPaymentApply = customerPayment.getApplyList().getApply(i);
customerPaymentApply.setApply(true);
}
}
WriteResponse writeResponse = port.add(customerPayment);
logResponse("add", writeResponse.getStatus());
}
}
private static boolean logResponse(String Operation, Status status) {
boolean success = status.isIsSuccess();
System.out.println(Operation + " success: " + success);
if (status.getStatusDetail() != null) {
int statusDetailCount = status.getStatusDetail().length;
for (int i = 0; i < statusDetailCount; i++) {
StatusDetail statusDetail = status.getStatusDetail(i);
System.out.println(Operation + " Type: "
+ statusDetail.getType() + " Code: "
+ statusDetail.getCode() + " Message: "
+ statusDetail.getMessage());
}
}
return success;
}
There is also a CustomerPaymentCreditList, i am not able to apply anything from this list.
ReplyDelete