projects
/
Business-OnlinePayment-PayflowPro.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
46e8e58
)
- updated to Test::More
author
plobbes
<plobbes>
Tue, 16 Jan 2007 02:39:21 +0000
(
02:39
+0000)
committer
plobbes
<plobbes>
Tue, 16 Jan 2007 02:39:21 +0000
(
02:39
+0000)
- updated %content to get one success and one failure test case
- incorporated test from (now removed) bad_auth.t
t/credit_card.t
patch
|
blob
|
history
diff --git
a/t/credit_card.t
b/t/credit_card.t
index
6ba927d
..
7b57484
100644
(file)
--- a/
t/credit_card.t
+++ b/
t/credit_card.t
@@
-1,48
+1,79
@@
-BEGIN { $| = 1; print "1..1\n"; }
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use POSIX qw(strftime);
+use Test::More;
use Business::OnlinePayment;
use Business::OnlinePayment;
-die "set environment variables to test: PFPRO_USER, PFPRO_VENDOR, PFPRO_PWD, ".
- "and optionally PFPRO_PARTNER and PFPRO_CERT_PATH\n"
- unless $ENV{'PFPRO_USER'} && $ENV{'PFPRO_VENDOR'} && $ENV{'PFPRO_PWD'};
+my $runinfo =
+ "to test set environment variables:"
+ . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD;"
+ . " (optional) PFPRO_PARTNER PFPRO_CERT_PATH";
-my $tx = new Business::OnlinePayment("PayflowPro",
- 'vendor' => $ENV{PFPRO_VENDOR} ,
- 'partner' => ( $ENV{PFPRO_PARTNER} || 'verisign' ),
- 'cert_path' => ( $ENV{PFPRO_CERT_PATH} || '.' ) ,
+plan(
+ ( $ENV{"PFPRO_USER"} && $ENV{"PFPRO_VENDOR"} && $ENV{"PFPRO_PWD"} )
+ ? ( tests => 2 )
+ : ( skip_all => $runinfo )
);
);
-$tx->content(
- type => 'VISA',
- login => $ENV{'PFPRO_USER'},
- password => $ENV{'PFPRO_PWD'},
- action => 'Normal Authorization',
- description => 'Business::OnlinePayment::PayflowPro visa test',
- amount => '0.01',
- first_name => 'Tofu',
- last_name => 'Beast',
- address => '123 Anystreet',
- city => 'Anywhere',
- state => 'UT',
- zip => '84058',
- country => 'US',
- email => 'ivan-payflowpro@420.am',
- #card_number => '4007000000027',
- card_number => '4111111111111111',
- expiration => '12/2009',
+my %opts = (
+ "vendor" => $ENV{PFPRO_VENDOR},
+ "partner" => $ENV{PFPRO_PARTNER} || "verisign",
+ "cert_path" => $ENV{PFPRO_CERT_PATH} || ".",
);
);
-$tx->test_transaction(1);
+my %content = (
+ type => "VISA",
+ login => $ENV{"PFPRO_USER"},
+ password => $ENV{"PFPRO_PWD"},
+ action => "Normal Authorization",
+ description => "Business::OnlinePayment::PayflowPro test",
+ amount => "0.01",
+ first_name => "Tofu",
+ last_name => "Beast",
+ address => "123 Anystreet",
+ city => "Anywhere",
+ state => "GA",
+ zip => "30004",
+ country => "US",
+ email => 'ivan-payflowpro@420.am',
+ expiration => "12/" . strftime( "%y", localtime ),
+ cvv2 => "123",
+
+ #card_number specified in test case
+);
-$tx->submit();
+{ # valid card number test
+ my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
+ $tx->content( %content, card_number => "4111111111111111" );
+ $tx->test_transaction(1);
+ $tx->submit;
+ is( $tx->is_success, 1, "valid card num: " . tx_info($tx) );
+}
-if($tx->is_success()) {
- print "ok 1\n";
- $auth = $tx->authorization;
- warn "********* $auth ***********\n";
-} else {
- print "not ok 1\n";
- warn '***** '. $tx->error_message. " *****\n";
- exit;
+{ # invalid card number test
+ my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
+ $tx->content( %content, card_number => "4111111111111112" );
+ $tx->test_transaction(1);
+ $tx->submit;
+ is( $tx->is_success, 0, "invalid card num: " . tx_info($tx) );
}
}
+sub tx_info {
+ my $tx = shift;
+
+ no warnings 'uninitialized';
+
+ return (
+ join( "",
+ "order_number(", $tx->order_number, ")",
+ " error_message(", $tx->error_message, ")",
+ " result_code(", $tx->result_code, ")",
+ " auth_info(", $tx->authorization, ")",
+ " avs_code(", $tx->avs_code, ")",
+ " cvv2_code(", $tx->cvv2_code, ")",
+ )
+ );
+}