Accounts Online
Accounts Online
User Management
Invoices & receipts
Custom Order Forms
Custom Fields
Protected Directories
Auto Accounts
API Functions
Handling Taxes
Shipping&Handling
|
Accounts Online API (rel.2.72)
The API implemented as a Perl module (file aolapi.pm).
init($configfile)
init()
Initializes API. Returns false (0) on failure, true (non 0) upon success.
$configfile must be set to full pathname to Accounts Online config file
(in most cases config.cgi residing in Accounts Online executable files directory). If omitted (or set to undef),
init() will try to locate config.cgi file in current directory.
error()
Returns plain ASCII text description of last error.
getvars()
Returns configuration variables as a hash array.
Example:
%varz = aolapi::getvars();
getaccnt($accid)
Returns account record with account id matching $accid. Always returns hash array, which is empty on failure.
Hash array fields |
id | account id |
passwd | account password |
opendate | date, the account opened (in seconds since beginning of the epoch, as per Perl time() function) |
openbalance | opening balance |
name | first name |
lname | last name |
street | street address |
city | city |
state | state |
zip | zip, postal code |
country | country |
phone | phone number |
fax | fax number |
email | email address |
bizphone | business phone number |
notes | account notes |
customN | custom field N (N is in the range 0-9) |
vat | VAT mode |
gst | Sales tax mode |
cctype | credit card type |
ccnumber | credit card number |
ccvalid | credit card expiry date |
ccname | name on card |
cczip | zip or postal code as per bank statement |
ccissue | issue number (switch/solo cards) |
Example:
$accid = $INPUT{'accid'};
$passwd = $INPUT{'passwd'};
%accnt = aolapi::getaccnt($accid);
if (!%accnt) {
print "Error: " . aolapi::error();
} elsif ($passwd ne $accnt{'passwd'}) {
print "Authentication failure";
} else {
print "Hello, $accnt{'name'} $accnt{'lname'}";
}
addaccnt(%accnt)
Creates new account using account definition passed as hash array. Returns new account id on success, undef otherwise.
See getaccnt() function for hash fields definition.
autoaccnt()
Creates new account using randomly generated account id and password. Returns new account id on success, undef otherwise.
updaccnt(%accnt)
Updates existing account using account definition passed as hash array. Returns the account id on success, undef otherwise.
See getaccnt() function for hash fields definition.
balance($id)
Returns current balance as per Account Manager view for account, specified by $id. Returns undef on errors.
balancedue($id)
Returns current balance due as per Account Manager view for account, specified by $id. Returns undef on errors.
listproducts()
Returns array of product IDs available.
getproduct($prodid)
Returns product record with product id matching $prodid. Always returns hash array, which is empty on failure.
Hash array fields |
id | product id
| description | product description |
category | product category |
setup | setup (one time) price |
maintenance | recurring (rebill) price |
billcycle | billing cycle (values: WK - weekly, BW - biweekly, MM - monthly, QQ - quarterly, SA - semiannual, AA - annual) |
billtype | product type (values: DB - receipt, N - invoice normal, P - invoice prorated) |
duein | days setup invoice is due in |
duein1 | days recurring invoice is due in |
billday | day to issue recurring invoice (as offset from beginning of billing cycle) |
notes | product notes |
dir | path to product directory |
dirurl | url of product directory |
ordurl | url of product order page |
ibillaccnt | ibill account number |
rcptrelay | path to on receipt script |
vat | VAT mode |
gst | Sales tax mode |
infourl | URL of product info page |
custom0 | Custom field #0 |
custom1 | Custom field #1 |
Example:
@prodlist = aolapi::listproducts();
if (!@prodlist) {
print "Error: " . aolapi::error();
} else {
print "<form method=\"POST\" action=\"cart.pl\">\n" .
"<input type=\"hidden\" name=\"cmd\" value=\"add\">\n" .
"<select name=\"prodid\">\n";
foreach $prodid (@prodlist) {
%pr = aolapi::getproduct($prodid);
if ($pr{'setup'} ne '*' && $pr{'setup'} ne undef) {
print "<option value=\"$prodid\">$pr{'description'}\n";
}
}
print "</select>\n" .
"<input type=\"submit\" value=\"Add to cart\">\n" .
"</form>\n";
}
vat($netprice, $accid, $prodid)
Calculates value added tax to be added to netprice for customer accid and product prodid.
gst($netprice, $accid, $prodid)
Calculates sales tax to be added to netprice for customer accid and product prodid.
listcats()
Returns array of category IDs available.
getcat($catid)
Returns category record with category id matching $catidid. Always returns hash array, which is empty on failure.
Hash array fields |
id | category id
| description | category description |
addtxn($accid, $prodid, $amount, $notes, $mmddyyyy, $duein_ref, $user, $addtax)
Posts a transaction to account $accid using product definition as per $prodid. Only $accid
and $prodid are required fields.
$amount used to set transaction amount for variable price products,
ignored otherwise. Please note, that $amount is always non negative number.
$duein_ref used to set transaction days due terms for variable due products of invoice type,
ignored otherwise. For products of receipt type this optional parameter conveys reference number/id.
$mmddyyy optional transaction date in mm/dd/yyyy format. If undefined current date will be used
$notes optional transaction notes
$user optional id of the user, which posted the transaction
$addtax if defined and non zero, applicable taxes will be added to total amount
The function returns amount posted, undef on failure.
payform($prodid, $amount, $accid)
Returns html code for payment form for account $accid using product definition as per $prodid.
Transaction amount $amount must be defined if product referenced by $prodid has variable (*)
setup price.
|