X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=t%2Fcapture.t;h=de46ac109def079167b385c19006ee9aa8516c6b;hb=870018b93d8b59d23d1c564bcaf612405e9cd5a7;hp=8e1d9131daad977d3ad863e3bd8a90f86d4fae73;hpb=39541291959ba143c5a9e8272b45d49aea654f35;p=Business-OnlinePayment-AuthorizeNet.git diff --git a/t/capture.t b/t/capture.t index 8e1d913..de46ac1 100644 --- a/t/capture.t +++ b/t/capture.t @@ -8,6 +8,9 @@ plan tests => 4; use_ok 'Business::OnlinePayment'; +#avoid dup checking in case "make test" is run too close to the last +my $amount = sprintf('%.2f', rand(100)); + my $tx = Business::OnlinePayment->new("AuthorizeNet"); $tx->server('test.authorize.net'); $tx->content( @@ -16,7 +19,7 @@ $tx->content( password => $password, action => 'Authorization Only', description => 'Business::OnlinePayment visa test', - amount => '49.95', + amount => $amount, invoice_number => '100100', customer_id => 'jsk', first_name => 'Tofu', @@ -28,14 +31,24 @@ $tx->content( card_number => '4007000000027', expiration => expiration_date(), ); -$tx->test_transaction(1); # test, dont really charge + +# don't set test_transaction (using test server though, still a test) +# as per authorize.net: +# "You need to be in Live Mode to get back a transaction ID" +#$tx->test_transaction(1); # test, dont really charge + $tx->submit(); ok($tx->is_success()) or diag $tx->error_message; +my $auth = $tx->authorization; + my $order_number = $tx->order_number; like $order_number, qr/^\d+$/; +#warn "auth: $auth\n"; +#warn "order_number: $order_number\n"; + my $settle_tx = Business::OnlinePayment->new("AuthorizeNet"); $settle_tx->server('test.authorize.net'); $settle_tx->content( @@ -44,14 +57,15 @@ $settle_tx->content( password => $password, action => 'Post Authorization', description => 'Business::OnlinePayment visa test', - amount => '49.95', + amount => $amount, invoice_number => '100100', - order_number => '111', + authorization => $auth, + order_number => $order_number, card_number => '4007000000027', expiration => expiration_date(), ); -$settle_tx->test_transaction(1); # test, dont really charge +#$settle_tx->test_transaction(1); # test, dont really charge $settle_tx->submit(); ok($settle_tx->is_success()) || diag $settle_tx->error_message;