summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/transaction.t73
-rw-r--r--t/transaction_decline.t51
2 files changed, 81 insertions, 43 deletions
diff --git a/t/transaction.t b/t/transaction.t
index 28db227..affe60c 100644
--- a/t/transaction.t
+++ b/t/transaction.t
@@ -3,37 +3,64 @@
use strict;
use warnings;
use POSIX qw(strftime);
-use Test::More tests => 1;
-
+use Test::More;
use Business::OnlinePayment;
-my %content = (
- login => '124freeside',
- password => 'freeside124',
- action => "Normal Authorization",
- type => "CC",
- description => "Business::OnlinePayment::FirstDataGlobalGateway test",
- card_number => '4111111111111111',
- cvv2 => '123',
- expiration => '12/20',
- amount => '1.00',
- first_name => 'Tofu',
- last_name => 'Beast',
- address => '1234 Soybean Ln.',
- city => 'Soyville',
- state => 'CA', #where else?
- zip => '54545',
-);
+my $login = $ENV{BOP_TEST_LOGIN};
+my $password = $ENV{BOP_TEST_PASSWORD};
+if (!$login) {
+ plan skip_all => "no test credentials provided; set BOP_TEST_LOGIN and BOP_TEST_PASSWORD to test communication with the gateway.",
+ 1;
+ exit(0);
+}
+
+plan tests => 2;
+
+###
+# Purchase
+###
+my %content = (
+ login => $login,
+ password => $password,
+ type => "CC",
+ description => "Business::OnlinePayment::FirstDataGlobalGateway test",
+ card_number => '4111111111111111',
+ cvv2 => '123',
+ expiration => '12/20',
+ amount => '1.00',
+ first_name => 'Tofu',
+ last_name => 'Beast',
+ address => '1234 Soybean Ln.',
+ city => 'Soyville',
+ state => 'CA', #where else?
+ zip => '94804',
+);
my $tx = new Business::OnlinePayment( 'FirstDataGlobalGateway' );
-$tx->content( %content );
+$tx->content( %content,
+ action => 'Normal Authorization' );
$tx->test_transaction(1);
$tx->submit;
-is( $tx->is_success, 1, 'Test transaction successful')
- or diag('iATS Payments error: '. $tx->error_message);
-
+is( $tx->is_success, 1, 'purchase' )
+ or diag('Gateway error: '. $tx->error_message);
+
+###
+# Refund
+###
+my $auth = $tx->authorization;
+$tx = new Business::OnlinePayment( 'FirstDataGlobalGateway' );
+$tx->content( %content,
+ action => 'Credit',
+ authorization => $auth );
+$tx->test_transaction(1);
+
+$tx->submit;
+
+is( $tx->is_success, 1, 'refund' )
+ or diag('Gateway error: '. $tx->error_message);
+
1;
diff --git a/t/transaction_decline.t b/t/transaction_decline.t
index 47a4cd1..a8efafb 100644
--- a/t/transaction_decline.t
+++ b/t/transaction_decline.t
@@ -3,25 +3,35 @@
use strict;
use warnings;
use POSIX qw(strftime);
-use Test::More tests => 3;
-
+use Test::More;
use Business::OnlinePayment;
-my %content = (
- action => "Normal Authorization",
- type => "CC",
- description => "Business::OnlinePayment::FirstDataGlobalGateway test",
- card_number => '4111111111111111',
- cvv2 => '123',
- expiration => '12/20',
- amount => '2.00',
- first_name => 'Tofu',
- last_name => 'Beast',
- address => '1234 Soybean Ln.',
- city => 'Soyville',
- state => 'CA', #where else?
- zip => '54545',
-);
+my $login = $ENV{BOP_TEST_LOGIN};
+my $password = $ENV{BOP_TEST_PASSWORD};
+if (!$login) {
+ plan skip_all => "no test credentials provided; set BOP_TEST_LOGIN and BOP_TEST_PASSWORD to test communication with the gateway.",
+ 1;
+ exit(0);
+}
+
+plan tests => 2;
+my %content = (
+ login => $login,
+ password => $password,
+ action => "Normal Authorization",
+ type => "CC",
+ description => "Business::OnlinePayment::FirstDataGlobalGateway test",
+ card_number => '4111111111111111',
+ cvv2 => '123',
+ expiration => '12/20',
+ amount => '5521.00', # trigger error 521
+ first_name => 'Tofu',
+ last_name => 'Beast',
+ address => '1234 Soybean Ln.',
+ city => 'Soyville',
+ state => 'CA', #where else?
+ zip => '54545',
+);
my $tx = new Business::OnlinePayment( 'FirstDataGlobalGateway' );
@@ -31,8 +41,9 @@ $tx->test_transaction(1);
$tx->submit;
-unlike( $tx->error_message, qr/^Agent code has not been set up/, 'Test decline not a login error');
-is( $tx->is_success, 0, 'Test decline transaction successful');
-is( $tx->failure_status, 'decline', 'Test decline failure_status set');
+is( $tx->is_success, 0, 'declined purchase')
+ or diag('Test transaction should have failed, but succeeded');
+is( $tx->failure_status, 'nsf', 'failure status' )
+ or diag('Failure status reported as '.$tx->failure_status);
1;