The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

BankDetails::India - Perl interface to access the ifsc.razorpay.com webservice.

VERSION

Version 1.0

SYNOPSIS

  use BankDetails::India;

  my $api = BankDetails::India->new();
  $api->get_all_data_by_ifsc('KKBK0005652');

DESCRIPTION

BankDetails::India is a module that provides methods to fetch details of Indian banks using their IFSC codes. It uses the Razorpay API to retrieve the bank details.

METHODS

new([%$args])

Construct a new BankDetails::India instance. Optionally takes a hash or hash reference.

    # Instantiate the class.
    my $api = BankDetails::India->new();

api_url

The URL of the API resource is read only attribute.

    # get the API endpoint.
    $api->api_url;

cache_data

The cache engine used to cache the web service API calls. By default, it uses file-based caching.

    # Instantiate the class by setting the cache engine.
    my $api = BankDetails::India->new(
        CHI->new(
            driver => 'File',
            namespace => 'bankdetails',
            root_dir => '/tmp/cache/'
        )
    );

    # Set through method.
    $api->cache_data(CHI->new(
        driver => 'File',
        namespace => 'bankdetails',
        root_dir => '/tmp/cache/'
    ));

    # get cache engine.
    $api->cache_data

ping_api()

Checks whether the API endpoint is currently up.

    # Returns 1 if up or 0 if not.
    $api->ping_api();

get_all_data_by_ifsc

Fetches all the available bank details for the given IFSC code.

    my $data = $bank_details->get_all_data_by_ifsc($ifsc_code);

Arguments

  • $ifsc_code (String, required) - The Indian Financial System Code (IFSC) of the bank branch.

Returns

Returns a hashref containing various details related to the bank branch.

Data Structure

The returned hashref has the following structure:

    {
        IFSC => "SBIN0000123",
        BANK => "State Bank of India",
        ADDRESS => "Main Branch, Mumbai",
        CONTACT => "022-12345678",
        STATE => "Maharashtra",
        DISTRICT => "Mumbai",
        CITY => "Mumbai",
        MICR => "400002007",
        IMPS => 1,
        NEFT => 1,
        RTGS => 1,
    }

get_bank_name_by_ifsc($ifsc_code)

Get the name of the bank based on the provided IFSC code.

    $api->get_bank_name_by_ifsc('KKBK0005652');

get_address_by_ifsc($ifsc_code)

Get the address of the bank based on the provided IFSC code.

    $api->get_address_by_ifsc('KKBK0005652');

get_contact_by_ifsc($ifsc_code)

Get the contact number of the bank based on the provided IFSC code.

    $api->get_contact_by_ifsc('KKBK0005652');

get_state_by_ifsc($ifsc_code)

Get the state of the bank based on the provided IFSC code.

    $api->get_state_by_ifsc('KKBK0005652');

get_district_by_ifsc($ifsc_code)

Get the district of the bank based on the provided IFSC code.

    $api->get_district_by_ifsc('KKBK0005652');

get_city_by_ifsc($ifsc_code)

Get the city of the bank based on the provided IFSC code.

    $api->get_city_by_ifsc('KKBK0005652');

get_rtgs_value($ifsc_code)

Checks whether the RTGS service is enabled or not for the input IFSC.

    # Returns 1 if RTGS service is enabled or 0 if not.
    $api->get_rtgs_value('KKBK0005652');

get_imps_value($ifsc_code)

Checks whether the IMPS service is enabled or not for the input IFSC.

    # Returns 1 if IMPS service is enabled or 0 if not.
    $api->get_imps_value('KKBK0005652');

get_neft_value($ifsc_code)

Checks whether the NEFT service is enabled or not for the input IFSC.

    # Returns 1 if NEFT service is enabled or 0 if not.
    $api->get_neft_value('KKBK0005652');

get_micr_code_by_ifsc($ifsc_code)

Gets the MICR code (9-digit code) of the bank based on the provided IFSC code.

    # Returns micr code.
    $api->get_micr_code_by_ifsc('KKBK0005652');

download_json($ifsc_code, $filename)

Download the complete BankDetails data for IFSC code as JSON file. Optional path and file name.

    $ifsc_code = 'KKBK0005652';

    # Using default path and file name.
    $api->download_json($ifsc_code);

    # Using specific path and file name.
    $filename = "/tmp/bankdetails_$ifsc_code.json";
    $api->download_json($ifsc_code, $filename);

download_xml($ifsc_code, $filename)

Download the complete BankDetails data for IFSC code as XML file. Optional path and file name.

    $ifsc_code = 'KKBK0005652';

    # Using default path and file name.
    $api->download_xml($ifsc_code);

    # Using specific path and file name.
    $filename = "/tmp/bankdetails_$ifsc_code.xml";
    $api->download_xml($ifsc_code, $filename);

AUTHOR

Rohit R Manjrekar, <manjrekarrohit76@gmail.com>

REPOSITORY

https://github.com/rmanjrekar/Webservice

LICENSE AND COPYRIGHT

MIT License

Copyright (c) 2023 Rohit R Manjrekar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.