File Coverage

blib/lib/Business/CyberSource/Response/Role/Base.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition 1 3 33.3
subroutine 9 9 100.0
pod n/a
total 38 40 95.0


line stmt bran cond sub pod time code
1             package Business::CyberSource::Response::Role::Base;
2 4     4   2482 use strict;
  4         6  
  4         111  
3 4     4   13 use warnings;
  4         5  
  4         104  
4 4     4   15 use namespace::autoclean;
  4         4  
  4         26  
5              
6             our $VERSION = '0.010007'; # VERSION
7              
8 4     4   271 use Moose::Role;
  4         4  
  4         25  
9 4     4   14134 use MooseX::RemoteHelper;
  4         5641  
  4         20  
10 4     4   86344 use Moose::Util::TypeConstraints;
  4         6  
  4         29  
11 4     4   5353 use MooseX::Types::Common::String 0.001005 qw( NonEmptySimpleStr );
  4         95151  
  4         26  
12 4         23 use MooseX::Types::CyberSource qw(
13             Decision
14             RequestID
15 4     4   8100 );
  4         7  
16              
17             with 'Business::CyberSource::Role::Traceable' => {
18             -excludes => [qw( trace )]
19             },
20             qw(
21             Business::CyberSource::Response::Role::ReasonCode
22             );
23              
24             ## common
25             has request_id => (
26             isa => RequestID,
27             remote_name => 'requestID',
28             is => 'ro',
29             predicate => 'has_request_id',
30             required => 1,
31             );
32              
33             has decision => (
34             isa => Decision,
35             remote_name => 'decision',
36             is => 'ro',
37             required => 1,
38             );
39              
40             has request_token => (
41             isa => subtype( NonEmptySimpleStr, where { length $_ <= 256 }),
42             remote_name => 'requestToken',
43             required => 1,
44             is => 'ro',
45             );
46              
47             has reason_text => (
48             isa => 'Str',
49             required => 1,
50             lazy => 1,
51             is => 'ro',
52             builder => '_build_reason_text',
53             );
54              
55             has is_accept => (
56             isa => 'Bool',
57             is => 'ro',
58             lazy => 1,
59             init_arg => undef,
60             default => sub {
61             my $self = shift;
62             return $self->decision eq 'ACCEPT' ? 1 : 0;
63             },
64             );
65              
66             has is_reject => (
67             isa => 'Bool',
68             is => 'ro',
69             lazy => 1,
70             init_arg => undef,
71             default => sub {
72             my $self = shift;
73             return $self->decision eq 'REJECT' ? 1 : 0;
74             },
75             );
76              
77             has is_error => (
78             isa => 'Bool',
79             is => 'ro',
80             lazy => 1,
81             init_arg => undef,
82             default => sub {
83             my $self = shift;
84             return $self->decision eq 'ERROR' ? 1 : 0;
85             }
86             );
87              
88             sub _build_reason_text {
89 1     1   1 my ( $self, $reason_code ) = @_;
90 1   33     36 $reason_code //= $self->reason_code;
91              
92 1         46 my %reason = (
93             100 => 'Successful transaction',
94             101 => 'The request is missing one or more required fields',
95             102 => 'One or more fields in the request contains invalid data',
96             110 => 'Only a partial amount was approved',
97             150 => 'General system failure',
98             151 => 'The request was received but there was a server timeout.',
99             152 => 'The request was received, but a service did not finish '
100             . 'running in time'
101             ,
102             200 => 'The authorization request was approved by the issuing bank '
103             . 'but declined by CyberSource because it did not pass the '
104             . 'Address Verification Service (AVS) check'
105             ,
106             201 => 'The issuing bank has questions about the request. You do not '
107             . 'receive an authorization code programmatically, but you might '
108             . 'receive one verbally by calling the processor'
109             ,
110             202 => 'Expired card. You might also receive this if the expiration '
111             . 'date you provided does not match the date the issuing bank '
112             . 'has on file'
113             ,
114             203 => 'General decline of the card. No other information provided '
115             . 'by the issuing bank'
116             ,
117             204 => 'Insufficient funds in the account',
118             205 => 'Stolen or lost card',
119             207 => 'Issuing bank unavailable',
120             208 => 'Inactive card or card not authorized for card-not-present '
121             . 'transactions'
122             ,
123             209 => 'American Express Card Identification Digits (CID) did not '
124             . 'match'
125             ,
126             210 => 'The card has reached the credit limit',
127             211 => 'Invalid CVN',
128             221 => 'The customer matched an entry on the processor\'s negative '
129             . 'file'
130             ,
131             230 => 'The authorization request was approved by the issuing bank '
132             . 'but declined by CyberSource because it did not pass the CVN '
133             . 'check'
134             ,
135             231 => 'Invalid account number',
136             232 => 'The card type is not accepted by the payment processor',
137             233 => 'General decline by the processor',
138             234 => 'There is a problem with your CyberSource merchant '
139             . 'configuration'
140             ,
141             235 => 'The requested amount exceeds the originally authorized '
142             . 'amount'
143             ,
144             236 => 'Processor failure',
145             237 => 'The authorization has already been reversed',
146             238 => 'The authorization has already been captured',
147             239 => 'The requested transaction amount must match the previous '
148             . 'transaction amount'
149             ,
150             240 => 'The card type sent is invalid or does not correlate with '
151             . 'the credit card number'
152             ,
153             241 => 'The request ID is invalid',
154             242 => 'You requested a capture, but there is no corresponding, '
155             . 'unused authorization record'
156             ,
157             243 => 'The transaction has already been settled or reversed',
158             246 => 'The capture or credit is not voidable because the capture or '
159             . 'credit information has already been submitted to your '
160             . 'processor. Or, you requested a void for a type of '
161             . 'transaction that cannot be voided'
162             ,
163             247 => 'You requested a credit for a capture that was previously '
164             . 'voided'
165             ,
166             250 => 'The request was received, but there was a timeout at the '
167             . 'payment processor'
168             ,
169             600 => 'Address verification failed',
170             );
171              
172 1         35 return $reason{$reason_code};
173             }
174              
175             1;
176              
177             # ABSTRACT: common to normal and exception (ERROR) responses
178              
179             __END__
180              
181             =pod
182              
183             =encoding UTF-8
184              
185             =head1 NAME
186              
187             Business::CyberSource::Response::Role::Base - common to normal and exception (ERROR) responses
188              
189             =head1 VERSION
190              
191             version 0.010007
192              
193             =head1 BUGS
194              
195             Please report any bugs or feature requests on the bugtracker website
196             https://github.com/xenoterracide/business-cybersource/issues
197              
198             When submitting a bug or request, please include a test-file or a
199             patch to an existing test-file that illustrates the bug or desired
200             feature.
201              
202             =head1 AUTHOR
203              
204             Caleb Cushing <xenoterracide@gmail.com>
205              
206             =head1 COPYRIGHT AND LICENSE
207              
208             This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>.
209              
210             This is free software, licensed under:
211              
212             The Artistic License 2.0 (GPL Compatible)
213              
214             =cut