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);
//Find customer account
$customerAccount = $session->loadCustomerAccount("php.ca-2");
//Create invoice1
$invoice1 = $customerAccount->createRevenueTransaction();
//code is optinal; if you specify the value, make sure the code is unique
$invoice1->setCode("php.rt-9-1");
//all amounts are in cents
$invoice1->setAmount(2000);
//Item Codes must be setup in portal prior to being used
$invoice1->setItemCode("T-Shirt");
//Type of transaction
$invoice1->setAccountActivityType(AccountActivityType::Invoice);
//Create payment1
$payment1 = $customerAccount->createAssetTransaction();
//code is optinal; if you specify the value, make sure the code is unique
$payment1->setCode("php.at-9-1");
//all amounts are in cents
$payment1->setAmount(2000);
$payment1->setTransactionType(AssetTransactionType::Visa);
$payment1->setAccountActivityType(AccountActivityType::Payment);
//Credit card number to charge
$payment1->setAccountNumber("4111111111111111");
//Credit card expiration date
$payment1->setAccessory("1209");
//Add processing specific info (for better qualification rates)
$captureInfo1 = $payment1->getCaptureInfo();
$captureInfo1->setHolderName("John Smith");
$captureInfo1->setCity("Columbus");
$captureInfo1->setState("CA");
$captureInfo1->setStreet("233 12th Street");
$captureInfo1->setZipCode("31909");
$captureInfo1->setPhone("2129856472");
$captureInfo1->setEmail("test@yahoo.com");
$captureInfo1->setCvv2("999");
//Create invoice2
$invoice2 = $customerAccount->createRevenueTransaction();
//code is optinal; if you specify the value, make sure the code is unique
$invoice2->setCode("php.rt-9-2");
//all amounts are in cents
$invoice2->setAmount(1500);
//Item Codes must be setup in portal prior to being used
$invoice2->setItemCode("T-Shirt");
//Type of transaction
$invoice2->setAccountActivityType(AccountActivityType::Invoice);
//Create payment2
$payment2 = $customerAccount->createAssetTransaction();
//code is optinal; if you specify the value, make sure the code is unique
$payment2->setCode("php.at-9-2");
///all amounts are in cents
$payment2->setAmount(1500);
$payment2->setTransactionType(AssetTransactionType::Visa);
$payment2->setAccountActivityType(AccountActivityType::Payment);
//Credit card number to charge
$payment2->setAccountNumber("4111111111111111");
//Credit card expiration date
$payment2->setAccessory("1209");
//Add processing specific info (for better qualification rates)
$captureInfo2 = $payment2->getCaptureInfo();
$captureInfo2->setHolderName("John Smith");
$captureInfo2->setCity("Columbus");
$captureInfo2->setState("CA");
$captureInfo2->setStreet("233 12th Street");
$captureInfo2->setZipCode("31909");
$captureInfo2->setPhone("2129856472");
$captureInfo2->setEmail("test@yahoo.com");
$captureInfo2->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
print($ex->getMessage());
return ;
}
//Logout
$session->logout();
?>