Scenario 12: Java

From UniCharge Integration Library
Jump to: navigation, search

Download Source File


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

public class Scenario12 {

  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);
    //Login
    Session session  = Session.login(2000"welcome", config);
    //Find customer account
    CustomerAccount customerAccount  = session.loadCustomerAccount("java.ca-2");
    //Create credit invoice
    RevenueTransaction creditInvoice  = customerAccount.createCredit();
    creditInvoice.setCode("java.rt-12");
    creditInvoice.setAmount(1500);
    //Create credit payment
    AssetTransaction creditPayment  = customerAccount.createRefund();
    creditPayment.setCode("java.at-12");
    creditPayment.setAmount(1500);
    creditPayment.setAccountNumber("4111111111111111");
    creditPayment.setAccessory("1209");
    creditPayment.setTransactionType(AssetTransactionType.Visa);
    //Add processing specific info (for better qualification rates)
    CaptureInfo captureInfo  = creditPayment.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;    }
    //Logout
    session.logout();

  }

}


Download Source File

Personal tools
Namespaces

Variants
Actions
Integration Info
Library Documentation
Toolbox