NAME
Finance::Bank::Commonwealth - Front-end module to netbank.com.au
SYNOPSIS
use Finance::Bank::Commonwealth();
my ($bank) = new Finance::Bank::Commonwealth({
'login' => 'xxxx',
'password' => 'yyy'
});
my ($from);
print "----------------------\n";
foreach $account ($bank->accounts()) {
print "Account Id: ". $account->id() . "\n";
print "Account Code: ". $account->code() . "\n";
print "Account BSB: " . $account->bsb() . "\n";
print "Account Number: " . $account->number() . "\n";
print "Account Name: " . $account->name() . "\n";
print "Account Type: " . $account->type() . "\n";
print "Account Balance: " . $account->balance() . "\n";
print "Available Funds: " . $account->available() ."\n";
print "----------------------\n";
if ($account->type() eq 'MasterCard') {
$from = $account;
}
}
my ($to) = new Finance::Bank::Commonwealth::Account({
'bsb' => '654321',
'number' => '12345678',
'type' => 'BankAccount',
'name' => 'Bob\'s Account',
});
my ($success) = $bank->transfer($from, $to, 1.50, "Why?");
if ($success) {
print "Date:" . $success->{'date'} . "\n";
print "Time:" . $success->{'time'} . "\n";
print "Receipt Number:" . $success->{'receipt_number'} . "\n";
}
DESCRIPTION
Attention!!!! This module gets access to YOUR MONEY!!!!!! DO NOT USE IT unless you are comfortable with the notion that you could (in theory) completely bugger your accounts if the Commonwealth Bank changed their website significantly. DO NOT USE IT unless you have inspected the code and feel comfortable with it. DO NOT come crying to me if it all goes horribly wrong. This is intended as a demonstration module, NOT as a production worthy system.
*ahem* Now that i've done everything possible to ensure that this module is never used, on with the show.
This module provides an API to the Commonwealth Bank's netbank.com.au website. It translates the method calls into http(s) requests. Due to the fragile nature of this type of API (due to the probability that the EDS may attempt to change the implementation and hence break this API), this module is NOT recommended for mission critical applications. Rather, it is intended for more casual uses. It is also worth noting that if you give this module your id and password, you are letting the module do whatever it wants with YOUR MONEY!!! This means that unless you competent at Perl and can read and understand this module, you would be well advised not to use it.
Also, because if the module fails to parse anything successfully, it will throw an exception. Any section of code that uses this module should be wrapped in an eval type structure (such as Graham Barrs Error module).
PARSING NOTES
The architects working on the Commonwealth Bank's website seem to have made a number of design decisions which I will document here to make it easier to understand what the HTML is doing.
1) They decided to not use cookies, rather to use special hidden form fields (EWF_SYS_0 & EWF_SYS_1) to record session state. Also, they decided to use a dynamic URL, so that someone must track through all the pages in a sequence.
2) They decided to obfuscate using simple javascript for the most part, and html redirects and frames during the initial loads.
3) Javascript obfuscation consists of just escaping the page and placing it in a javascript string.
4) Obfuscation is usually dispensed with after the first couple of screens in a sequence.
5) Session state is often only recorded on the server, meaning that you don't actually see confirmation in the form fields of what is happening.
METHODS
new(\%params)
The new constructor instantiates a new Bank object. It attempts to log onto the netbank.com.au site using the login and password provided in the params hash
my ($bank) = new Finance::Bank::Commonwealth({
'login' => 'xxx',
'password' => 'yyy',
'user_agent' => 'Finance::Bank::Commonwealth',
});
A reference to the bank object is returned that can be used to access the instance methods for this class.
billers
The billers method returns an array of all the Finance::Bank::Commonwealth::Biller objects that are currently connected to the login.
my ($biller);
foreach $biller ($bank->billers()) {
print "Biller Id: " . $biller->id() . "\n";
print "Biller Code: " . $biller->code() . "\n";
print "Biller Name: " . $biller->name() . "\n";
print "Ref No.: " . $biller->customer_ref_no() . "\n";
}
transfer($from, $to, $amount, $comment)
The transfer method transfers money from the $from account into the $to account. The $from account MUST belong to the current login. The method will return a Finance::Bank::Commonwealth::Success object that gives the date, time and receipt number of the transfer.
my ($from);
my ($account);
foreach $account ($bank->accounts()) {
if ($account->type() eq 'MasterCard') {
$from = $account;
}
}
my ($to) = new Finance::Bank::Commonwealth::Account({
'bsb' => '654321',
'number' => '12345678',
'type' => 'BankAccount',
'name' => 'Bob\'s Account',
});
my ($success) = $bank->transfer($from, $to, 1.50, "Why this should be");
if ($success) {
print "Date:" . $success->date() . "\n";
print "Time:" . $success->time() . "\n";
print "Receipt Number:" . $success->receipt_number() . "\n";
}
accounts
The accounts method returns an array of Finance::Bank::Commonwealth::Account objects that are connected to the current login.
foreach $account ($bank->accounts()) {
print "Account Id: ". $account->id() . "\n";
print "Account Code: ". $account->code() . "\n";
print "Account BSB: " . $account->bsb() . "\n";
print "Account Number: " . $account->number() . "\n";
print "Account Name: " . $account->name() . "\n";
print "Account Type: " . $account->type() . "\n";
print "Account Balance: " . $account->balance() . "\n";
print "Available Funds: " . $account->available() ."\n";
}
transactions($account)
The transactions method returns an array of Finance::Bank::Commonwealth::Transaction objects that are connected to the $account specified. Note that this method will NOT yet return all the available transactions. It will only return the most recent transactions. This method will also check the banks accounting and make sure that all the balances actually add up. (We all trust banks :)).
my ($transaction);
print "---------------------------------------------\n";
foreach $transaction ($bank->transactions($from)) {
print "Transaction Date: " . $transaction->date() . "\n";
print "Transaction Reason: " . $transaction->reason() . "\n";
print "Transaction Amount: " . $transaction->amount() . "\n";
print "Transaction Total: " . $transaction->total() . "\n";
print "---------------------------------------------\n";
}
bpay($from, $biller, $amount)
The bpay method allows a payment of $amount to be made from the $from account to the $biller. The method will return a Finance::Bank::Commonwealth::Success object that gives the date, time and receipt number of the transfer.
$from = new Finance::Bank::Commonwealth::Account({
'bsb' => '063011',
'number' => '10127167',
'type' => 'Streamline'
});
my ($biller) = new Finance::Bank::Commonwealth::Biller({
'code' => '8789',
'ref_no' => '221019047125' });
my ($success) = $bank->bpay($from, $biller, .50);
if ($success) {
print "Date:" . $success->date() . "\n";
print "Time:" . $success->time() . "\n";
print "Receipt Number:" . $success->receipt_number() . "\n";
}
AUTHOR
David Dick (ddick@cpan.org)
VERSION
v0.98 released 15 Aug 2002
COPYRIGHT
Copyright (c) 2002 David Dick. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself