fix detection of a successful test
[freeside.git] / FS / t / suite / 03-realtime_pay.t
1 #!/usr/bin/perl
2
3 use FS::Test;
4 use Test::More tests => 2;
5 use FS::cust_main;
6
7 my $FS = FS::Test->new;
8
9 # In the stock database, cust#5 has open invoices
10 my $cust_main = FS::cust_main->by_key(5);
11 my $balance = $cust_main->balance;
12 ok( $balance > 10.00, 'customer has an outstanding balance of more than $10.00' );
13
14 # Get the payment form
15 $FS->post('/misc/payment.cgi?payby=CARD;custnum=5');
16 my $form = $FS->form('OneTrueForm');
17 $form->value('amount'       => '10.00');
18 $form->value('custpaybynum' => '');
19 $form->value('payinfo'      => '4012888888881881');
20 $form->value('month'        => '01');
21 $form->value('year'         => '2020');
22 # payname and location fields should already be set
23 $form->value('save'         => 1);
24 $form->value('auto'         => 1);
25 $FS->post($form);
26
27 # on success, gives a redirect to the payment receipt
28 my $paynum;
29 if ($FS->redirect =~ m[^/view/cust_pay.html\?paynum=(\d+)]) {
30   pass('payment processed');
31   $paynum = $1;
32 } elsif ( $FS->error ) {
33   fail('payment rejected');
34   diag ( $FS->error );
35 } else {
36   fail('unknown result');
37   diag ( $FS->page );
38 }
39
40 1;