diff options
Diffstat (limited to 't')
-rwxr-xr-x[-rw-r--r--] | t/022-payments-card-pre-authorization-complete-void.t (renamed from t/022-payments-card-pre-authorization.t) | 90 |
1 files changed, 70 insertions, 20 deletions
diff --git a/t/022-payments-card-pre-authorization.t b/t/022-payments-card-pre-authorization-complete-void.t index acceee5..00c25f9 100644..100755 --- a/t/022-payments-card-pre-authorization.t +++ b/t/022-payments-card-pre-authorization-complete-void.t @@ -60,6 +60,7 @@ SKIP: { created order_number risk_score + id ); ok( $response = $tr->response_decoded, 'response_decoded' ); @@ -81,13 +82,14 @@ SKIP: { %content = ( %content, - action => 'post authorization', + action => 'Post Authorization', order_number => $tr->order_number, + amount => '8.99', # $1 Less than pre-auth ); my $tr_pa; ok( $tr_pa = Business::OnlinePayment->new('Bambora'), 'Instantiate $tr_pa' ); - ok( $tr->content( %content ), 'Set transaction content onto $tr_pa' ); + ok( $tr_pa->content( %content ), 'Set transaction content onto $tr_pa' ); { local $@; eval { $tr_pa->submit }; @@ -95,27 +97,75 @@ SKIP: { warn "Error: $@" if $@; } - my $response_pa; - + %expect = ( + amount => '8.99', + approved => '1', + message => 'Approved', + message_id => '1', + type => 'PAC', + ); + @expect = (qw/ + authorizing_merchant_id + card + created + order_number + id + /); + my $response_pa; ok( $response_pa = $tr_pa->response_decoded, 'response_decoded' ); - # for my $attr (qw/ - # message_id - # authorization - # order_number - # txn_date - # avs_code - # is_success - # /) { - # ok( - # defined $tr->$attr(), - # sprintf '%s $tr->%s() = %s', - # $name, - # $attr, - # $tr->$attr() - # ); - # } + for my $k ( keys %expect ) { + ok( + $response_pa->{$k} eq $expect{$k}, + sprintf '$tr->%s == %s', $k, $expect{$k} + ); + } + + for my $k ( @expect ) { + ok( + defined $response_pa->{$k}, + sprintf '$r->%s (%s)', + $k, $response_pa->{$k} + ); + } + + # + # Void Transaction + # + + my %content_void = ( + action => 'Void', + login => $content{login}, + password => $content{password}, + order_number => $tr_pa->order_number, + amount => '8.99', + ); + + my $tr_void; + ok( $tr_void = Business::OnlinePayment->new('Bambora'), 'Instantiate $tr_void' ); + ok( $tr_void->content( %content_void ), 'Set transaction content onto $tr_void' ); + { + local $@; + eval { $tr_void->submit }; + ok( !$@, "Submit void" ); + warn "Error: $@" if $@; + } + + %expect = ( + amount => '8.99', + approved => '1', + message => 'Approved', + message_id => '1', + type => 'R', + ); + @expect = (qw/ + authorizing_merchant_id + card + created + order_number + id + /); } |