Finance-Bank-ID-Mandiri

 view release on metacpan or  search on metacpan

lib/Finance/Bank/ID/Mandiri.pm  view on Meta::CPAN


=head1 VERSION

This document describes version 0.383 of Finance::Bank::ID::Mandiri (from Perl distribution Finance-Bank-ID-Mandiri), released on 2021-08-26.

=head1 SYNOPSIS

If you just want to download banking statements, and you use Linux/Unix, you
might want to use the L<download-mandiri> script instead of having to deal with
this library directly.

If you want to use the library in your Perl application:

    use Finance::Bank::ID::Mandiri;

    # FBI::Mandiri uses Log::ger. to show logs, use something like:
    use Log::ger::Output 'Screen';

    my $ibank = Finance::Bank::ID::Mandiri->new(
        username => '....', # optional if you're only using parse_statement()
        password => '....', # idem
        verify_https => 1,          # default is 0
        #https_ca_dir => '/etc/ssl/certs', # default is already /etc/ssl/certs
    );

    eval {
        $ibank->login(); # dies on error

        my $accts = $ibank->list_accounts();

        my $bal = $ibank->check_balance($acct); # $acct is optional

        my $stmt = $ibank->get_statement(
            account    => ..., # opt, default account used if not undef
            days       => 30,  # opt
            start_date => DateTime->new(year=>2009, month=>10, day=>6),
                               # opt, takes precedence over 'days'
            end_date   => DateTime->today, # opt, takes precedence over 'days'
        );

        print "Transactions: ";
        for my $tx (@{ $stmt->{transactions} }) {
            print "$tx->{date} $tx->{amount} $tx->{description}\n";
        }
    };
    warn if $@;

    # remember to call this, otherwise you will have trouble logging in again
    # for some time
    $ibank->logout;

Utility routines:

    # parse HTML statement directly
    my $res = $ibank->parse_statement($html);

=head1 DESCRIPTION

This module provide a rudimentary interface to the web-based online banking
interface of the Indonesian B<Bank Mandiri> at https://ib.bankmandiri.co.id
(henceforth IB). You will need either L<Crypt::SSLeay> or L<IO::Socket::SSL>
installed for HTTPS support to work (and strictly L<Crypt::SSLeay> to enable
certificate verification). L<WWW::Mechanize> is required but you can supply your
own mech-like object.

Aside from the above site for invididual accounts, there are also 2 other sites
for corporate accounts: https://cms.bankmandiri.co.id/ecbanking/ (henceforth
CMS) and https://mcm.bankmandiri.co.id/ (henceforth MCM). CMS is the older
version and as of the end of Sept, 2010 has been discontinued.

This module currently can only login to IB and not CMS/MCM, but this module can
parse statement page from all 3 sites. For CMS version, only text version [copy
paste result] is currently supported and not HTML. For MCM, only semicolon
format is currently supported.

Warning: This module is neither offical nor is it tested to be 100% safe!
Because of the nature of web-robots, everything may break from one day to the
other when the underlying web interface changes.

=head1 WARNING

This warning is from Simon Cozens' C<Finance::Bank::LloydsTSB>, and seems just
as apt here.

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 ERROR HANDLING AND DEBUGGING

Most methods die() when encountering errors, so you can use eval() to trap them.

Full response headers and bodies are dumped to a separate logger. See
documentation on C<new()> below and the sample script in examples/ subdirectory
in the distribution.

=head1 ATTRIBUTES

=head1 METHODS

=head2 new(%args)

Create a new instance. %args keys:

=over

=item * username

Optional if you are just using utility methods like C<parse_statement()> and not
C<login()> etc.

=item * password

Optional if you are just using utility methods like C<parse_statement()> and not
C<login()> etc.

=item * mech

Optional. A L<WWW::Mechanize>-like object. By default this module instantiate a

lib/Finance/Bank/ID/Mandiri.pm  view on Meta::CPAN


Optional. Default is today (or some 1+ days from today if today is a
Saturday/Sunday/holiday, depending on the default value set by the site's form).

=back

=head2 parse_statement($html, %opts) => $res

Given the HTML of the account statement results page, parse it into structured
data:

 $stmt = {
    start_date     => $start_dt, # a DateTime object
    end_date       => $end_dt,   # a DateTime object
    account_holder => STRING,
    account        => STRING,    # account number
    currency       => STRING,    # 3-digit currency code
    transactions   => [
        # first transaction
        {
          date        => $dt, # a DateTime object, book date ("tanggal pembukuan")
          seq         => INT, # a number >= 1 which marks the sequence of transactions for the day
          amount      => REAL, # a real number, positive means credit (deposit), negative means debit (withdrawal)
          description => STRING,
          branch      => STRING, # 4-digit branch/ATM code, only for MCM
        },
        # second transaction
        ...
    ]
 }

Returns:

 [$status, $err_details, $stmt]

C<$status> is 200 if successful or some other 3-letter code if parsing failed.
C<$stmt> is the result (structure as above, or undef if parsing failed).

Options:

=over 4

=item * return_datetime_obj => BOOL

Default is true. If set to false, the method will return dates as strings with
this format: 'YYYY-MM-DD HH::mm::SS' (produced by DateTime->dmy . ' ' .
DateTime->hms). This is to make it easy to pass the data structure into YAML,
JSON, MySQL, etc. Nevertheless, internally DateTime objects are still used.

=back

Additional notes:

The method can also (or used to) handle copy-pasted text from the GUI browser,
but this is no longer documented or guaranteed to keep working.

=head1 FAQ

=head2 (2014) I'm getting error message: "Can't connect to ib.bankmandiri.co.id:443 at ..."

Try upgrading your IO::Socket::SSL. It stalls with IO::Socket::SSL version 1.76,
but works with newer versions (e.g. 1.989).

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/Finance-Bank-ID-Mandiri>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Finance-Bank-ID-Mandiri>.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTORS

=for stopwords Steven Haryanto (on PC)

=over 4

=item *

Steven Haryanto (on PC) <stevenharyanto@gmail.com>

=item *

Steven Haryanto <steven@masterweb.net>

=back

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.

Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your
system), you can install L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
beyond that are considered a bug and can be reported to me.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Finance-Bank-ID-Mandiri>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired



( run in 2.926 seconds using v1.01-cache-2.11-cpan-744e820c463 )