1 package Business::OnlineThirdPartyPayment;
6 use base qw(Business::OnlinePayment);
11 $VERSION = eval $VERSION; # modperlstyle: convert the string into a number
14 authorization => undef,
15 error_message => undef,
16 failure_status => undef,
17 fraud_detect => undef, # unsupported
19 maximum_risk => undef, # unsupported
25 server_response => undef,
26 test_transaction => undef,
27 transaction_type => undef,
28 fraud_score => undef, # unsupported
29 fraud_transaction_id => undef, # unsupported
31 collectitems => undef,
35 my($class,$processor,%data) = @_;
37 croak("unspecified processor") unless $processor;
39 my $subclass = "${class}::$processor";
41 croak("unknown processor $processor ($@)") if $@;
43 my $self = bless {processor => $processor}, $subclass;
44 $self->build_subs(keys %fields);
46 if($self->can("set_defaults")) {
47 $self->set_defaults(%data);
52 my $value = $data{$_};
54 $self->build_subs($key);
64 croak("Processor subclass did not override reference function");
73 Business::OnlineThirdPartyPayment - Perl extension for third party web page based online payment processing
77 use Business::OnlineThirdPartyPayment;
80 new Business::OnlineThirdPartyPayment($processor, %processor_info);
81 $transaction->content(
83 action => 'Authorization Only',
85 reference => '3735928559',
87 $transaction->submit();
89 if($transaction->is_success()) {
90 print "Success! Redirect browser to ". $transaction->popup_url();
92 print "Card was rejected: ", $transaction->error_message(), "\n";
95 #when the provider calls us back via HTTP
97 my $cgi = new CGI; #initialized to current page
99 my $reference = $transaction->reference($cgi->Vars);
100 $transaction->content(
102 action => 'Post Authorization',
103 reference => $reference,
105 $transaction->submit();
106 if($transaction->is_success()) {
107 print "Card processed scucessfully: ", $transaction->authorization(), "\n";
109 print "Card was rejected: ", $transaction->error_message(), "\n";
116 Business::OnlineThirdPartyPayment is a generic module for processing payments
117 through online credit card processors, electronic cash systems, etc. through
118 which the payors web browser is redirected. It is a subclass of
119 L<Business::OnlinePayment>
121 =head1 METHODS AND FUNCTIONS
123 =head2 new($processor, %processor_options);
125 Create a new Business::OnlineThirdPartyPayment object, $processor is required,
126 and defines the online processor to use. If necessary, processor
127 options can be specified, currently supported options are 'Server',
128 'Port', and 'Path', which specify how to find the online processor
129 (https://server:port/path), but individual processor modules should
130 supply reasonable defaults for this information, override the defaults
131 only if absolutely necessary (especially path), as the processor
132 module was probably written with a specific target script in mind.
134 =head2 content(%content);
136 The information necessary for the transaction, this tends to vary a
137 little depending on the processor, so we have chosen to use a system
138 which defines specific fields in the frontend which get mapped to the
139 correct fields in the backend. Currently defined fields are:
141 =head3 PROCESSOR FIELDS
147 A unique reference for this transaction.
151 For additional fields, see L<Business::OnlinePayment> and the specific
152 processor module used.
156 Submit the transaction to the processor for completion
160 Returns true if the transaction was submitted successfully, false if
161 it failed (or undef if it has not been submitted yet).
163 =head2 test_transaction();
165 Most processors provide a test mode, where submitted transactions will
166 not actually be charged or added to your batch, calling this function
167 with a true argument will turn that mode on if the processor supports
168 it, or generate a fatal error if the processor does not support a test
169 mode (which is probably better than accidentally making real charges).
173 Jeff Finucane <business-onlinethirdpartypayment@weasellips>
177 Partially based on code from Business::OnlinePayment.
179 Copyright (c) 1999-2004 Jason Kohles.
180 Copyright (c) 2004 Ivan Kohler
181 Copyright (c) 2007-2009 Freeside Internet Services, Inc.
183 All rights reserved. This program is free software; you can redistribute
184 it and/or modify it under the same terms as Perl itself.
188 THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
189 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
190 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
194 L<Business::OnlinePayment>, http://420.am/business-onlinepayment/
196 For verification of credit card checksums, see L<Business::CreditCard>.