NAME

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

VERSION

version 0.905

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,
    birthday   => $row->birthday,
    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',
    birthday   => 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 class 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.

first_name

Individual's first name.

last_name

Individual's last name.

email

E-mail address of the individual.

phone

Phone number of the individual.

birthday

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

address

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

business

See Business::CPI::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.

METHODS

BUILDARGS

Used to inflate address and business keys in the constructor.

SPONSORED BY

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

SEE ALSO

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

AUTHOR

André Walker <andre@andrewalker.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 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.