Business-PhoneBill-Allopass

 view release on metacpan or  search on metacpan

Allopass/Simple.pm  view on Meta::CPAN

package Business::PhoneBill::Allopass::Simple;

use vars qw($VERSION @ISA @EXPORT);
$VERSION = "1.01";

use HTTP::Request::Common qw(GET POST);
use LWP::UserAgent;

my $baseurl = 'http://www.allopass.com/check/vf.php4';
my $error   = '';

use Exporter;
@EXPORT=qw('allopass_check');

=head1 NAME

Billing::Allopass::Simple - A simple function for micropayment system from Allopass

=head1 SYNOPSIS

    use Business::PhoneBill::Allopass::Simple;
  
    if (allopass_check($document_id, $RECALL)){
        print "OK\n";
    } else {
        print get_last_allopass_error;
    }
  
=head1 DESCRIPTION

This module provides a simple API to the Allopass.com micropayment system.
This alternative to Business::PhoneBill::Allopass justs performs access code checks.

See I<http://www.allopass.com/index.php4?ADV=1508058> for more informations on their system and how it basically works.

=head1 FUNCTIONS

=over 4

=item B<allopass_check> - Checks if a code has been recently validated for this document.

    allopass_check($document_id, $code);

You must perform this check within 2 minutes after the code is entered.

=cut

sub allopass_check {
    my ($doc_id, $code, $r) = @_;
    my ($res, $ua, $req);
    $ua = LWP::UserAgent->new;
    $ua->agent('Business::PhoneBill::Allopass::Simple/'.$VERSION);
    $req = POST $baseurl,
        [
        'CODE'      => $code ,
	'to'        => $doc_id ,
        ];
    $res = $ua->simple_request($req)->as_string;
    return _is_res_ok($res);
}

=item B<get_last_allopass_error> - Returns last status string

    print get_last_allopass_error();

=cut



( run in 1.458 second using v1.01-cache-2.11-cpan-3c2a17b8caa )