#!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); use Test::More; use Business::OnlinePayment; my $runinfo = "to test set environment variables:" . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD;" . " (optional) PFPRO_PARTNER PFPRO_CERT_PATH"; plan( ( $ENV{"PFPRO_USER"} && $ENV{"PFPRO_VENDOR"} && $ENV{"PFPRO_PWD"} ) ? ( tests => 2 ) : ( skip_all => $runinfo ) ); my %opts = ( "vendor" => $ENV{PFPRO_VENDOR}, "partner" => $ENV{PFPRO_PARTNER} || "verisign", "cert_path" => $ENV{PFPRO_CERT_PATH} || ".", ); 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 ); { # 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) ); } { # 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, ")", ) ); }