package Business::OnlinePayment;
use strict;
-use vars qw($VERSION);
+use vars qw($VERSION %_info_handler);
use Carp;
require 5.005;
response_page
);
+#fallback
+sub _info {
+ my $class = shift;
+ ( my $gw = $class ) =~ s/^Business::OnlinePayment:://;
+ {
+ 'info_compat' => '0.00',
+ 'gateway_name' => $gw,
+ 'module_notes' => "Module does not yet provide info.",
+ };
+}
+
+#allow classes to declare info in a flexible way, but return normalized info
+%_info_handler = (
+ 'supported_types' => sub {
+ my( $class, $v ) = @_;
+ my $types = ref($v) ? $v : [ $v ];
+ $types = { map { $_=>1 } @$types } if ref($v) eq 'ARRAY';
+ $types;
+ },
+ 'supported_actions' => sub {
+ my( $class, $v ) = @_;
+ return $v if ref($v) eq 'HASH';
+ $v = [ $v ] unless ref($v);
+ my $types = $class->info('supported_types');
+ { map { $_ => $v } keys %$types };
+ },
+);
+
+sub info {
+ my $class = shift;
+ my $info = $class->_info;
+ if ( @_ ) {
+ my $key = shift;
+ exists($_info_handler{$key})
+ ? &{ $_info_handler{$key} }( $class, $info->{$key} )
+ : $info->{$key};
+ } else {
+ wantarray ? ( keys %$info ) : [ keys %$info ];
+ }
+}
+
sub new {
my($class,$processor,%data) = @_;
=item action
-What to do with the transaction (currently available are: Normal
-Authorization, Authorization Only, Credit, Post Authorization,
-Recurring Authorization, Modify Recurring Authorization,
-Cancel Recurring Authorization)
+What action being taken by this transaction. Currently available are:
+
+=over 8
+
+=item Normal Authorization
+
+=item Authorization Only
+
+=item Post Authorization
+
+=item Void
+
+=item Credit
+
+=item Recurring Authorization
+
+=item Modify Recurring Authorization
+
+=item Cancel Recurring Authorization
+
+=back
=item amount
=head1 AUTHORS
+(v2 series)
+
Jason Kohles, email@jasonkohles.com
-(v3 rewrite) Ivan Kohler <ivan-business-onlinepayment@420.am>
+(v3 rewrite)
+
+Ivan Kohler <ivan-business-onlinepayment@420.am>
Phil Lobbes E<lt>phil at perkpartners dot comE<gt>
(or add "failure_status" to your build_subs call if you have one during
initialization)
-
+
+
+- (NEW IN 3.01) Introspection:
+
+ - Add an _info subroutine to your module that returns a hashref of
+ information:
+
+ sub _info {
+ {
+ 'info_compat' => '0.01', # always 0.01 for now,
+ # 0.02 will have requirements
+ 'gateway_name' => 'Example Gateway',
+ 'gateway_url' => 'http://www.example.com/',
+ 'module_version' => $VERSION,
+ 'supported_types' => [ qw( CC ECHECK ) ],
+ 'supported_actions' => [
+ 'Normal Authorization',
+ 'Authorization Only',
+ 'Post Authorization',
+ 'Void',
+ 'Credit',
+ ],
+ };
+ }
+
+ # or a more complicated case:
+
+ sub _info {
+ {
+ 'info_compat' => '0.01', # always 0.01 for now,
+ # 0.02 will have requirements
+ 'gateway_name' => 'Example Gateway',
+ 'gateway_url' => 'http://www.example.com/',
+ 'module_version' => $VERSION,
+ 'module_notes' => 'usage notes',
+ 'supported_types' => [ qw( CC ECHECK ) ],
+ 'supported_actions' => { 'CC' => [
+ 'Normal Authorization',
+ 'Authorization Only',
+ 'Post Authorization',
+ 'Void',
+ 'Credit',
+ 'Recurring Authorization',
+ 'Modify Recurring Authorization',
+ 'Cancel Recurring Authorization',
+ ],
+ 'ECHECK' => [
+ 'Normal Authorization',
+ 'Void',
+ 'Credit',
+ ],
+ },
+ 'CC_void_requires_card' => 1,
+ };
+ }
+
+