~ubuntu-branches/ubuntu/natty/libbusiness-onlinepayment-ippay-perl/natty

« back to all changes in this revision

Viewing changes to .pc/no-connectivity.patch/t/check.t

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Bamber, gregor herrmann, Nicholas Bamber, Ansgar Burchardt
  • Date: 2010-10-28 14:28:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101028142852-tkh4l5fw0lyygl4o
Tags: 0.05-1
[ gregor herrmann ]
* Bump debhelper dependency in debian/control to 7.

[ Nicholas Bamber ]
* New upstream release
* Upped standards version to 3.9.1
* echo '3.0 (quilt)' > debian/source/format
* Added myself to Uploaders
* Rewrote short and long descriptions
* Refreshed copyright
* Reviewed patch (and converted from diff format)

[ Ansgar Burchardt ]
* debian/control: Make build-dep on perl unversioned.
* debian/control: Change Homepage field to Business::OnlinePayment homepage
  which is more informative than the module's CPAN page. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
use Test::More;
 
4
 
 
5
my($login, $password, %opt) = ('TESTMERCHANT', '', 'Origin' => 'RECURRING' );
 
6
plan tests => 16;
 
7
 
 
8
use_ok 'Business::OnlinePayment';
 
9
 
 
10
my %content = (
 
11
    type           => 'CHECK',
 
12
    login          => $login,
 
13
    password       => $password,
 
14
    action         => 'Normal Authorization',
 
15
    amount         => '49.95',
 
16
    customer_id    => 'jsk',
 
17
    name           => 'Tofu Beast',
 
18
    account_number => '12345',
 
19
    routing_code   => '111000025',  # BoA in Texas taken from Wikipedia
 
20
    bank_name      => 'First National Test Bank',
 
21
    account_type   => 'Checking',
 
22
);
 
23
 
 
24
my $voidable;
 
25
 
 
26
#check test
 
27
{
 
28
  my $ctx = Business::OnlinePayment->new("IPPay", %opt);
 
29
  $ctx->content(%content);
 
30
  tx_check(
 
31
    $ctx,
 
32
    desc          => 'normal ACH transaction',
 
33
    is_success    => 1,
 
34
    result_code   => '000',
 
35
    error_message => 'CHECK ACCEPTED',
 
36
    authorization => qr/^000000$/,
 
37
    name          => 'Tofu Beast',
 
38
  );
 
39
  $voidable = $ctx->order_number if $ctx->is_success;
 
40
}
 
41
 
 
42
#check void test
 
43
{
 
44
  my $ctx = Business::OnlinePayment->new("IPPay", %opt);
 
45
  $ctx->content(%content, action => 'void', order_number => $voidable);
 
46
  tx_check(
 
47
    $ctx,
 
48
    desc          => 'ACH void transaction',
 
49
    is_success    => 1,
 
50
    result_code   => '000',
 
51
    error_message => 'CHECK ACCEPTED',
 
52
    authorization => qr/^000000$/,
 
53
  );
 
54
}
 
55
 
 
56
#check credit test
 
57
{
 
58
  my $ctx = Business::OnlinePayment->new("IPPay", %opt);
 
59
  $ctx->content(%content, action => 'credit');
 
60
  tx_check(
 
61
    $ctx,
 
62
    desc          => 'ACH credit transaction',
 
63
    is_success    => 1,
 
64
    result_code   => '000',
 
65
    error_message => 'CHECK ACCEPTED',
 
66
    authorization => qr/^000000$/,
 
67
  );
 
68
}
 
69
 
 
70
sub tx_check {
 
71
    my $tx = shift;
 
72
    my %o  = @_;
 
73
 
 
74
    $tx->test_transaction(1);
 
75
    $tx->submit;
 
76
 
 
77
    is( $tx->is_success,    $o{is_success},    "$o{desc}: " . tx_info($tx) );
 
78
    is( $tx->result_code,   $o{result_code},   "result_code(): RESULT" );
 
79
    is( $tx->error_message, $o{error_message}, "error_message() / RESPMSG" );
 
80
    like( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
 
81
    like( $tx->order_number, qr/^\w{18}/, "order_number() / PNREF" );
 
82
}
 
83
 
 
84
sub tx_info {
 
85
    my $tx = shift;
 
86
 
 
87
    no warnings 'uninitialized';
 
88
 
 
89
    return (
 
90
        join( "",
 
91
            "is_success(",     $tx->is_success,    ")",
 
92
            " order_number(",  $tx->order_number,  ")",
 
93
            " error_message(", $tx->error_message, ")",
 
94
            " result_code(",   $tx->result_code,   ")",
 
95
            " auth_info(",     $tx->authorization, ")",
 
96
        )
 
97
    );
 
98
}
 
99