The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::CPI::Role::Account - Manage accounts in the gateway

VERSION

version 0.919

SYNOPSIS

    # build the gateway object
    my $cpi = Business::CPI->new( gateway => 'Whatever', ... );

    # get data of the account about to be created
    # instead of Reseller, it could be a client, or data from a form, etc
    my $row = $db->resultset('Reseller')->find(5324);

    # create the object in the gateway
    $cpi->create_account({
        id         => $row->id,
        first_name => $row->name,
        last_name  => $row->surname,
        email      => $row->email,
        birthdate  => $row->birthdate,
        phone      => $row->phone,
        return_url => $myapp->root_url . '/gateway_account_created',
    });

    # hardcoded data
    $cpi->create_account({
        id         => 43125,
        first_name => 'John',
        last_name  => 'Smith',
        email      => 'john@smith.com',
        birthdate  => DateTime->now->subtract(years => 25),
        phone      => '11 00001111',
        address    => {
            street     => 'Av. Paulista',
            number     => '123',
            complement => '7º andar',
            district   => 'Bairro X',
            city       => 'São Paulo',
            state      => 'SP',
            country    => 'br',
        },
        business => {
            corporate_name => 'MyCompany Ltd.',
            trading_name   => 'MyCompany',
            phone          => '11 11110000',
            address        => {
                street     => 'Alameda Santos',
                number     => '321',
                complement => '3º andar',
                district   => 'Bairro Y',
                city       => 'São Paulo',
                state      => 'SP',
                country    => 'br',
            },
        },
        return_url => 'http://mrsmith.com',
    });

DESCRIPTION

This role is used internally by the gateway to build objects representing a person's account in the gateway. In general, the end-user shouldn't have to instantiate this directly, but use the helper methods in the gateway main class. See the "SYNOPSIS" for an example, and be sure to check the gateway driver documentation for specific details and examples.

ATTRIBUTES

id

The id of the person who owns this account (or will own it, if it's being created) in the database of the application using Business::CPI. This is irrelevant for the gateway, but they store it for an easy way for the application to associate the gateway accounts to the application records.

gateway_id

The code that uniquely identifies this account in the gateway side.

full_name

Individual's full name. We have both full_name, and first_name and last_name because some gateways use the former, and some the latter. The application might set both the separate attributes (first and last) and the single one (full), and let the driver decide what to use. Or, the application might ignore this field, and let Business::CPI concatenate first and last names to generate the full_name.

first_name

Individual's first name.

last_name

Individual's last name.

login

Login of the individual in the gateway.

email

E-mail address of the individual.

phone

Phone number of the individual. You can use + sign to set the country code, and you can set the area code if you want. You may use non-alphanumerical characters, such as parenthesis or spaces, but they will be removed. You cannot use letters.

Examples of valid numbers: "+55 11 98123-4567", "11 98123-4567", "98123-4567".

birthdate

The date the person was born. Must be a DateTime object.

registration_date

The date the account was created. Must be a DateTime object.

is_business_account

Boolean attribute to set whether the account represents an individual person or a company.

address

See Business::CPI::Role::Account::Address. You should provide a HashRef with the attributes, according to the Address role, and it will be inflated for you.

business

See Business::CPI::Role::Account::Business. You should provide a HashRef with the attributes, according to the Business class, and it will be inflated for you.

return_url

The URL the user will be redirected when the account is created.

SPONSORED BY

Estante Virtual - http://www.estantevirtual.com.br

SEE ALSO

Business::CPI, Business::CPI::Role::Account::Address, Business::CPI::Role::Account::Business, Business::CPI::Role::Buyer

AUTHOR

André Walker <andre@andrewalker.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by André Walker.

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