summaryrefslogtreecommitdiff
path: root/t/transaction_nocvv.t
blob: 625c01dca299bf96d3bb7c7ce75f8053a995d8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl

use strict;
use warnings;
use POSIX qw(strftime);
use Test::More;
use Business::OnlinePayment;
require "t/lib/test_account.pl";

my %opts = test_account('card');

if (!$opts{'login'} || !$opts{'password'}) {
  plan skip_all => "no test credentials provided; fill out t/lib/test_account.pl to test communication with the gateway.",
  1;
  exit(0);
}

plan tests => 2;

###
# Purchase
###
my %content = (
    login          => delete($opts{'login'}),
    password       => delete($opts{'password'}),
    action         => 'Normal Authorization',
    description    => 'Business::OnlinePayment visa test',
    card_number    => '4111111111111111',
    expiration     => expiration_date(),
    amount         => '24.42',
    name           => 'Murphy Law',
    email          => 'fake@acme.com',
    address        => '123 Anystreet',
    zip            => '84058',
);

my $tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );

$tx->content( %content );

$tx->test_transaction(1);

$tx->submit;

is( $tx->is_success, 1, 'purchase' )
  or diag('Gateway error: '. $tx->error_message);

###
# Refund
###
my $auth = $tx->authorization;
$tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );
$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;