MooseX/Types/CyberSource.pm

filter: Statementstmt 78.5% 132 / 168 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 48.9% 24 / 49 Podpod n/a totaltotal 71.8% 156 / 217 CC 1 SCAR 2.7
CC
1
Cov
79%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.3
« Business/CyberSource/Response/Role/Base.pm ↑ Summary Business/CyberSource/RequestPart/Service.pm »
1 package MooseX::Types::CyberSource;
2 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 49 ▶use Module::Runtime 'use_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 49 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 49 our $VERSION = '0.010007'; # VERSION
8  
9 49 use MooseX::Types -declare => [ qw(
10 AVSResult
11 ElectronicVerificationResult
12 CardTypeCode
13 CountryCode
14 CvIndicator
15 CvResults
16 DCCIndicator
17  
18 Decision
19 CommerceIndicator
20 Items
21  
22 Item
23 Card
24 PurchaseTotals
25 Service
26 AuthService
27 AuthReversalService
28 CaptureService
29 CreditService
30 TaxService
31 BillTo
32 BusinessRules
33  
34 ResPurchaseTotals
35 AuthReply
36 TaxReply
37 DCCReply
38 Reply
39  
40 TaxReplyItems
41 TaxReplyItem
42  
43 RequestID
44  
45 ExpirationDate
46  
47 DateTimeFromW3C
48  
49 Client
50  
51 _VarcharOne
52 _VarcharSeven
53 _VarcharTen
54 _VarcharTwenty
55 _VarcharFifty
56 _VarcharSixty
57 49 ▶) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 49 ▶use MooseX::Types::Common::Numeric qw( PositiveOrZeroNum );
Subroutine BEGIN: called CC=1 SCAR=0.0
60 49 ▶use MooseX::Types::Common::String qw( NonEmptySimpleStr SimpleStr );
Subroutine BEGIN: called CC=1 SCAR=0.0
61 49 ▶use MooseX::Types::Moose qw( Int Num Str HashRef ArrayRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
62 49 ▶use MooseX::Types::Locale::Country qw( Alpha2Country Alpha3Country CountryName );
Subroutine BEGIN: called CC=1 SCAR=0.0
63 49 ▶use MooseX::Types::DateTime qw( );
Subroutine BEGIN: called CC=1 SCAR=0.0
64 49 ▶use MooseX::Types::DateTime::W3C qw( DateTimeW3C );
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 49 my $varchar_message = 'string is empty or longer than ';
67  
68 49 enum Decision, [ qw( ACCEPT REJECT ERROR REVIEW ) ];
69  
70 49 enum CommerceIndicator, [ qw(
71 aesk
72 aesk_attempted
73 install
74 install_internet
75 internet
76 js
77 js_attempted
78 moto
79 moto_cc
80 recurring
81 recurring_internet
82 retail
83 spa
84 spa_failure
85 vbv
86 vbv_attempted
87 vbv_failure
88 ) ];
89  
90 # can't find a standard on this, so I assume these are a cybersource thing
91 49 enum CardTypeCode, [ qw(
92 001
93 002
94 003
95 004
96 005
97 006
98 007
99 014
100 021
101 024
102 031
103 033
104 034
105 035
106 036
107 037
108 039
109 040
110 042
111 043
112 ) ];
113  
114 49 enum CvIndicator, [ qw( 0 1 2 9 ) ];
115  
116 49 enum CvResults, [ qw( D I M N P S U X 1 2 3 ),'' ];
117  
118 49 enum AVSResult, [ qw( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 ) ];
119  
120 49 enum ElectronicVerificationResult, [ qw( N P R S U Y 2) ];
121  
122 49 my $prefix = 'Business::CyberSource::';
123 49 my $req = $prefix . 'RequestPart::';
124 49 my $res = $prefix . 'ResponsePart::';
125  
126 49 my $itc = $req . 'Item';
127 49 my $ptc = $req . 'PurchaseTotals';
128 49 my $svc = $req . 'Service';
129 49 my $cdc = $req . 'Card';
130 49 my $btc = $req . 'BillTo';
131 49 my $brc = $req . 'BusinessRules';
132 49 my $azs = $req . 'Service::Auth';
133 49 my $ars = $req . 'Service::AuthReversal';
134 49 my $cps = $req . 'Service::Capture';
135 49 my $cds = $req . 'Service::Credit';
136 49 my $txs = $req . 'Service::Tax';
137  
138 49 my $res_pt_c = $res . 'PurchaseTotals';
139 49 my $res_ar_c = $res . 'AuthReply';
140 49 my $res_re_c = $res . 'Reply';
141 49 my $res_dc_c = $res . 'DCCReply';
142 49 my $res_tr_c = $res . 'TaxReply';
143 49 my $res_ti_c = $res . 'TaxReply::Item';
144  
145 49 my $client = 'Business::CyberSource::Client';
146  
147 49 class_type Item, { class => $itc };
148 49 class_type PurchaseTotals, { class => $ptc };
149 49 class_type Service, { class => $svc };
150 49 class_type Card, { class => $cdc };
151 49 class_type BillTo, { class => $btc };
152 49 class_type BusinessRules, { class => $brc };
153 49 class_type AuthService, { class => $azs };
154 49 class_type AuthReversalService, { class => $ars };
155 49 class_type CaptureService, { class => $cps };
156 49 class_type CreditService, { class => $cds };
157 49 class_type TaxService, { class => $txs };
158  
159 49 class_type ResPurchaseTotals, { class => $res_pt_c };
160 49 class_type AuthReply, { class => $res_ar_c };
161 49 class_type Reply, { class => $res_re_c };
162 49 class_type DCCReply, { class => $res_dc_c };
163 49 class_type TaxReply, { class => $res_tr_c };
164 49 class_type TaxReplyItem, { class => $res_ti_c };
165  
166 49 class_type Client, { class => $client };
167  
168 0 ▶coerce Item, from HashRef, via { use_module( $itc )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
169 4 ▶coerce PurchaseTotals, from HashRef, via { use_module( $ptc )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
170 0 ▶coerce Service, from HashRef, via { use_module( $svc )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
171 0 ▶coerce AuthService, from HashRef, via { use_module( $azs )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
172 1 ▶coerce AuthReversalService, from HashRef, via { use_module( $ars )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
173 1 ▶coerce CaptureService, from HashRef, via { use_module( $cps )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
174 0 ▶coerce CreditService, from HashRef, via { use_module( $cds )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
175 0 ▶coerce TaxService, from HashRef, via { use_module( $txs )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
176 2 ▶coerce Card, from HashRef, via { use_module( $cdc )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
177 0 ▶coerce BillTo, from HashRef, via { use_module( $btc )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
178 0 ▶coerce BusinessRules, from HashRef, via { use_module( $brc )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
179 2 ▶coerce ResPurchaseTotals, from HashRef, via { use_module( $res_pt_c )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
180 2 ▶coerce AuthReply, from HashRef, via { use_module( $res_ar_c )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
181 0 ▶coerce TaxReply, from HashRef, via { use_module( $res_tr_c )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
182 0 ▶coerce DCCReply, from HashRef, via { use_module( $res_dc_c )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
183 0 ▶coerce TaxReplyItem, from HashRef, via { use_module( $res_ti_c )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
184 1 ▶coerce Reply, from HashRef, via { use_module( $res_re_c )->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
185 0 ▶coerce Client, from HashRef, via { use_module( $client )->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
186  
187 49 subtype CountryCode, as Alpha2Country;
188 49 subtype ExpirationDate, as MooseX::Types::DateTime::DateTime;
189 49 subtype DateTimeFromW3C, as MooseX::Types::DateTime::DateTime;
190 49 subtype TaxReplyItems, as ArrayRef[TaxReplyItem];
191 49 subtype Items, as ArrayRef[Item];
192  
193  
194 coerce CountryCode,
195 from Alpha3Country,
196 via {
197 0 ▶ use_module('Locale::Code');
Subroutine __ANON__: not called CC=1 SCAR=6.9
198  
199 0 return uc Locale::Code::country_code2code( $_ ,
200 Locale::Code::LOCALE_CODE_ALPHA_3(),
201 Locale::Code::LOCALE_CODE_ALPHA_2(),
202 );
203 }
204 49 ;
205  
206 coerce CountryCode,
207 from CountryName,
208 via {
209 0 ▶ use_module('Locale::Code');
Subroutine __ANON__: not called CC=1 SCAR=6.9
210 0 return uc Locale::Code::country_code2code( $_ ,
211 Locale::Code::LOCALE_CODE_ALPHA_2(),
212 );
213 49 };
214  
215 49 enum DCCIndicator, [ qw( 1 2 3 ) ];
216  
217 coerce ExpirationDate,
218 from HashRef,
219 via {
220 0 ▶ return DateTime->last_day_of_month( %{ $_ } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
221 49 };
222  
223 subtype RequestID,
224 as NonEmptySimpleStr,
225 6 ▶ where { length $_ <= 29 },
Subroutine __ANON__: called CC=1 SCAR=0.0
226 0 ▶ message { $varchar_message . '29' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
227 49 ;
228  
229  
230 coerce TaxReplyItems,
231 from ArrayRef[HashRef],
232 via {
233 0 ▶ my $items = $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
234  
235 0 my @items = map { use_module( $res_ti_c )->new( $_ ) } @{ $items };
236 0 return \@items;
237 49 };
238  
239 coerce Items,
240 from ArrayRef[HashRef],
241 via {
242 0 ▶ my $items = $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
243  
244 0 my @items = map { use_module($itc)->new( $_ ) } @{ $items };
245 0 return \@items;
246 49 };
247  
248  
249 coerce DateTimeFromW3C,
250 from DateTimeW3C,
251 via {
252 3 ▶ return use_module('DateTime::Format::W3CDTF')
Subroutine __ANON__: called CC=1 SCAR=0.0
253 ->new->parse_datetime( $_ );
254 49 };
255  
256 subtype _VarcharOne,
257 as NonEmptySimpleStr,
258 0 ▶ where { length $_ <= 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
259 0 ▶ message { $varchar_message . '1' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
260 49 ;
261  
262 subtype _VarcharSeven,
263 as NonEmptySimpleStr,
264 2 ▶ where { length $_ <= 7 },
Subroutine __ANON__: called CC=1 SCAR=0.0
265 0 ▶ message { $varchar_message . '7' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
266 49 ;
267  
268 subtype _VarcharTen,
269 as SimpleStr,
270 13 ▶ where { length $_ <= 10 },
Subroutine __ANON__: called CC=1 SCAR=0.0
271 0 ▶ message { $varchar_message . '10' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
272 49 ;
273  
274 subtype _VarcharTwenty,
275 as NonEmptySimpleStr,
276 0 ▶ where { length $_ <= 20 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
277 0 ▶ message { $varchar_message . '20' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
278 49 ;
279  
280 subtype _VarcharFifty,
281 as NonEmptySimpleStr,
282 22 ▶ where { length $_ <= 50 },
Subroutine __ANON__: called CC=1 SCAR=0.0
283 0 ▶ message { $varchar_message . '50' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
284 49 ;
285  
286 subtype _VarcharSixty,
287 as NonEmptySimpleStr,
288 31 ▶ where { length $_ <= 60 },
Subroutine __ANON__: called CC=1 SCAR=0.0
289 0 ▶ message { $varchar_message . '60' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
290 49 ;
291 49 1;
292  
293 # ABSTRACT: Moose Types specific to CyberSource
294  
295 __END__
296  
297 =pod
298  
299 =encoding UTF-8
300  
301 =head1 NAME
302  
303 MooseX::Types::CyberSource - Moose Types specific to CyberSource
304  
305 =head1 VERSION
306  
307 version 0.010007
308  
309 =head1 SYNOPSIS
310  
311 {
312 package My::CyberSource::Response;
313 use Moose;
314 use MooseX::Types::CyberSource qw( Decision );
315  
316 has decision => (
317 is => 'ro',
318 isa => Decision,
319 );
320 __PACKAGE__->meta->make_immutable;
321 }
322  
323 my $response = My::CyberSource::Response->new({
324 decison => 'ACCEPT'
325 });
326  
327 =head1 DESCRIPTION
328  
329 This module provides CyberSource specific Moose Types.
330  
331 =begin Pod::Coverage
332  
333 LOCALE_CODE_ALPHA_2
334  
335 LOCALE_CODE_ALPHA_3
336  
337 =end Pod::Coverage
338  
339 =head1 TYPES
340  
341 =over
342  
343 =item * C<Client>
344  
345 L<Business::CyberSource::Client>
346  
347 =item * C<Decision>
348  
349 Base Type: C<enum>
350  
351 CyberSource Response Decision
352  
353 =item * C<CardTypeCode>
354  
355 Base Type: C<enum>
356  
357 Numeric codes that specify Card types. Codes denoted with an asterisk* are
358 automatically detected when using
359  
360 =item * C<CommerceIndicator>
361  
362 Base Type: C<enum>
363  
364 Valid strings for for use in in the commerceIndicator field.
365  
366 =item * C<CvResults>
367  
368 Base Type: C<enum>
369  
370 Single character code that defines the result of having sent a CVN. See
371 L<CyberSource's Documentation on Card Verification Results
372 |http://www.cybersource.com/support_center/support_documentation/quick_references/view.php?page_id=421>
373 for more information.
374  
375 =item * C<AVSResults>
376  
377 Base Type: C<enum>
378  
379 Single character code that defines the result of having sent a CVN. See
380 L<CyberSource's Documentation on AVS Results
381 |http://www.cybersource.com/support_center/support_documentation/quick_references/view.php?page_id=423>
382 for more information.
383  
384 =item * C<DCCIndicator>
385  
386 Base Type: C<enum>
387  
388 Single character code that defines the DCC status
389  
390 =over
391  
392 =item * C<1>
393  
394 Converted - DCC is being used.
395  
396 =item * C<2>
397  
398 Non-convertible - DCC cannot be used.
399  
400 =item * C<3>
401  
402 Declined - DCC could be used, but the customer declined it.
403  
404 =back
405  
406 =back
407  
408 =head1 BUGS
409  
410 Please report any bugs or feature requests on the bugtracker website
411 https://github.com/xenoterracide/business-cybersource/issues
412  
413 When submitting a bug or request, please include a test-file or a
414 patch to an existing test-file that illustrates the bug or desired
415 feature.
416  
417 =head1 AUTHOR
418  
419 Caleb Cushing <xenoterracide@gmail.com>
420  
421 =head1 COPYRIGHT AND LICENSE
422  
423 This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>.
424  
425 This is free software, licensed under:
426  
427 The Artistic License 2.0 (GPL Compatible)
428  
429 =cut
« Business/CyberSource/Response/Role/Base.pm ↑ Summary Business/CyberSource/RequestPart/Service.pm »