File Coverage

blib/lib/Business/Payment/Charge.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Business::Payment::Charge;
2              
3 5     5   525 use Moose;
  5         8  
  5         24  
4 5     5   21065 use Business::Payment::Types;
  5         11  
  5         37  
5              
6             with 'MooseX::Traits';
7              
8             has '+_trait_namespace' => (
9             default => 'Business::Payment::Charge'
10             );
11              
12             has type => (
13             is => 'ro',
14             isa => 'Str',
15             default => 'CHARGE'
16             );
17              
18             has amount => (
19             is => 'ro',
20             isa => 'Math::Currency',
21             coerce => 1,
22             required => 1
23             );
24              
25             has credit_card => (
26             is => 'rw',
27             isa => 'Object'
28             );
29              
30             has description => (
31             is => 'rw',
32             isa => 'Str'
33             );
34              
35 5     5   1902 no Moose;
  5         10  
  5         29  
36             __PACKAGE__->meta->make_immutable;
37              
38             =head1 NAME
39              
40             Business::Payment::Charge - Charge to be handled by Processor
41              
42             =head1 SYNOPSIS
43              
44             use Business::Payment;
45              
46             my $bp = Business::Payment->new(
47             processor => Business::Payment::Processor::Test::True->new
48             );
49              
50             my $charge = Business::Payment::Charge->new(
51             amount => 10.00 # Something Math::Currency can parse
52             );
53              
54             my $result = $bp->handle($charge);
55             if($result->success) {
56             print "Success!\n";
57             } else {
58             print "Failed: ".$result->error_code.": ".$result->error_message."\n";
59             }
60              
61             =head1 DESCRIPTION
62              
63             Business::Payment::Charge is a unit of work meant to represent a single
64             transaction to be handled by a processor.
65              
66             =head1 AUTHOR
67              
68             Cory G Watson, C<< <gphat@cpan.org> >>
69              
70             =head1 COPYRIGHT & LICENSE
71              
72             Copyright 2009 Cold Hard Code, LLC, all rights reserved.
73              
74             This program is free software; you can redistribute it and/or modify it
75             under the same terms as Perl itself.