Finance-Bank-BNPParibas
view release on metacpan or search on metacpan
lib/Finance/Bank/BNPParibas.pm view on Meta::CPAN
package Finance::Bank::BNPParibas;
use strict;
use Carp qw(carp croak);
use WWW::Mechanize;
#use LWP::Debug qw(+);
use vars qw($VERSION);
$VERSION = 0.09;
use constant BASE_URL => 'https://www.secure.bnpparibas.net/controller?type=homeconnex';
use constant LOGIN_FORM_NAME => 'logincanalnet';
=pod
=head1 NAME
Finance::Bank::BNPParibas - Check your BNP bank accounts from Perl
=head1 SYNOPSIS
use Finance::Bank::BNPParibas;
my @accounts = Finance::Bank::BNPParibas->check_balance(
username => "$username", # Be sure to put the numbers
password => "$password", # between quote.
);
foreach my $account ( @accounts ){
local $\ = "\n";
print " Name ", $account->name;
print " Account_no ", $account->account_no;
print " Balance ", $account->balance;
print " Statement\n";
foreach my $statement ( $account->statements ){
print $statement->as_string;
}
}
=head1 DESCRIPTION
This module provides a rudimentary interface to the BNPNet online
banking system at L<https://www.bnpnet.bnp.fr/>. You will need
either Crypt::SSLeay or IO::Socket::SSL installed for HTTPS support
to work with LWP.
The interface of this module is directly taken from Simon Cozens'
Finance::Bank::LloydsTSB.
=head1 WARNING
This is code for B<online banking>, and that means B<your money>, and
that means B<BE CAREFUL>. You are encouraged, nay, expected, to audit
the source of this module yourself to reassure yourself that I am not
doing anything untoward with your banking data. This software is useful
to me, but is provided under B<NO GUARANTEE>, explicit or implied.
=head1 METHODS
=head2 check_balance( username => $username, password => $password, ua => $ua )
Return a list of account (F::B::B::Account) objects, one for each of
your bank accounts. You can provide to this method a WWW::Mechanize
object as third argument.
=cut
sub check_balance {
my ( $class, %opts ) = @_;
croak "Must provide a password" unless exists $opts{password};
croak "Must provide a username" unless exists $opts{username};
my @accounts;
$opts{ua} ||= WWW::Mechanize->new(
agent => "Finance::Bank::BNPParibas/$VERSION ($^O)",
cookie_jar => {},
);
my $self = bless {%opts}, $class;
my $orig_r;
my $count = 0;
{
$orig_r = $self->{ua}->get(BASE_URL);
# loop detected, try again
++$count;
redo unless $orig_r->content || $count > 13;
}
croak $orig_r->error_as_HTML if $orig_r->is_error;
# As of 2005-04-19, BNP changed their default login form to a fancy
# imagemap to compose the password, thankfully, they still provide
# access to the old login form:
$self->{ua}->follow_link( url_regex => qr/identifiant=secure_bnpparibas_net/ );
# Check if the login form is in the page.
$self->{ua}->quiet(1);
$self->{ua}->form_name(LOGIN_FORM_NAME)
or croak "Cannot find the login form '" . LOGIN_FORM_NAME . "'";
$self->{ua}->set_fields(
login => $self->{username},
( run in 1.644 second using v1.01-cache-2.11-cpan-22024b96cdf )