| 1 | package Net::Stripe::Customer; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Net::Stripe::Customer::VERSION = '0.43'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Kavorka; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Net::Stripe::Plan; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Net::Stripe::Token; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Net::Stripe::Card; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Net::Stripe::Discount; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Net::Stripe::List; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | extends 'Net::Stripe::Resource'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # ABSTRACT: represent a Customer object from Stripe | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # Customer creation args | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | has 'email' => (is => 'rw', isa => 'Maybe[Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | has 'description' => (is => 'rw', isa => 'Maybe[Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | has 'trial_end' => (is => 'rw', isa => 'Maybe[Int|Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | has 'card' => (is => 'rw', isa => 'Maybe[Net::Stripe::Token|Net::Stripe::Card|StripeTokenId]'); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | has 'source' => (is => 'rw', isa => 'Maybe[Net::Stripe::Card|StripeTokenId|StripeSourceId]'); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | has 'quantity' => (is => 'rw', isa => 'Maybe[Int]'); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | has 'plan' => (is => 'rw', isa => 'Maybe[Net::Stripe::Plan|Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | has 'coupon' => (is => 'rw', isa => 'Maybe[Net::Stripe::Coupon|Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | has 'discount' => (is => 'rw', isa => 'Maybe[Net::Stripe::Discount]'); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | has 'metadata' => (is => 'rw', isa => 'Maybe[HashRef]'); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | has 'account_balance' => (is => 'rw', isa => 'Maybe[Int]', trigger => \&_account_balance_trigger); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | has 'balance' => (is => 'rw', isa => 'Maybe[Int]', trigger => \&_balance_trigger); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | has 'default_card' => (is => 'rw', isa => 'Maybe[Net::Stripe::Token|Net::Stripe::Card|Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | has 'default_source' => (is => 'rw', isa => 'Maybe[StripeCardId|StripeSourceId]'); | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # API object args | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | has 'id' => (is => 'ro', isa => 'Maybe[Str]'); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | has 'cards' => (is => 'ro', isa => 'Net::Stripe::List'); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | has 'deleted' => (is => 'ro', isa => 'Maybe[Bool|Object]', default => 0); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | has 'sources' => (is => 'ro', isa => 'Net::Stripe::List'); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | has 'subscriptions' => (is => 'ro', isa => 'Net::Stripe::List'); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | has 'subscription' => (is => 'ro', | |||||||||||||||||||||||||||||||||||||||||
| 38 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | builder => '_build_subscription'); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub _build_subscription { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_subscription: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return $self->subscriptions->get(0); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | method _account_balance_trigger( | ||||||||||||||||||||||||||||||||||||||||||
| 47 | Maybe[Int] $new_value!, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | Maybe[Int] $old_value?, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
_account_balance_trigger: not called CC=15 SCAR=49.6
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return unless defined( $new_value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return if defined( $old_value ) && $old_value eq $new_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $old_value and $old_value eq $new_value
MC/DC0%0/2
defined $old_value and $old_value eq $new_value
defined $old_value
$old_value eq $new_value
Truth table0%0/3
A and B
A= defined $old_valueB= $old_value eq $new_value
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return if defined( $self->balance ) && $self->balance == $new_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->balance and $self->balance == $new_value
MC/DC0%0/2
defined $self->balance and $self->balance == $new_value
defined $self->balance
$self->balance == $new_value
Truth table0%0/3
A and B
A= defined $self->balanceB= $self->balance == $new_value
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->balance( $new_value ); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | method _balance_trigger( | ||||||||||||||||||||||||||||||||||||||||||
| 57 | Maybe[Int] $new_value!, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | Maybe[Int] $old_value?, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
BEGIN: called CC=1 SCAR=3.7
Subroutine
_balance_trigger: not called CC=15 SCAR=49.6
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return unless defined( $new_value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | return if defined( $old_value ) && $old_value eq $new_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $old_value and $old_value eq $new_value
MC/DC0%0/2
defined $old_value and $old_value eq $new_value
defined $old_value
$old_value eq $new_value
Truth table0%0/3
A and B
A= defined $old_valueB= $old_value eq $new_value
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return if defined( $self->account_balance ) && $self->account_balance == $new_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->account_balance and $self->account_balance == $new_value
MC/DC0%0/2
defined $self->account_balance and $self->account_balance == $new_value
defined $self->account_balance
$self->account_balance == $new_value
Truth table0%0/3
A and B
A= defined $self->account_balanceB= $self->account_balance == $new_value
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->account_balance( $new_value ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | method form_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
form_fields: called CC=5 SCAR=17.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | $self->account_balance( undef ) if | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $self->account_balance and defined $self->balance and $self->account_balance == $self->balance
defined $self->account_balance and defined $self->balance
MC/DC0%0/3
defined $self->account_balance and defined $self->balance and $self->account_balance == $self->balance
defined $self->account_balance
defined $self->balance
$self->account_balance == $self->balance
Truth table25%1/4
A and B and C
A= defined $self->account_balanceB= defined $self->balanceC= $self->account_balance == $self->balance
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | defined( $self->account_balance ) && | ||||||||||||||||||||||||||||||||||||||||||
| 69 | defined( $self->balance ) && | ||||||||||||||||||||||||||||||||||||||||||
| 70 | $self->account_balance == $self->balance; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | return $self->form_fields_for( | |||||||||||||||||||||||||||||||||||||||||
| 72 | qw/email description trial_end account_balance balance quantity card plan coupon | ||||||||||||||||||||||||||||||||||||||||||
| 73 | metadata default_card source default_source/ | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||||||||||||||||||||||||