#!/usr/bin/perl -w
use Test::More;
+require "t/lib/test_account.pl";
-my($login, $password, @opts) = ('TESTMERCHANT', '',
- 'default_Origin' => 'RECURRING' );
+my($login, $password, %opt) = test_account_or_skip('card');
plan tests => 43;
use_ok 'Business::OnlinePayment';
# valid card number test
{
- my $tx = Business::OnlinePayment->new("IPPay", @opts);
+ my $tx = Business::OnlinePayment->new("IPPay", %opt);
$tx->content(%content);
tx_check(
$tx,
# invalid card number test
{
- my $tx = Business::OnlinePayment->new("IPPay", @opts);
+ my $tx = Business::OnlinePayment->new("IPPay", %opt);
$tx->content(%content, card_number => "4111111111111112" );
tx_check(
$tx,
# authorization only test
{
- my $tx = Business::OnlinePayment->new("IPPay", @opts);
+ my $tx = Business::OnlinePayment->new("IPPay", %opt);
$tx->content(%content, action => 'authorization only', amount => '3.00' );
tx_check(
$tx,
# post authorization test
SKIP: {
- my $tx = new Business::OnlinePayment( "IPPay", %opts );
+ my $tx = new Business::OnlinePayment( "IPPay", %opt );
$tx->content( %content, 'action' => "post authorization",
'amount' => $postable_amount, # not required
'order_number' => $postable,
# void test
SKIP: {
- my $tx = new Business::OnlinePayment( "IPPay", %opts );
+ my $tx = new Business::OnlinePayment( "IPPay", %opt );
$tx->content( %content, 'action' => "Void",
'order_number' => $voidable,
'authorization' => $voidable_auth,
# credit test
SKIP: {
- my $tx = new Business::OnlinePayment( "IPPay", %opts );
+ my $tx = new Business::OnlinePayment( "IPPay", %opt );
$tx->content( %content, 'action' => "credit");
tx_check(
$tx,
);
}
-sub expiration_date {
- my($month, $year) = (localtime)[4,5];
- $year++; # So we expire next year.
- $year %= 100; # y2k? What's that?
-
- return sprintf("%02d/%02d", $month, $year);
-}
--- /dev/null
+sub test_account_or_skip {
+ my $suffix = shift;
+ my($login, $password, %opt) = test_account($suffix);
+
+ unless( defined $login ) {
+ plan skip_all => "No test account";
+ }
+
+ return($login, $password, %opt);
+}
+
+sub test_account {
+ my $suffix = shift || 'card';
+
+ my($login, $password) = ('TESTMERCHANT', '');
+
+ my %opt;
+ if ( $suffix eq 'check ' ) {
+ %opt = ('Origin' => 'RECURRING');
+ } else {
+ %opt = ('default_Origin' => 'RECURRING');
+ }
+
+ return($login, $password, %opt);
+}
+
+sub expiration_date {
+ my($month, $year) = (localtime)[4,5];
+ $month += 1;
+ $year++; # So we expire next year.
+ $year %= 100; # y2k? What's that?
+
+ return sprintf("%02d/%02d", $month, $year);
+}
+
+#sub tomorrow {
+# my($day, $month, $year) = (localtime(time+86400))[3..5];
+# return sprintf("%04d-%02d-%02d", $year+1900, ++$month, $day);
+#}
+
+1;
+