| 1 | package MooseX::Types::CyberSource; | ||
| 2 | 52 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 52 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 52 | ▶ | use Module::Runtime 'use_module'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 52 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 52 | our $VERSION = '0.010008'; # VERSION | |
| 8 | |||
| 9 | 52 | ▶ | use MooseX::Types -declare => [ |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | qw( | ||
| 11 | AVSResult | ||
| 12 | ElectronicVerificationResult | ||
| 13 | CardTypeCode | ||
| 14 | CountryCode | ||
| 15 | CvIndicator | ||
| 16 | CvResults | ||
| 17 | DCCIndicator | ||
| 18 | |||
| 19 | Decision | ||
| 20 | CommerceIndicator | ||
| 21 | Items | ||
| 22 | |||
| 23 | Item | ||
| 24 | Card | ||
| 25 | PurchaseTotals | ||
| 26 | Service | ||
| 27 | AuthService | ||
| 28 | AuthReversalService | ||
| 29 | CaptureService | ||
| 30 | CreditService | ||
| 31 | TaxService | ||
| 32 | BillTo | ||
| 33 | ShipTo | ||
| 34 | BusinessRules | ||
| 35 | InvoiceHeader | ||
| 36 | OtherTax | ||
| 37 | ShipFrom | ||
| 38 | |||
| 39 | ResPurchaseTotals | ||
| 40 | AuthReply | ||
| 41 | TaxReply | ||
| 42 | DCCReply | ||
| 43 | Reply | ||
| 44 | |||
| 45 | TaxReplyItems | ||
| 46 | TaxReplyItem | ||
| 47 | |||
| 48 | RequestID | ||
| 49 | |||
| 50 | ExpirationDate | ||
| 51 | |||
| 52 | DateTimeFromW3C | ||
| 53 | |||
| 54 | Client | ||
| 55 | |||
| 56 | ShippingMethod | ||
| 57 | |||
| 58 | _VarcharOne | ||
| 59 | _VarcharSeven | ||
| 60 | _VarcharTen | ||
| 61 | _VarcharFifteen | ||
| 62 | _VarcharTwenty | ||
| 63 | _VarcharFifty | ||
| 64 | _VarcharSixty | ||
| 65 | ) | ||
| 66 | 52 | ]; | |
| 67 | |||
| 68 | use MooseX::Types::Common::Numeric | ||
| 69 | 52 | ▶ | qw( PositiveOrZeroNum ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 70 | 52 | ▶ | use MooseX::Types::Common::String qw( NonEmptySimpleStr SimpleStr ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 71 | 52 | ▶ | use MooseX::Types::Moose qw( Int Num Str HashRef ArrayRef ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 72 | use MooseX::Types::Locale::Country | ||
| 73 | 52 | ▶ | qw( Alpha2Country Alpha3Country CountryName ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 74 | 52 | ▶ | use MooseX::Types::DateTime qw( ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 75 | 52 | ▶ | use MooseX::Types::DateTime::W3C qw( DateTimeW3C ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 76 | |||
| 77 | 52 | my $varchar_message = 'string is empty or longer than '; | |
| 78 | 52 | my $num_message = 'value is non Num, empty or longer than '; | |
| 79 | |||
| 80 | 52 | enum Decision, [qw( ACCEPT REJECT ERROR REVIEW )]; | |
| 81 | |||
| 82 | 52 | enum CommerceIndicator, [ | |
| 83 | qw( | ||
| 84 | aesk | ||
| 85 | aesk_attempted | ||
| 86 | install | ||
| 87 | install_internet | ||
| 88 | internet | ||
| 89 | js | ||
| 90 | js_attempted | ||
| 91 | moto | ||
| 92 | moto_cc | ||
| 93 | recurring | ||
| 94 | recurring_internet | ||
| 95 | retail | ||
| 96 | spa | ||
| 97 | spa_failure | ||
| 98 | vbv | ||
| 99 | vbv_attempted | ||
| 100 | vbv_failure | ||
| 101 | ) | ||
| 102 | ]; | ||
| 103 | |||
| 104 | # can't find a standard on this, so I assume these are a cybersource thing | ||
| 105 | 52 | enum CardTypeCode, [ | |
| 106 | qw( | ||
| 107 | 001 | ||
| 108 | 002 | ||
| 109 | 003 | ||
| 110 | 004 | ||
| 111 | 005 | ||
| 112 | 006 | ||
| 113 | 007 | ||
| 114 | 014 | ||
| 115 | 021 | ||
| 116 | 024 | ||
| 117 | 031 | ||
| 118 | 033 | ||
| 119 | 034 | ||
| 120 | 035 | ||
| 121 | 036 | ||
| 122 | 037 | ||
| 123 | 039 | ||
| 124 | 040 | ||
| 125 | 042 | ||
| 126 | 043 | ||
| 127 | ) | ||
| 128 | ]; | ||
| 129 | |||
| 130 | 52 | enum CvIndicator, [qw( 0 1 2 9 )]; | |
| 131 | |||
| 132 | 52 | enum CvResults, [ qw( D I M N P S U X 1 2 3 ), '' ]; | |
| 133 | |||
| 134 | 52 | 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 )]; | |
| 135 | |||
| 136 | 52 | enum ElectronicVerificationResult, [qw( N P R S U Y 2)]; | |
| 137 | |||
| 138 | 52 | enum ShippingMethod, | |
| 139 | [qw(lowcost sameday oneday twoday threeday pickup other none)]; | ||
| 140 | |||
| 141 | 52 | my $prefix = 'Business::CyberSource::'; | |
| 142 | 52 | my $req = $prefix . 'RequestPart::'; | |
| 143 | 52 | my $res = $prefix . 'ResponsePart::'; | |
| 144 | |||
| 145 | 52 | my $itc = $req . 'Item'; | |
| 146 | 52 | my $ptc = $req . 'PurchaseTotals'; | |
| 147 | 52 | my $cdc = $req . 'Card'; | |
| 148 | 52 | my $btc = $req . 'BillTo'; | |
| 149 | 52 | my $stc = $req . 'ShipTo'; | |
| 150 | 52 | my $brc = $req . 'BusinessRules'; | |
| 151 | 52 | my $ihc = $req . 'InvoiceHeader'; | |
| 152 | 52 | my $otc = $req . 'OtherTax'; | |
| 153 | 52 | my $sfc = $req . 'ShipFrom'; | |
| 154 | 52 | my $svc = $req . 'Service'; | |
| 155 | |||
| 156 | 52 | my $azs = $svc . '::Auth'; | |
| 157 | 52 | my $ars = $svc . '::AuthReversal'; | |
| 158 | 52 | my $cps = $svc . '::Capture'; | |
| 159 | 52 | my $cds = $svc . '::Credit'; | |
| 160 | 52 | my $txs = $svc . '::Tax'; | |
| 161 | |||
| 162 | 52 | my $res_pt_c = $res . 'PurchaseTotals'; | |
| 163 | 52 | my $res_ar_c = $res . 'AuthReply'; | |
| 164 | 52 | my $res_re_c = $res . 'Reply'; | |
| 165 | 52 | my $res_dc_c = $res . 'DCCReply'; | |
| 166 | 52 | my $res_tr_c = $res . 'TaxReply'; | |
| 167 | 52 | my $res_ti_c = $res . 'TaxReply::Item'; | |
| 168 | |||
| 169 | 52 | my $client = 'Business::CyberSource::Client'; | |
| 170 | |||
| 171 | 52 | class_type Item, { class => $itc }; | |
| 172 | 52 | class_type PurchaseTotals, { class => $ptc }; | |
| 173 | 52 | class_type Service, { class => $svc }; | |
| 174 | 52 | class_type Card, { class => $cdc }; | |
| 175 | 52 | class_type BillTo, { class => $btc }; | |
| 176 | 52 | class_type ShipTo, { class => $stc }; | |
| 177 | 52 | class_type BusinessRules, { class => $brc }; | |
| 178 | 52 | class_type InvoiceHeader, { class => $ihc }; | |
| 179 | 52 | class_type OtherTax, { class => $otc }; | |
| 180 | 52 | class_type ShipFrom, { class => $sfc }; | |
| 181 | 52 | class_type AuthService, { class => $azs }; | |
| 182 | 52 | class_type AuthReversalService, { class => $ars }; | |
| 183 | 52 | class_type CaptureService, { class => $cps }; | |
| 184 | 52 | class_type CreditService, { class => $cds }; | |
| 185 | 52 | class_type TaxService, { class => $txs }; | |
| 186 | |||
| 187 | 52 | class_type ResPurchaseTotals, { class => $res_pt_c }; | |
| 188 | 52 | class_type AuthReply, { class => $res_ar_c }; | |
| 189 | 52 | class_type Reply, { class => $res_re_c }; | |
| 190 | 52 | class_type DCCReply, { class => $res_dc_c }; | |
| 191 | 52 | class_type TaxReply, { class => $res_tr_c }; | |
| 192 | 52 | class_type TaxReplyItem, { class => $res_ti_c }; | |
| 193 | |||
| 194 | 52 | class_type Client, { class => $client }; | |
| 195 | |||
| 196 | 0 | ▶ | coerce Item, from HashRef, via { use_module($itc)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 197 | 4 | ▶ | coerce PurchaseTotals, from HashRef, via { use_module($ptc)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 198 | 0 | ▶ | coerce Service, from HashRef, via { use_module($svc)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 199 | 0 | ▶ | coerce AuthService, from HashRef, via { use_module($azs)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 200 | 1 | ▶ | coerce AuthReversalService, from HashRef, via { use_module($ars)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 201 | 1 | ▶ | coerce CaptureService, from HashRef, via { use_module($cps)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 202 | 0 | ▶ | coerce CreditService, from HashRef, via { use_module($cds)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 203 | 0 | ▶ | coerce TaxService, from HashRef, via { use_module($txs)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 204 | 2 | ▶ | coerce Card, from HashRef, via { use_module($cdc)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 205 | 0 | ▶ | coerce BillTo, from HashRef, via { use_module($btc)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 206 | 1 | ▶ | coerce ShipTo, from HashRef, via { use_module($stc)->new( $_ ) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 207 | 0 | ▶ | coerce BusinessRules, from HashRef, via { use_module($brc)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 208 | 1 | ▶ | coerce InvoiceHeader, from HashRef, via { use_module($ihc)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 209 | 1 | ▶ | coerce OtherTax, from HashRef, via { use_module($otc)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 210 | 1 | ▶ | coerce ShipFrom, from HashRef, via { use_module($sfc)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 211 | 2 | ▶ | coerce ResPurchaseTotals, from HashRef, via { use_module($res_pt_c)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 212 | 2 | ▶ | coerce AuthReply, from HashRef, via { use_module($res_ar_c)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 213 | 0 | ▶ | coerce TaxReply, from HashRef, via { use_module($res_tr_c)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 214 | 0 | ▶ | coerce DCCReply, from HashRef, via { use_module($res_dc_c)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 215 | 0 | ▶ | coerce TaxReplyItem, from HashRef, via { use_module($res_ti_c)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 216 | 1 | ▶ | coerce Reply, from HashRef, via { use_module($res_re_c)->new($_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 217 | 0 | ▶ | coerce Client, from HashRef, via { use_module($client)->new($_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 218 | |||
| 219 | 52 | subtype CountryCode, as Alpha2Country; | |
| 220 | 52 | subtype ExpirationDate, as MooseX::Types::DateTime::DateTime; | |
| 221 | 52 | subtype DateTimeFromW3C, as MooseX::Types::DateTime::DateTime; | |
| 222 | |||
| 223 | 52 | subtype TaxReplyItems, as ArrayRef [TaxReplyItem]; | |
| 224 | 52 | subtype Items, as ArrayRef [Item]; | |
| 225 | |||
| 226 | 0 | ▶ | coerce CountryCode, from Alpha3Country, via { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 227 | 0 | use_module('Locale::Code'); | |
| 228 | |||
| 229 | 0 | return uc Locale::Code::country_code2code( | |
| 230 | $_, | ||
| 231 | Locale::Code::LOCALE_CODE_ALPHA_3(), | ||
| 232 | Locale::Code::LOCALE_CODE_ALPHA_2(), | ||
| 233 | ); | ||
| 234 | 52 | }; | |
| 235 | |||
| 236 | 0 | ▶ | coerce CountryCode, from CountryName, via { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 237 | 0 | use_module('Locale::Code'); | |
| 238 | return | ||
| 239 | 0 | uc Locale::Code::country_code2code( $_, | |
| 240 | Locale::Code::LOCALE_CODE_ALPHA_2(), | ||
| 241 | ); | ||
| 242 | 52 | }; | |
| 243 | |||
| 244 | 52 | enum DCCIndicator, [qw( 1 2 3 )]; | |
| 245 | |||
| 246 | 0 | ▶ | coerce ExpirationDate, from HashRef, via { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 247 | 0 | return DateTime->last_day_of_month( %{$_} ); | |
| 248 | 52 | }; | |
| 249 | |||
| 250 | subtype RequestID, as NonEmptySimpleStr, | ||
| 251 | 6 | ▶ | where { length $_ <= 29 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 252 | 0 | ▶ | message { $varchar_message . '29' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 253 | |||
| 254 | 0 | ▶ | coerce TaxReplyItems, from ArrayRef [HashRef], via { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 255 | 0 | my $items = $_; | |
| 256 | |||
| 257 | 0 | my @items = map { use_module($res_ti_c)->new($_) } @{$items}; | |
| 258 | 0 | return \@items; | |
| 259 | 52 | }; | |
| 260 | |||
| 261 | 0 | ▶ | coerce Items, from ArrayRef [HashRef], via { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 262 | 0 | my $items = $_; | |
| 263 | |||
| 264 | 0 | my @items = map { use_module($itc)->new($_) } @{$items}; | |
| 265 | 0 | return \@items; | |
| 266 | 52 | }; | |
| 267 | |||
| 268 | 3 | ▶ | coerce DateTimeFromW3C, from DateTimeW3C, via { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 269 | 3 | return use_module('DateTime::Format::W3CDTF')->new->parse_datetime($_); | |
| 270 | 52 | }; | |
| 271 | |||
| 272 | subtype _VarcharOne, as NonEmptySimpleStr, | ||
| 273 | 0 | ▶ | where { length $_ <= 1 }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 274 | 0 | ▶ | message { $varchar_message . '1' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 275 | |||
| 276 | subtype _VarcharSeven, as NonEmptySimpleStr, | ||
| 277 | 2 | ▶ | where { length $_ <= 7 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 278 | 0 | ▶ | message { $varchar_message . '7' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 279 | |||
| 280 | subtype _VarcharTen, as SimpleStr, | ||
| 281 | 22 | ▶ | where { length $_ <= 10 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 282 | 0 | ▶ | message { $varchar_message . '10' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 283 | |||
| 284 | subtype _VarcharFifteen, as SimpleStr, | ||
| 285 | 5 | ▶ | where { length $_ <= 15 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 286 | 0 | ▶ | message { $varchar_message . '15' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 287 | |||
| 288 | subtype _VarcharTwenty, as NonEmptySimpleStr, | ||
| 289 | 0 | ▶ | where { length $_ <= 20 }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 290 | 0 | ▶ | message { $varchar_message . '20' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 291 | |||
| 292 | subtype _VarcharFifty, as NonEmptySimpleStr, | ||
| 293 | 33 | ▶ | where { length $_ <= 50 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 294 | 0 | ▶ | message { $varchar_message . '50' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 295 | |||
| 296 | subtype _VarcharSixty, as NonEmptySimpleStr, | ||
| 297 | 65 | ▶ | where { length $_ <= 60 }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 298 | 0 | ▶ | message { $varchar_message . '60' }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 299 | |||
| 300 | 52 | 1; | |
| 301 | |||
| 302 | # ABSTRACT: Moose Types specific to CyberSource | ||
| 303 | |||
| 304 | __END__ | ||