Business-OnlinePayment-IPayment

 view release on metacpan or  search on metacpan

t/payment.t  view on Meta::CPAN


my $faultybopi;

eval { $faultybopi =
         Business::OnlinePayment::IPayment->new();
       $faultybopi->session_id;
       };

ok($@, "Error: $@");

my %accdata = (
               accountid => 99999,
               trxuserid => 99999,
               trxpassword => 0,
               adminactionpassword => '5cfgRT34xsdedtFLdfHxj7tfwx24fe',
              );

my %urls = (
            success_url => "http://linuxia.de/ipayment/success",
            failure_url => "http://linuxia.de/ipayment/failure",
           );

t/payment.t  view on Meta::CPAN

# please note that we want to die here, as without the credentials is
# not going to work, and should be provided when the object is
# created.
foreach my $k (qw/accountid trxuserid trxpassword/) {
    eval { $faultybopi =
             Business::OnlinePayment::IPayment->new(%faulty, %urls);
           $faultybopi->session_id;
       };
    # test all the bad values
    ok($@, "Error: $@");
    $faulty{$k} = $accdata{$k};
}

# adminactionpassword seems to be optional? But we need only to
# generate the session, nothing more

my $wsdl_file = File::Spec->catfile("t", "ipayment.wsdl");

my $bopi = Business::OnlinePayment::IPayment->new(%accdata, %urls,
                                                  wsdl_file => $wsdl_file);

$accdata{accountId} = delete $accdata{accountid};
$accdata{trxuserId} = delete $accdata{trxuserid};

is_deeply($bopi->accountData, { %accdata } , "Stored values ok");

is scalar(keys %{$bopi->processorUrls}), 3, "Found 3 urls";
is $bopi->processorUrls->{redirectUrl}, $urls{success_url}, "success ok";
is $bopi->processorUrls->{silentErrorUrl}, $urls{failure_url}, "success ok";

eval { $bopi->trx_obj->paymentType("test") };
ok($@, "Can't set payment type to bogus value $@");

eval { $bopi->trx_obj->transactionType("preauth") };
ok($@, "Can't change the transaction to allowed value after its creation");



( run in 0.521 second using v1.01-cache-2.11-cpan-454fe037f31 )