Scenario 3: Java

From UniCharge Integration Library
Jump to: navigation, search

Download Source File


import ibilling.client.*
import java.util.*

public class Scenario3 {

  public static void main(String[] args) {
        //Set up clients' settings
    Map<String, Object> config  = new HashMap<String, Object>();
    config.put(SessionConnection.PROCESSOR_HOST, "https://[server-name]/ibilling/xmlhttps");
    config.put("debug"true);
    Session session  = Session.login(2000"welcome", config);
    //Find customer account
    CustomerAccount customerAccount  = session.loadCustomerAccount("java.ca-1");
    //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-3");
    //all amounts are in cents
    paymentPlan.setAmount(3000);
    //Item Codes must be setup in portal prior to being used
    paymentPlan.setItemCode("Membership");
    //Billing Cycle codes must be setup in portal prior to being used
    paymentPlan.setBillingCycleCode("M03");
    paymentPlan.setType(PaymentPlanType.Fixed);
    //Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
    //paymentPlan.setFirstBillingDate(<java.util.Date>);
    paymentPlan.add(06false);
    //frequency of the payment cycle, default value is 1
    //paymentPlan.setRecurrence(Integer reccurenceNumber)
    paymentPlan.setRecurrence(1);
    //Create child payment plan
    PaymentPlan childPaymentPlan  = paymentPlan.createLinkedPaymentPlan();
    //code is optinal; if you specify the value, make sure the code is unique
    childPaymentPlan.setCode("java.pp-3-1");
    childPaymentPlan.setType(PaymentPlanType.Perpetual);
    //all amounts are in cents
    childPaymentPlan.setAmount(2000);
    //Item Codes must be setup in portal prior to being used
    childPaymentPlan.setItemCode("Membership");
    //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;    }
    //logout
    session.logout();

  }

}</code>

Download Source File

Personal tools
Namespaces

Variants
Actions
Integration Info
Library Documentation
Toolbox