From Intrannuity
Download Source File
<?php
require_once "lib/iBilling.php";
//Set up clients' settings
$config = new HashMap();
$config->put(SessionConnection::PROCESSOR_HOST, "http://server.ibillingclient.org/ibilling/xmlhttps");
$config->put("debug", true);
//Login
$session = Session::login(2000, "welcome", $config);
//execute find payment plan
$paymentPlan = $session->loadPaymentPlan("php.pp-3");
$charge = $paymentPlan->getCharges()->get(1);
$charge->setIsPrepaid(true);
//get customer account
$customerAccount = $paymentPlan->getCustomerAccount();
//Create payment for downpayment
$transaction = $customerAccount->createAssetTransaction();
//code is optinal; if you specify the value, make sure the code is unique
$transaction->setCode("php.at-5");
//all amounts are in cents
$transaction->setAmount(3000);
//Type of transaction
$transaction->setAccountActivityType(AccountActivityType::Payment);
$transaction->setTransactionType(AssetTransactionType::Check);
//check number
$transaction->setAccountNumber("10100125687");
$transaction->setIsPrepayment(true);
$transaction->setDueDate($charge->getBillingDate());
//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
print($ex->getMessage());
return ;
}
//Logout
$session->logout();
?>