File Coverage

blib/lib/Business/CyberSource/Response.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Business::CyberSource::Response;
2 3     3   1764 use strict;
  3         4  
  3         80  
3 3     3   9 use warnings;
  3         4  
  3         77  
4 3     3   1224 use namespace::autoclean;
  3         31169  
  3         12  
5 3     3   1338 use Module::Load 'load';
  3         2130  
  3         14  
6              
7             our $VERSION = '0.010007'; # VERSION
8              
9 3     3   1449 use Moose;
  3         839319  
  3         16  
10             extends 'Business::CyberSource::Message';
11             with qw(
12             Business::CyberSource::Response::Role::Base
13             );
14              
15 3         20 use MooseX::Types::CyberSource qw(
16             ResPurchaseTotals
17             AuthReply
18             Reply
19             TaxReply
20             DCCReply
21 3     3   15103 );
  3         11  
22              
23             has '+reference_code' => ( required => 0 );
24              
25             has purchase_totals => (
26             isa => ResPurchaseTotals,
27             remote_name => 'purchaseTotals',
28             is => 'ro',
29             predicate => 'has_purchase_totals',
30             coerce => 1,
31             handles => [ qw( currency ) ],
32             );
33              
34              
35             has auth => (
36             isa => AuthReply,
37             remote_name => 'ccAuthReply',
38             is => 'ro',
39             predicate => 'has_auth',
40             coerce => 1,
41             );
42              
43             has capture => (
44             isa => Reply,
45             remote_name => 'ccCaptureReply',
46             is => 'ro',
47             predicate => 'has_capture',
48             coerce => 1,
49             );
50              
51             has credit => (
52             isa => Reply,
53             remote_name => 'ccCreditReply',
54             is => 'ro',
55             predicate => 'has_credit',
56             coerce => 1,
57             );
58              
59             has auth_reversal=> (
60             isa => Reply,
61             remote_name => 'ccAuthReversalReply',
62             is => 'ro',
63             predicate => 'has_auth_reversal',
64             coerce => 1,
65             );
66              
67             has dcc => (
68             isa => DCCReply,
69             remote_name => 'ccDCCReply',
70             is => 'ro',
71             predicate => 'has_dcc',
72             coerce => 1,
73             );
74              
75             has tax => (
76             isa => TaxReply,
77             remote_name => 'taxReply',
78             is => 'ro',
79             predicate => 'has_tax',
80             coerce => 1,
81             );
82              
83             __PACKAGE__->meta->make_immutable;
84             1;
85              
86             # ABSTRACT: Response Object
87              
88             __END__
89              
90             =pod
91              
92             =encoding UTF-8
93              
94             =head1 NAME
95              
96             Business::CyberSource::Response - Response Object
97              
98             =head1 VERSION
99              
100             version 0.010007
101              
102             =head1 SYNOPSIS
103              
104             use Try::Tiny;
105              
106             my $response
107             = try {
108             $client->run_transaction( $request )
109             }
110             catch {
111             if ( blessed $_
112             && $_->isa('Business::CyberSource::Response::Exception')
113             ) {
114             if ( $_->is_error ) {
115             # probably a temporary error on cybersources problem retry
116             }
117             }
118             else {
119             # log it and investigate
120             }
121             };
122              
123             if ( $response->is_accept ) {
124             if ( $response->has_auth ) {
125             # pass to next request or store
126             $response->request_id;
127             $response->reference_code;
128             }
129             }
130             elsif ( $response->is_reject ) {
131             # log it
132             $response->request_id;
133             $response->reason_text;
134             }
135             else {
136             # throw exception
137             }
138              
139             =head1 DESCRIPTION
140              
141             This response can be used to determine the success of a transaction,
142             as well as receive a follow up C<request_id> in case you need to do further
143             actions with this.
144              
145             =head1 EXTENDS
146              
147             L<Business::CyberSource::Message>
148              
149             =head1 WITH
150              
151             =over
152              
153             =item L<Business::CyberSource::Role::RequestID>
154              
155             =back
156              
157             =head1 ATTRIBUTES
158              
159             =head2 is_accept
160              
161             boolean way of determining whether the transaction was accepted
162              
163             =head2 is_reject
164              
165             boolean way of determining whether the transaction was rejected
166              
167             =head2 is_error
168              
169             boolean way of determining whether the transaction was error. Note this is used
170             internally as a response that is an error will throw an exception.
171              
172             =head2 decision
173              
174             Summarizes the result of the overall request. This is the text, you can check
175             L<is_accept|/"is_accept">, L<is_reject|/"is_reject"> for a more boolean way.
176              
177             =head2 reason_code
178              
179             Numeric value corresponding to the result of the credit card authorization
180             request.
181              
182             =head2 reason_text
183              
184             official description of returned reason code.
185              
186             I<warning:> reason codes are returned by CyberSource and occasionally do not
187             reflect the real reason for the error please inspect the
188             L<trace|Business::Cybersource::Message/"trace"> request/response for issues
189              
190             =head2 request_token
191              
192             Request token data created by CyberSource for each reply. The field is an
193             encoded string that contains no confidential information, such as an account
194             or card verification number. The string can contain up to 256 characters.
195              
196             =head2 reference_code
197              
198             B<Type:> Varying character 50
199              
200             The merchant reference code originally sent
201              
202             =head2 auth
203              
204             $response->auth if $response->has_auth;
205              
206             B<Type:> L<Business::CyberSource::ResponsePart::AuthReply>
207              
208             =head2 purchase_totals
209              
210             $response->purchase_totals if $response->has_purchase_totals;
211              
212             B<Type:> L<Business::CyberSource::ResponsePart::PurchaseTotals>
213              
214             =head2 capture
215              
216             $response->capture if $response->has_capture;
217              
218             B<Type:> L<Business::CyberSource::ResponsePart::Reply>
219              
220             =head2 credit
221              
222             $response->credit if $response->has_credit;
223              
224             B<Type:> L<Business::CyberSource::ResponsePart::Reply>
225              
226             =head2 auth_reversal
227              
228             $response->auth_reversal if $response->has_auth_reversal;
229              
230             B<Type:> L<Business::CyberSource::ResponsePart::Reply>
231              
232             =head2 dcc
233              
234             $response->dcc if $response->has_dcc;
235              
236             B<Type:> L<Business::CyberSource::ResponsePart::DCCReply>
237              
238             =head2 tax
239              
240             $response->tax if $response->has_tax;
241              
242             B<Type:> L<Business::CyberSource::ResponsePart::TaxReply>
243              
244             =for test_synopsis my ( $request, $client );
245              
246             =head1 BUGS
247              
248             Please report any bugs or feature requests on the bugtracker website
249             https://github.com/xenoterracide/business-cybersource/issues
250              
251             When submitting a bug or request, please include a test-file or a
252             patch to an existing test-file that illustrates the bug or desired
253             feature.
254              
255             =head1 AUTHOR
256              
257             Caleb Cushing <xenoterracide@gmail.com>
258              
259             =head1 COPYRIGHT AND LICENSE
260              
261             This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>.
262              
263             This is free software, licensed under:
264              
265             The Artistic License 2.0 (GPL Compatible)
266              
267             =cut