import ibilling.client.* import java.util.* public class Scenario2 { public static void main(String[] args) { //Set up clients' settings Map config = new HashMap(); config.put(SessionConnection.PROCESSOR_HOST, "http://server.ibillingclient.org/ibilling/xmlhttps"); config.put(SessionConnection.PAYMENT_OPTION_VERIFICATION_AMOUNT, 99); config.put("debug", true); //Login Session session = Session.login(2000, "welcome", config); //Create customer account CustomerAccount customerAccount = session.createCustomerAccount(); //code is optinal; if you specify the value, make sure the code is unique customerAccount.setCode("java.ca-2"); customerAccount.setMerchantAccountCode(2001); customerAccount.setFirstName("John"); customerAccount.setLastName("Smith"); customerAccount.setType(CustomerAccountType.Male); customerAccount.setHomePhone("2129856472"); customerAccount.setEmail("test@yahoo.com"); customerAccount.setStreet1("233 12th Street"); customerAccount.setCity("Columbus"); customerAccount.setState("NY"); customerAccount.setZipCode("31909"); //Create payment option PaymentOption paymentOption = customerAccount.createPaymentOption(); //code is optinal; if you specify the value, make sure the code is unique paymentOption.setCode("java.po-2"); paymentOption.setHolderName("John Smith"); paymentOption.setNumber("1000121279381"); //routing number paymentOption.setAccessory("610000227"); paymentOption.setType(PaymentOptionType.Checking); paymentOption.setStreet1("233 12th Street"); paymentOption.setCity("Columbus"); paymentOption.setState("CA"); paymentOption.setZipCode("31909"); //Create payment plan PaymentPlan paymentPlan = customerAccount.createPaymentPlan(); //code is optinal; if you specify the value, make sure the code is unique paymentPlan.setCode("java.pp-2"); //all amounts are in cents paymentPlan.setAmount(1000); //Item Codes must be setup in portal prior to being used paymentPlan.setItemCode("Membership"); paymentPlan.setType(PaymentPlanType.Perpetual); //Billing Cycle codes must be setup in portal prior to being used paymentPlan.setBillingCycleCode("W01"); //Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed. //paymentPlan.setFirstBillingDate(); paymentPlan.setPaymentOption(paymentOption); //Create invoice for downpayment RevenueTransaction revenueTransaction = customerAccount.createRevenueTransaction(); //code is optinal; if you specify the value, make sure the code is unique revenueTransaction.setCode("java.rt-2"); //ll amounts are in cents revenueTransaction.setAmount(5000); //Item Codes must be setup in portal prior to being used revenueTransaction.setItemCode("Membership"); //Type of transaction revenueTransaction.setAccountActivityType(AccountActivityType.Invoice); //Create payment for downpayment AssetTransaction transaction = customerAccount.createAssetTransaction(); //code is optinal; if you specify the value, make sure the code is unique transaction.setCode("java.at-2"); //all amounts are in cents transaction.setAmount(5000); transaction.setTransactionType(AssetTransactionType.Visa); //Credit card number to charge transaction.setAccountNumber("4111111111111111"); //Credit card expiration date transaction.setAccessory("1209"); //Type of transaction transaction.setAccountActivityType(AccountActivityType.Payment); //Add processing specific info (for better qualification rates CaptureInfo captureInfo = transaction.getCaptureInfo(); captureInfo.setHolderName("John Smith"); captureInfo.setCity("Columbus"); captureInfo.setState("CA"); captureInfo.setStreet("233 12th Street"); captureInfo.setZipCode("31909"); captureInfo.setPhone("2129856472"); captureInfo.setEmail("test@yahoo.com"); captureInfo.setCvv2("999"); //Mark object for persistence session.save(customerAccount); //Synchronize changes with the server try{ session.synchronize(); } catch(Exception ex){ //Be sure to properly handle exception, this is just a sample solution System.out.println(ex.getMessage()); return; } //Get info from customer account System.out.println(customerAccount.getCode()); System.out.println(customerAccount.getFirstName()); System.out.println(customerAccount.getLastName()); System.out.println(customerAccount.getCreateDate()); //Get info from payment option System.out.println(paymentOption.getCode()); System.out.println(paymentOption.getAccessory()); System.out.println(paymentOption.getNumber()); System.out.println(paymentOption.getCreateDate()); //Get info from payment plan System.out.println(paymentPlan.getCode()); System.out.println(paymentPlan.getFirstBillingDate()); System.out.println(paymentPlan.getBillingCycleCode()); System.out.println(paymentPlan.getCreateDate()); //Get info from revenue transaction System.out.println(revenueTransaction.getCode()); System.out.println(revenueTransaction.getAmount()); System.out.println(revenueTransaction.getAccountActivityType()); System.out.println(revenueTransaction.getCreateDate()); //Get info from asset transaction System.out.println(transaction.getCode()); System.out.println(transaction.getAccessory()); System.out.println(transaction.getAccountNumber()); System.out.println(transaction.getCreateDate()); //Get info from capture info System.out.println(captureInfo.getReturnType()); System.out.println(captureInfo.getApprovalCode()); System.out.println(captureInfo.getReferenceNumber()); //logout session.logout(); } }