1 package Business::OnlinePayment::HTTPS;
4 use vars qw($VERSION @ISA $ssl_module $skip_NetSSLeay);
10 @ISA = qw( Business::OnlinePayment );
19 die if defined($skip_NetSSLeay) && $skip_NetSSLeay;
22 # qw(get_https post_https make_form make_headers);
23 $ssl_module = 'Net::SSLeay';
28 require LWP::UserAgent;
29 require HTTP::Request::Common;
30 require Crypt::SSLeay;
31 #import HTTP::Request::Common qw(GET POST);
32 $ssl_module = 'Crypt::SSLeay';
36 unless ( $ssl_module ) {
37 die "Net::SSLeay (+URI) or Crypt::SSLeay (+LWP) is required";
44 Business::OnlinePayment::HTTPS - Base class for HTTPS payment APIs
48 package Business::OnlinePayment::MyProcessor
49 @ISA = qw( Business::OnlinePayment::HTTPS );
56 # pass a list (order is preserved, if your gateway needs that)
57 ($page, $response, %reply_headers)
58 = $self->https_get( field => 'value', ... );
61 my %hash = ( field => 'value', ... );
62 ($page, $response_code, %reply_headers)
63 = $self->https_get( $hashref );
70 This is a base class for HTTPS based gateways, providing useful code for
71 implementors of HTTPS payment APIs.
73 It depends on Net::SSLeay _or_ ( Crypt::SSLeay and LWP::UserAgent ).
79 =item https_get HASHREF | FIELD => VALUE, ...
81 Accepts parameters as either a hashref or a list of fields and values. In the
82 latter case, ordering is preserved (see L<Tie::IxHash> to do so when passing a
85 Returns a list consisting of the page content as a string, the HTTP response
86 code, and a list of key/value pairs representing the HTTP response headers.
93 #accept a hashref or a list (keep it ordered)
98 tie my %hash, 'Tie::IxHash', @_;
102 my $path = $self->path;
103 if ( keys %$post_data ) {
105 #my $u = URI->new("", "https");
106 #$u->query_param(%$post_data);
107 #$path .= '?'. $u->query;
109 $path .= '?'. join('&',
110 map { uri_escape($_).'='. uri_escape($post_data->{$_}) }
117 my $referer = ''; ### XXX referer!!!
119 $headers{'Referer'} = $referer if length($referer);
121 if ( $ssl_module eq 'Net::SSLeay' ) {
123 import Net::SSLeay qw(get_https make_headers);
124 my $headers = make_headers(%headers);
125 get_https( $self->server, $self->port, $path, $referer, $headers );
127 } elsif ( $ssl_module eq 'Crypt::SSLeay' ) {
129 import HTTP::Request::Common qw(GET);
131 my $ua = new LWP::UserAgent;
132 my $res = $ua->request(
133 GET( 'https://'. $self->server. ':'. $self->port. '/'. $path )
136 #( $res->as_string, # wtf?
139 map { $_ => $res->header($_) } $res->header_field_names
144 die "unknown SSL module $ssl_module";
159 die "not yet implemented";
166 L<Business::OnlinePayment>