| 1 | package Business::TrueLayer::Payment::Method; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | Business::TrueLayer::Payment::Method - class representing a payment_method | ||||||||||||||||||||
| 6 | as used in the TrueLayer v3 API. | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | my $PaymentMethod = Business::TrueLayer::Payment::Method->new( | ||||||||||||||||||||
| 11 | name => ... | ||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 3 | ▶ | use feature qw/ signatures postderef /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 3 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 3 | ▶ | use MooseX::Aliases; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 3 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 3 | ▶ | no warnings qw/ experimental::signatures experimental::postderef /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 3 | with 'Business::TrueLayer::Types::Beneficiary'; | |||||||||||||||||||
| 26 | 3 | ▶ | use Business::TrueLayer::Provider; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =over | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =item type (Str) | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =item beneficiary | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | A L<Business::TrueLayer::Beneficiary> object. Hash refs will be coerced. | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =item provider | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | A L<Business::TrueLayer::Provider> object. Hash refs will be coerced. | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =back | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 3 | has [ qw/ type / ] => ( | |||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||
| 50 | isa => 'Str', | ||||||||||||||||||||
| 51 | required => 1, | ||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 3 | has [ qw/ mandate_id / ] => ( | |||||||||||||||||||
| 55 | is => 'ro', | ||||||||||||||||||||
| 56 | isa => 'Str', | ||||||||||||||||||||
| 57 | required => 0, | ||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | coerce 'Business::TrueLayer::Provider' | ||||||||||||||||||||
| 61 | => from 'HashRef' | ||||||||||||||||||||
| 62 | 5 | ▶ | => via { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 63 | 5 | Business::TrueLayer::Provider->new( %{ $_ } ); | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | 3 | ; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 3 | has provider => ( | |||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||
| 69 | isa => 'Business::TrueLayer::Provider', | ||||||||||||||||||||
| 70 | coerce => 1, | ||||||||||||||||||||
| 71 | required => 0, | ||||||||||||||||||||
| 72 | alias => 'provider_selection', | ||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 3 | has beneficiary => ( | |||||||||||||||||||
| 76 | is => 'ro', | ||||||||||||||||||||
| 77 | isa => 'Business::TrueLayer::Beneficiary', | ||||||||||||||||||||
| 78 | coerce => 1, | ||||||||||||||||||||
| 79 | required => 0, | ||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 6 | ▶ | sub BUILD { | ||||||||||||||||||
|
Subroutine
BUILD: called CC=6 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||
| 83 | 6 | my ( $self ) = @_; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | # the type defines the requirement for some of the | ||||||||||||||||||||
| 86 | # attributes of this object | ||||||||||||||||||||
| 87 | 6 | ▶ | if ( $self->is_bank_transfer ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 88 | 5 | ▶ | $self->beneficiary || die "payment_method of type 'bank_transfer'" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 89 | . " requires a beneficiary"; | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 5 | ▶ | $self->provider || die "payment_method of type 'bank_transfer'" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | . " requires a provider / provider_selection"; | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | } elsif ( $self->is_mandate ) { | ||||||||||||||||||||
| 95 | 1 | ▶ | $self->mandate_id || die "payment_method of type 'mandate'" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 96 | . " requires a mandate_id"; | ||||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =head1 METHODS | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =head2 is_bank_transfer | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head2 is_mandate | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | Check if the payment method is a particular type | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | if ( $PaymentMethod->is_bank_transfer ) { | ||||||||||||||||||||
| 109 | ... | ||||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 6 | ▶ | sub is_bank_transfer { shift->_is_type( 'bank_transfer' ); } | ||||||||||||||||||
|
Subroutine
is_bank_transfer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 115 | 1 | ▶ | sub is_mandate { shift->_is_type( 'mandate' ); } | ||||||||||||||||||
|
Subroutine
is_mandate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 7 | ▶ | sub _is_type ( $self,$type ) { | ||||||||||||||||||
|
Subroutine
_is_type: called CC=3 SCAR=11.2
| |||||||||||||||||||||
| 118 | 7 | ▶ | return ( $self->type // '' ) eq $type ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->type // ""
MC/DC0%0/1
$self->type // ""
$self->type
Truth table50%1/2
A
A= $self->type
| |||||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 SEE ALSO | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | L<Business::TrueLayer::Beneficiary> | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | L<Business::TrueLayer::Provider> | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 3 | 1; | |||||||||||||||||||