0.03
[Business-BatchPayment.git] / BatchPayment.pm
1 package Business::BatchPayment;
2
3 use 5.006;
4 use strict;
5 use vars '$DEBUG';
6 use warnings;
7
8 use Class::MOP;
9 use Business::BatchPayment::Processor;
10 use Business::BatchPayment::Item;
11 use Business::BatchPayment::Transport;
12
13 $DEBUG = 0;
14
15 =head1 NAME
16
17 Business::BatchPayment - Batch-oriented payment processing
18
19 =cut
20
21 our $VERSION = '0.02';
22
23 =head1 SYNOPSIS
24
25   use Business::BatchPayment;
26
27   my %options = ( merchant_id => '00451', password => 'opensesame' );
28   my $processor = Business::BatchPayment->create(MyGateway => %options);
29
30   my @request;
31   push @request, Business::BatchPayment->create(Item =>
32     action        => 'payment', # as opposed to 'credit'
33     payment_type  => 'CC', #credit card, or 'ECHECK' for check/ACH
34     amount        => '49.95',
35     tid           => '0001234', # transaction id, like a customer/order number
36     card_number   => '1234123412341238',
37     expiration    => '0100', # MM/YY
38     # these fields are optional
39     first_name    => 'John',
40     last_name     => 'Doe',
41     address       => '123 Main Street',
42     address2      => 'Suite H',
43     city          => 'Anytown',
44     state         => 'CA',
45     country       => 'US',
46     zip           => '99015',
47   ); # returns a Business::OnlinePayment::Item;
48
49   $processor->submit(@request);
50
51   # at some point in the future
52   
53   my @reply = $processor->receive();
54   foreach my $item (@reply) {
55     ... process items and record successful/failed payments
56   }
57
58   # if your processor uses processor_id...
59
60   $processor->submit(@request);
61   foreach (@request) {
62     ... record process_id for that request
63   }
64   # later...
65   my @reply = $processor->receive(@process_ids);
66
67 =head1 CLASS METHODS
68
69 =over 4
70
71 =item create MODULE[, OPTIONS ]
72
73 Loads Business::BatchPayment::MODULE, then attempts to call 
74 Business::BatchPayment::MODULE->new(OPTIONS).
75
76 =cut
77
78 # not a Moose method
79
80 sub create {
81   my $class = shift;
82   my $subclass = shift;
83   $subclass = "Business::BatchPayment::$subclass";
84   Class::MOP::load_class($subclass);
85   $subclass->new(@_);
86 }
87
88 =back
89
90 =head1 AUTHOR
91
92 Mark Wells, C<< <mark at freeside.biz> >>
93
94 =head1 BUGS
95
96 =head1 SUPPORT
97
98 You can find documentation for this module with the perldoc command.
99
100     perldoc Business::BatchPayment
101
102 Commercial support is available from Freeside Internet Services,
103 L<http://www.freeside.biz>.
104
105 =head1 LICENSE AND COPYRIGHT
106
107 Copyright 2012 Mark Wells.
108
109 This program is free software; you can redistribute it and/or modify it
110 under the terms of either: the GNU General Public License as published
111 by the Free Software Foundation; or the Artistic License.
112
113 See http://dev.perl.org/licenses/ for more information.
114
115
116 =cut
117
118 1; # End of Business::BatchPayment