summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/bop.t35
-rw-r--r--t/credit_card.t31
-rw-r--r--t/pod-coverage.t10
3 files changed, 63 insertions, 13 deletions
diff --git a/t/bop.t b/t/bop.t
index 37bd4a1..5f03ca2 100644
--- a/t/bop.t
+++ b/t/bop.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 11;
use Business::OnlinePayment;
@@ -15,14 +15,37 @@ my $driver = "PayflowPro";
$obj = $package->new($driver);
isa_ok( $obj, $package );
- # new (via build_subs) automatically creates convenience methods
- can_ok( $obj, qw(vendor partner cert_path) );
+ # convenience methods
+ can_ok( $obj, qw(vendor partner) );
can_ok( $obj, qw(order_number avs_code cvv2_code) );
+ can_ok( $obj, qw(request_id param debug expdate_mmyy) );
+
+ # internal methods
+ can_ok( $obj, qw(_map_fields _revmap_fields) );
# defaults
my $server = "payflow.verisign.com";
- is( $obj->server, $server, "server($server)" );
- is( $obj->port, "443", "port(443)" );
- is( $obj->cert_path, undef, "cert_path" );
+ is( $obj->server, $server, "server($server)" );
+ is( $obj->port, "443", "port(443)" );
+}
+
+{ # expdate
+ my $obj = $package->new($driver);
+ my @exp = (
+
+ #OFF [qw(1999.8 0899)],
+ #OFF [qw(1984-11 1184)],
+ #OFF [qw(06/7 0706)],
+ #OFF [qw(06-12 1206)],
+ [qw(12/06 1206)],
+ [qw(6/2000 0600)],
+ [qw(10/2000 1000)],
+ [qw(1/99 0199)],
+ );
+ foreach my $aref (@exp) {
+ my ( $exp, $moyr ) = @$aref;
+ my ($mmyy) = $obj->expdate_mmyy($exp);
+ is( $mmyy, $moyr, "$exp: MMYY '$mmyy' eq '$moyr' from $exp" );
+ }
}
diff --git a/t/credit_card.t b/t/credit_card.t
index 108f859..efe6a26 100644
--- a/t/credit_card.t
+++ b/t/credit_card.t
@@ -9,7 +9,7 @@ use Business::OnlinePayment;
my $runinfo =
"to test set environment variables:"
- . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD;"
+ . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD and CLIENTCERTID (for X-VPS-VIT-CLIENT-CERTIFICATION-ID); "
. " (optional) PFPRO_PARTNER PFPRO_CERT_PATH";
plan(
@@ -19,9 +19,22 @@ plan(
);
my %opts = (
- "vendor" => $ENV{PFPRO_VENDOR},
- "partner" => $ENV{PFPRO_PARTNER} || "verisign",
- "cert_path" => $ENV{PFPRO_CERT_PATH} || ".",
+ "debug" => 0,
+ "vendor" => $ENV{PFPRO_VENDOR},
+ "partner" => $ENV{PFPRO_PARTNER} || "verisign",
+ ( $ENV{PFPRO_CERT_PATH} ? ( "cert_path" => $ENV{PFPRO_CERT_PATH} ) : () ),
+ (
+ $ENV{CLIENTCERTID} ? (
+ headers => {
+ "X-VPS-VIT-CLIENT-CERTIFICATION-ID" => $ENV{CLIENTCERTID},
+
+ # "X-VPS-REQUEST-ID" => $self->request_id(),
+ # "X-VPS-CLIENT-TIMEOUT" => , # default 45 seconds
+ # "X-VPS-VIT-CLIENT-DURATION" => , # commit request
+ }
+ )
+ : ()
+ ),
);
my %content = (
@@ -91,6 +104,7 @@ my %content = (
);
# IF first 3 chars of STREET >= 667 THEN AVSADDR == "X" (and AVSZIP="X")
+ $tx = new Business::OnlinePayment( "PayflowPro", %opts );
$tx->content( %content, "address" => "700 Any street" );
tx_check(
$tx,
@@ -104,6 +118,7 @@ my %content = (
);
# IF ZIP <= 50001 and >= 99999 THEN AVSZIP == "N"
+ $tx = new Business::OnlinePayment( "PayflowPro", %opts );
$tx->content( %content, "zip" => "99999" );
tx_check(
$tx,
@@ -117,6 +132,7 @@ my %content = (
);
# Both AVSADDR and AVSZIP == "N"
+ $tx = new Business::OnlinePayment( "PayflowPro", %opts );
$tx->content( %content, "address" => "500 Any street", "zip" => "99999" );
tx_check(
$tx,
@@ -147,6 +163,7 @@ my %content = (
);
# IF CVV2 >= 601 THEN CVV2MATCH == "X"
+ $tx = new Business::OnlinePayment( "PayflowPro", %opts );
$tx->content( %content, "cvv2" => "601" );
tx_check(
$tx,
@@ -167,13 +184,13 @@ sub tx_check {
$tx->test_transaction(1);
$tx->submit;
- is( $tx->is_success, $o{is_success}, $o{desc} . ": " . tx_info($tx) );
- is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
- like( $tx->order_number, qr/^\w{12}/, "order_number() / PNREF" );
+ is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) );
+ is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
is( $tx->error_message, $o{error_message}, "error_message() / RESPMSG" );
is( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" );
is( $tx->cvv2_code, $o{cvv2_code}, "cvv2_code() / CVV2MATCH" );
+ like( $tx->order_number, qr/^\w{12}/, "order_number() / PNREF" );
}
sub tx_info {
diff --git a/t/pod-coverage.t b/t/pod-coverage.t
new file mode 100644
index 0000000..e2715fd
--- /dev/null
+++ b/t/pod-coverage.t
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage"
+ if $@;
+all_pod_coverage_ok();