| 1 | package Business::CyberSource::Response::Role::Base; | ||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 7 | our $VERSION = '0.010008'; # VERSION | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 7 | ▶ | use MooseX::RemoteHelper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 7 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 7 | ▶ | use MooseX::Types::Common::String 0.001005 qw( NonEmptySimpleStr ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 7 | ▶ | use MooseX::Types::CyberSource qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | Decision | ||||||||||||||||||||
| 14 | RequestID | ||||||||||||||||||||
| 15 | 7 | ); | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 7 | with 'Business::CyberSource::Role::Traceable' => { | |||||||||||||||||||
| 18 | -excludes => [qw( trace )] | ||||||||||||||||||||
| 19 | }, | ||||||||||||||||||||
| 20 | qw( | ||||||||||||||||||||
| 21 | Business::CyberSource::Response::Role::ReasonCode | ||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | ## common | ||||||||||||||||||||
| 25 | 7 | has request_id => ( | |||||||||||||||||||
| 26 | isa => RequestID, | ||||||||||||||||||||
| 27 | remote_name => 'requestID', | ||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||
| 29 | predicate => 'has_request_id', | ||||||||||||||||||||
| 30 | required => 1, | ||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 7 | has decision => ( | |||||||||||||||||||
| 34 | isa => Decision, | ||||||||||||||||||||
| 35 | remote_name => 'decision', | ||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||
| 37 | required => 1, | ||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | has request_token => ( | ||||||||||||||||||||
| 41 | 4 | ▶ | isa => subtype( NonEmptySimpleStr, where { length $_ <= 256 }), | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | remote_name => 'requestToken', | ||||||||||||||||||||
| 43 | required => 1, | ||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 7 | 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 | 1 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 61 | 1 | my $self = shift; | |||||||||||||||||||
| 62 | 1 | ▶ | return $self->decision eq 'ACCEPT' ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | }, | ||||||||||||||||||||
| 64 | 7 | ); | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | has is_reject => ( | ||||||||||||||||||||
| 67 | isa => 'Bool', | ||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||
| 69 | lazy => 1, | ||||||||||||||||||||
| 70 | init_arg => undef, | ||||||||||||||||||||
| 71 | 1 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 72 | 1 | my $self = shift; | |||||||||||||||||||
| 73 | 1 | ▶ | return $self->decision eq 'REJECT' ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||
| 75 | 7 | ); | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | has is_error => ( | ||||||||||||||||||||
| 78 | isa => 'Bool', | ||||||||||||||||||||
| 79 | is => 'ro', | ||||||||||||||||||||
| 80 | lazy => 1, | ||||||||||||||||||||
| 81 | init_arg => undef, | ||||||||||||||||||||
| 82 | 1 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 83 | 1 | my $self = shift; | |||||||||||||||||||
| 84 | 1 | ▶ | return $self->decision eq 'ERROR' ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | 7 | ); | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 1 | ▶ | sub _build_reason_text { | ||||||||||||||||||
|
Subroutine
_build_reason_text: called CC=2 SCAR=7.4
| |||||||||||||||||||||
| 89 | 1 | my ( $self, $reason_code ) = @_; | |||||||||||||||||||
| 90 | 1 | ▶ | $reason_code //= $self->reason_code; | ||||||||||||||||||
|
Condition33%1/3
$reason_code //= $self->reason_code
MC/DC0%0/2
$reason_code //= $self->reason_code
$reason_code
$self->reason_code
Truth table33%1/3
A //= B
A= $reason_codeB= $self->reason_code
| |||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 1 | 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 | return $reason{$reason_code}; | |||||||||||||||||||
| 173 | } | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | 7 | 1; | |||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | # ABSTRACT: common to normal and exception (ERROR) responses | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | __END__ | ||||||||||||||||||||