Finance-Bank-CreditMut
view release on metacpan or search on metacpan
lib/Finance/Bank/CreditMut.pm view on Meta::CPAN
package Finance::Bank::CreditMut;
use strict;
use Carp qw(carp croak);
use WWW::Mechanize;
use HTML::TableExtract;
use XML::Twig;
use vars qw($VERSION);
$VERSION = 0.14;
=pod
=encoding utf8
=head1 NAME
Finance::Bank::CreditMut - Check your Crédit Mutuel accounts from Perl
=head1 SYNOPSIS
use Finance::Bank::CreditMut;
my @accounts = Finance::Bank::CreditMut->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 " Statement\n";
foreach my $statement ( $account->statements ){
print $statement->as_string;
}
}
=head1 DESCRIPTION
This module provides a rudimentary interface to the CyberMut online banking
system at L<https://www.creditmutuel.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 Briac Pilpré's
Finance::Bank::BNPParibas.
=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::CM::Account) objects, one for each of your
bank accounts. You can provide to this method a WWW::Mechanize object as
third argument. If not, a new one will be created.
=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 => __PACKAGE__ . "/$VERSION ($^O)",
cookie_jar => {},
);
my $self = bless {%opts}, $class;
my $orig_r;
my $count = 0;
{
$orig_r = $self->{ua}->get("https://www.creditmutuel.fr/fr/authentification.html");
# loop detected, try again
++$count;
redo unless $orig_r->content || $count > 13;
}
croak $orig_r->error_as_HTML if $orig_r->is_error;
{
local $^W; # both fields_are read-only
my $click_r = $self->{ua}->submit_form(
form_id => 'bloc_ident',
fields => {
_cm_user => $self->{username},
_cm_pwd => $self->{password},
}
);
croak $click_r->error_as_HTML if $click_r->is_error;
}
my $r = $self->{ua}->get("https://www.creditmutuel.fr/fr/banque/comptes-et-contrats.html");
( run in 1.171 second using v1.01-cache-2.11-cpan-ceb78f64989 )