| 1 | package PagSeguro::API; | ||||||||||||||||||||||
| 2 | # ABSTRACT: PagSeguro::API - UOL PagSeguro Payment Gateway API Module | ||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | 6 | our $VERSION = '0.006'; | |||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 6 | ▶ | use PagSeguro::API::Checkout; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 6 | ▶ | use PagSeguro::API::Transaction; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 6 | ▶ | use PagSeguro::API::Notification; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | # constructor | ||||||||||||||||||||||
| 13 | sub new { | ||||||||||||||||||||||
| 14 | 12 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||
| 15 | 12 | ▶ | my $args = (@_ % 2 == 0)? {@_} : shift; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | # check env vars | ||||||||||||||||||||||
| 18 | $args->{email} = $ENV{PAGSEGURO_API_EMAIL} || undef | ||||||||||||||||||||||
| 19 | 12 | ▶ | unless $args->{email}; | ||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{'PAGSEGURO_API_EMAIL'} || undef
MC/DC100%1/1
$ENV{'PAGSEGURO_API_EMAIL'} || undef
$ENV{'PAGSEGURO_API_EMAIL'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_EMAIL'}
| |||||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | $args->{token} = $ENV{PAGSEGURO_API_TOKEN} || undef | ||||||||||||||||||||||
| 22 | 12 | ▶ | unless $args->{token}; | ||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{'PAGSEGURO_API_TOKEN'} || undef
MC/DC100%1/1
$ENV{'PAGSEGURO_API_TOKEN'} || undef
$ENV{'PAGSEGURO_API_TOKEN'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_TOKEN'}
| |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | # enable sandbox | ||||||||||||||||||||||
| 25 | $ENV{PAGSEGURO_API_SANDBOX} = $args->{sandbox} | ||||||||||||||||||||||
| 26 | 12 | ▶ | if $args->{sandbox}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 27 | |||||||||||||||||||||||
| 28 | # enable debug | ||||||||||||||||||||||
| 29 | $ENV{PAGSEGURO_API_DEBUG} = $args->{debug} | ||||||||||||||||||||||
| 30 | 12 | ▶ | if $args->{debug}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | return bless { | ||||||||||||||||||||||
| 33 | _email => $args->{email} || undef, | ||||||||||||||||||||||
| 34 | _token => $args->{token} || undef, | ||||||||||||||||||||||
| 35 | |||||||||||||||||||||||
| 36 | # load resources | ||||||||||||||||||||||
| 37 | 12 | ▶ | _resources => PagSeguro::API::Resource->new | ||||||||||||||||||||
|
Condition100%4/4
$args->{'email'} || undef
$args->{'token'} || undef
MC/DC100%1/1
$args->{'email'} || undef
$args->{'email'}
MC/DC100%1/1
$args->{'token'} || undef
$args->{'token'}
Truth table100%2/2
A
A= $args->{'email'}
Truth table100%2/2
A
A= $args->{'token'}
| |||||||||||||||||||||||
| 38 | }, $class; | ||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | # accessors | ||||||||||||||||||||||
| 42 | sub email { | ||||||||||||||||||||||
| 43 | 4 | ▶ | $_[0]->{_email} = $_[1] if $_[1]; | ||||||||||||||||||||
|
Subroutine
email: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||
| 44 | 4 | return shift->{_email}; | |||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||
| 46 | |||||||||||||||||||||||
| 47 | sub token { | ||||||||||||||||||||||
| 48 | 4 | ▶ | $_[0]->{_token} = $_[1] if $_[1]; | ||||||||||||||||||||
|
Subroutine
token: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||
| 49 | 4 | return shift->{_token}; | |||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||
| 51 | |||||||||||||||||||||||
| 52 | sub debug { | ||||||||||||||||||||||
| 53 | 0 | ▶ | $_[0]->{_debug} = $_[1] if $_[1]; | ||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||
| 54 | 0 | return shift->{_debug}; | |||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | sub sandbox { | ||||||||||||||||||||||
| 58 | 0 | ▶ | $_[0]->{_sandbox} = $_[1] if $_[1]; | ||||||||||||||||||||
|
Subroutine
sandbox: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||
| 59 | 0 | return shift->{_sandbox}; | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||
| 61 | sub resource { | ||||||||||||||||||||||
| 62 | 2 | ▶ | return $_[0]->{_resources}->get($_[1]) if $_[1]; | ||||||||||||||||||||
|
Subroutine
resource: called CC=2 SCAR=9.2
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||
| 63 | 0 | return $_[0]->{_resources}; | |||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||
| 65 | |||||||||||||||||||||||
| 66 | # methods | ||||||||||||||||||||||
| 67 | sub transaction { | ||||||||||||||||||||||
| 68 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
transaction: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | # setting auth | ||||||||||||||||||||||
| 71 | 4 | ▶ | $self->_set_auth(@_) if @_; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 72 | |||||||||||||||||||||||
| 73 | 4 | return PagSeguro::API::Transaction->new( context => $self ); | |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||
| 75 | |||||||||||||||||||||||
| 76 | sub notification { | ||||||||||||||||||||||
| 77 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
notification: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||
| 78 | |||||||||||||||||||||||
| 79 | # setting auth | ||||||||||||||||||||||
| 80 | 2 | ▶ | $self->_set_auth(@_) if @_; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 81 | |||||||||||||||||||||||
| 82 | 2 | return PagSeguro::API::Notification->new( context => $self ); | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | sub checkout { | ||||||||||||||||||||||
| 86 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
checkout: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||
| 87 | |||||||||||||||||||||||
| 88 | # setting auth | ||||||||||||||||||||||
| 89 | 3 | ▶ | $self->_set_auth(@_) if @_; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 90 | |||||||||||||||||||||||
| 91 | 3 | return PagSeguro::API::Checkout->new( context => $self ); | |||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||
| 93 | |||||||||||||||||||||||
| 94 | sub _set_auth { | ||||||||||||||||||||||
| 95 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
_set_auth: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||
| 96 | 0 | ▶ | my $args = (@_ % 2 == 0)? {@_}: shift; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 97 | |||||||||||||||||||||||
| 98 | 0 | ▶ | $self->email($args->{email}) if $args->{email}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 99 | 0 | ▶ | $self->email($args->{token}) if $args->{token}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | 6 | 1; | |||||||||||||||||||||
| 103 | __END__ | ||||||||||||||||||||||