| 1 | #!/usr/bin/perl | ||
| 2 | use Data::Dumper; | ||
| 3 | use Business::OnlinePayment; | ||
| 4 | $\ = "\n"; | ||
| 5 | |||
| 6 | # This script is used to run a series of prescribed transactions, in order to certify the application | ||
| 7 | |||
| 8 | $login = {'login' => '...', # info for test account | ||
| 9 | 'password' => '...', | ||
| 10 | 'serial' => '...', | ||
| 11 | }; | ||
| 12 | |||
| 13 | $cards = { | ||
| 14 | 'visa' => {'cc' => '4003000123456781', | ||
| 15 | 'exp' => '10/04', | ||
| 16 | }, | ||
| 17 | 'mastercard' => {'cc' => '5454545454545454', | ||
| 18 | 'exp' => '08/04', | ||
| 19 | }, | ||
| 20 | 'amex' => {'cc' => '371449635398431', | ||
| 21 | 'exp' => '05/12', | ||
| 22 | }, | ||
| 23 | 'discover' => {'cc' => '6011901165142939', | ||
| 24 | 'exp' => '01/05', | ||
| 25 | }, | ||
| 26 | 'diners' => {'cc' => '36438999960016', | ||
| 27 | 'exp' => '05/12', | ||
| 28 | }, | ||
| 29 | 'jcb' => {'cc' => '3566002020360224', | ||
| 30 | 'exp' => '10/04', | ||
| 31 | }, | ||
| 32 | }; | ||
| 33 | |||
| 34 | @tests = ( | ||
| 35 | { | ||
| 36 | 'action' => 'Normal Authorization', | ||
| 37 | 'entry_method' => 'Swipe', | ||
| 38 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 39 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 40 | 'amount' => '1.31', | ||
| 41 | }, | ||
| 42 | { | ||
| 43 | 'action' => 'Normal Authorization', | ||
| 44 | 'entry_method' => 'Manual', | ||
| 45 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 46 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 47 | 'amount' => '1.32', | ||
| 48 | 'cvv2' => '412', | ||
| 49 | 'street' => '652', | ||
| 50 | }, | ||
| 51 | { | ||
| 52 | 'action' => 'Normal Authorization', | ||
| 53 | 'entry_method' => 'Swipe', | ||
| 54 | 'card_number' => $cards->{'mastercard'}->{'cc'}, | ||
| 55 | 'expiration' => $cards->{'mastercard'}->{'exp'}, | ||
| 56 | 'amount' => '1.33', | ||
| 57 | }, | ||
| 58 | { | ||
| 59 | 'action' => 'Normal Authorization', | ||
| 60 | 'entry_method' => 'Manual', | ||
| 61 | 'card_number' => $cards->{'amex'}->{'cc'}, | ||
| 62 | 'expiration' => $cards->{'amex'}->{'exp'}, | ||
| 63 | 'amount' => '1.34', | ||
| 64 | 'street' => '1234', | ||
| 65 | 'zip' => '35289', | ||
| 66 | }, | ||
| 67 | { | ||
| 68 | 'action' => 'Normal Authorization', | ||
| 69 | 'entry_method' => 'Manual', | ||
| 70 | 'card_number' => $cards->{'diners'}->{'cc'}, | ||
| 71 | 'expiration' => $cards->{'diners'}->{'exp'}, | ||
| 72 | 'amount' => '1.35', | ||
| 73 | }, | ||
| 74 | { | ||
| 75 | 'action' => 'Credit', | ||
| 76 | 'entry_method' => 'Swipe', | ||
| 77 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 78 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 79 | 'amount' => '1.36', | ||
| 80 | }, | ||
| 81 | { | ||
| 82 | 'action' => 'Credit', | ||
| 83 | 'entry_method' => 'Manual', | ||
| 84 | 'card_number' => $cards->{'amex'}->{'cc'}, | ||
| 85 | 'expiration' => $cards->{'amex'}->{'exp'}, | ||
| 86 | 'amount' => '1.37', | ||
| 87 | 'street' => '62347', | ||
| 88 | 'zip' => '3A45E2', # weird, but ok... | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | 'action' => 'Credit', | ||
| 92 | 'entry_method' => 'Swipe', | ||
| 93 | 'card_number' => $cards->{'discover'}->{'cc'}, | ||
| 94 | 'expiration' => $cards->{'discover'}->{'exp'}, | ||
| 95 | 'amount' => '1.38', | ||
| 96 | }, | ||
| 97 | { | ||
| 98 | 'action' => 'Void', | ||
| 99 | 'entry_method' => 'Swipe', | ||
| 100 | 'card_number' => $cards->{'discover'}->{'cc'}, | ||
| 101 | 'expiration' => $cards->{'discover'}->{'exp'}, | ||
| 102 | 'amount' => '1.38', | ||
| 103 | }, | ||
| 104 | { | ||
| 105 | 'action' => 'Post Authorization', | ||
| 106 | 'entry_method' => 'Swipe', | ||
| 107 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 108 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 109 | 'amount' => '1.39', | ||
| 110 | 'authorization' => 'AE34BH', | ||
| 111 | }, | ||
| 112 | { | ||
| 113 | 'action' => 'Post Authorization', | ||
| 114 | 'entry_method' => 'Manual', | ||
| 115 | 'card_number' => $cards->{'amex'}->{'cc'}, | ||
| 116 | 'expiration' => $cards->{'amex'}->{'exp'}, | ||
| 117 | 'amount' => '1.40', | ||
| 118 | 'authorization' => '112233', | ||
| 119 | }, | ||
| 120 | { | ||
| 121 | 'action' => 'Void', | ||
| 122 | 'entry_method' => 'Manual', | ||
| 123 | 'card_number' => $cards->{'amex'}->{'cc'}, | ||
| 124 | 'expiration' => $cards->{'amex'}->{'exp'}, | ||
| 125 | 'amount' => '1.40', | ||
| 126 | 'authorization' => '112233', | ||
| 127 | }, | ||
| 128 | { | ||
| 129 | 'action' => 'Authorization Only', | ||
| 130 | 'entry_method' => 'Swipe', | ||
| 131 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 132 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 133 | 'amount' => '0.00', | ||
| 134 | 'authorization' => '', | ||
| 135 | 'cvv2' => '', | ||
| 136 | 'street' => '', | ||
| 137 | 'zip' => '', | ||
| 138 | }, | ||
| 139 | { | ||
| 140 | 'action' => 'Authorization Only', | ||
| 141 | 'entry_method' => 'Manual', | ||
| 142 | 'card_number' => $cards->{'mastercard'}->{'cc'}, | ||
| 143 | 'expiration' => $cards->{'mastercard'}->{'exp'}, | ||
| 144 | 'amount' => '1.41', | ||
| 145 | 'cvv2' => '843', | ||
| 146 | }, | ||
| 147 | { | ||
| 148 | 'action' => 'Normal Authorization', | ||
| 149 | 'entry_method' => 'Swipe', | ||
| 150 | 'card_number' => $cards->{'visa'}->{'cc'}, | ||
| 151 | 'expiration' => $cards->{'visa'}->{'exp'}, | ||
| 152 | 'amount' => '14120.49', | ||
| 153 | }, | ||
| 154 | ); | ||
| 155 | |||
| 156 | $time = localtime; | ||
| 157 | print $time; | ||
| 158 | |||
| 159 | LOOP: | ||
| 160 | foreach $test (@tests) | ||
| 161 | { | ||
| 162 | # print '----------' | ||
| 163 | |||
| 164 | my $tx = new Business::OnlinePayment("iAuthorizer"); | ||
| 165 | $test->{'entry_method'} = 'Manual'; | ||
| 166 | |||
| 167 | $tx->content(%{$test}, %{$login}); | ||
| 168 | $tx->submit(); | ||
| 169 | |||
| 170 | # unless($tx->is_success) # uncomment for some debug output | ||
| 171 | # { | ||
| 172 | # print Dumper($test); | ||
| 173 | # print Dumper({$tx->content()}); | ||
| 174 | # print $tx->server_response(); | ||
| 175 | # print $tx->error_message(); | ||
| 176 | # } | ||
| 177 | # else | ||
| 178 | # { | ||
| 179 | print $tx->server_response(); | ||
| 180 | # } | ||
| 181 | } | ||
| 182 | |||
| 183 | $time = localtime; | ||
| 184 | print $time; | ||
| 185 |