This file is indexed.

/usr/lib/interchange/Vend/Payment/MCVE.pm is in interchange 5.7.7-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# Vend::Payment::MCVE - Interchange MCVE support
#
# $Id: MCVE.pm,v 1.6 2009-03-16 19:34:01 jon Exp $
#
# Author: Tom Friedel (tom@readyink.com) for Carlc Internet Services (http://www.carlc.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA  02110-1301  USA.

package Vend::Payment::MCVE;

use vars qw($VERSION);
$VERSION = substr(q$Revision: 1.6 $, 10);

=head1 NAME

Vend::Payment::MCVE - Interchange MCVE support

=head1 SYNOPSIS

    &charge=mcve

	or

    [charge mode=mcve param1=value1 param2=value2]

	or

    mcve($mode, $opt);

=head1 PREREQUISITES

    MCVE.pm

The MCVE libraries are available free at http://www.mcve.com/

=head1 DESCRIPTION

MCVE, Mainstreet Credit Verification Engine is a high performance
software application designed to provide quality, in-house, Credit Card
processing FROM Linux, FreeBSD, OpenBSD, IBM AIX, Sun Solaris, SCO
OpenServer/UnixWare, and Mac OS X platforms to established clearing
houses.  The MCVE C & Perl library software can be downloaded free of charge
from http://mcve.com.  This module was developed and tested with the server 
software installed on HotConnect.net (http://www.hotconnect.net). 
Hot Connect, Inc. is an Interchange friendly Web Hosting, E-Commerce, and
Internet Services company.

The Vend::Payment::MCVE module implements the mcve() routine
for use with Interchange. It is compatible on a call level with the other
Interchange payment modules.

To enable this module, place this directive in C<interchange.cfg>:

    Require module Vend::Payment::MCVE

This I<must> be in interchange.cfg or a file included from it.

Make sure CreditCardAuto is off (default in Interchange demos).

The mode can be named anything, but the C<gateway> parameter must be set
to C<mcve>. To make it the default payment gateway for all credit
card transactions in a specific catalog, you can set in C<catalog.cfg>:

    Variable   MV_PAYMENT_MODE  mcve

It uses several of the standard settings from Interchange payment. Any time
we speak of a setting, it is obtained either first from the tag/call options,
then from an Interchange order Route named for the mode, then finally a
default global payment variable, For example, the C<id> parameter would
be specified by:

    [charge mode=mcve name=mcve_configname]

or

    Route mcve name mcve_configname

or 

    Variable MV_PAYMENT_NAME      mcve_configname

The active settings are:

    Variable   MV_PAYMENT_MODE mcve
    Variable   MV_PAYMENT_NAME mcve_username
    Variable   MV_PAYMENT_PASSWD mcve_password
    Variable   MV_PAYMENT_HOST sv1.carlc.com
    Variable   MV_PAYMENT_PORT 8333
    Variable   MV_PAYMENT_COUNTER etc/mcve_id.counter
    Variable   MV_PAYMENT_COUNTER_START 100
    Variable   MV_PAYMENT_SALE_ON_AUTH 1
    Variable   MV_PAYMENT_NO_SALE_BAD_AVS 0
    Variable   MV_PAYMENT_NO_SALE_BAD_CVV2 0
    Variable   MV_PAYMENT_SUCCESS_ON_ANY 0

=over 4

=item name

Your MCVE configuration username, set up when MCVE was configured/installed on
the machine. Global parameter is MV_PAYMENT_NAME.

=item no_sale_bad_avs

Normally Interchange charge modules do an authorization, and if successful, do a sale.
This module is configurable for a different models, where transactions are not
automatically saled.  

=item sale_on_auth

The storekeeper may not wish to sale a transaction if the AVS is bad.  

=item success_on_any

Alternatively the storekeeper may wish to cause any transaction to appear to be a
successful sale.  The storekeeper would have to contact buyers with bad credit card
information and manually redo the sale.  The motivation is to make sure no one
attempts a sale and gives up for any reason.   This mode of operation, set with
MV_PAYMENT_SUCCESS_ON_ANY is not commonly used.

=item transaction

The type of transaction to be run. Valid values are:

    Interchange mode    MCVE mode
    ----------------    -----------------
    auth                auth
    sale                sale

Not supported yet:

    return              return
    reverse             reverse
    void                void

=item counter, counter_start

Currently this is not being used, and Interchange is generating id's.

    Route   mcve  counter        etc/mcve_id.counter
    Route   mcve  counter_start  100

=back

=head2 Troubleshooting

Try the instructions above, with a test credit card number from your payment processor.

Then try a sale with the card number C<4111 1111 1111 1111>
and a valid expiration date. The sale should be denied, and the reason should
be in [data session payment_error].

If nothing works:

Make sure you "Require"d the module in interchange.cfg:

    Require module Vend::Payment::MCVE

Make sure MCVE is installed and working.

Check the error logs, both catalog and global.

Make sure you set your payment parameters properly.  

Try an order, then put this code in a page:

    [calc]
	$Tag->uneval( { ref => $Session->{payment_result} );
    [/calc]

That should show what happened.

=head1 BUGS

There is actually nothing *in* Vend::Payment::MCVE. It changes packages
to Vend::Payment and places things there.

=head1 AUTHORS

MCVE modifications by tom@readyink.com for Carlc Internet Services

=head1 CREDITS

Derived from CCVS.pm template, and others.

=cut

BEGIN {
	eval {
		package Vend::Payment;
        	require MVCE or die __PACKAGE__ . " requires MVCE";
		::logGlobal({}, "MCVE module found version %s", $MCVE::VERSION)
			unless $Vend::Quiet or ! $Global::VendRoot;
	};

	::logGlobal("%s payment module %s initialized", __PACKAGE__, $VERSION)
		unless $Vend::Quiet or ! $Global::VendRoot;
}

package Vend::Payment;

sub mcve {
    my ($opt) = @_;

#::logDebug("mcve called, args=" . ::uneval(\@_));

    my $sess;
    my %result;

    my $mcve_die = sub {
	my ($msg, @args) = @_;
	$msg = "MCVE: $msg" unless $msg =~ /^MCVE/;
	$msg = ::errmsg($msg, @args);
	&MCVE::done($sess) if $sess;
	::logDebug("mcve erred, result=$msg");
	die("$msg\n");
    };

    my $actual = $opt->{actual};
    if(! $actual) {
	my %actual = map_actual();
	$actual = \%actual;
    }

    if(! defined $opt->{precision} ) {
        $opt->{precision} = charge_param('precision');
    }

    my $exp = sprintf '%02d%02d',
    $actual->{mv_credit_card_exp_month},
    $actual->{mv_credit_card_exp_year};

    my $op = $opt->{transaction} || 'sale';

    my %type_map = (
	mauthcapture	=>	'sale',
	mauthonly	=>	'auth',
	mauthreturn	=>	'return',
	S		=>	'sale',
	C		=>	'auth',
	V		=>	'void',
	sale		=>	'sale',
	auth		=>	'auth',
	authorize	=>	'auth',
	void		=>	'void',
	delete		=>	'delete',
    );

    if (defined $type_map{$op}) {
        $op = $type_map{$op};
    }

    if(! $amount) {
        $amount = $opt->{total_cost} || 
	  Vend::Util::round_to_frac_digits(
					 Vend::Interpolate::total_cost(),
					   $opt->{precision},
					   );
    }

    my $invoice;

    unless ($invoice = $opt->{order_id}) {

	if($op ne 'auth' and $op ne 'sale') {
	    return $mcve_die->("must supply order ID for transaction type %s", $op);
	}

	my $file =  $opt->{"counter"} || charge_param('counter');
	$file = "etc/mcve_order.counter" if ! $file ;

	if ( open( FILE, $file  )) {
	    $orderID = <FILE> ;
	    close( FILE ) ;
	    chomp $orderID ;
	    $orderID ++ ;
	}
	else {
	    $orderID = $opt->{"counter_start"} || charge_param('counter_start') || 100 ;
	}

	if ( open( FILE, ">$file" )) {
	    print FILE "$orderID\n" ;
	    close( FILE ) ;
	}
	else {
	    return $mcve_die->("Could not create OrderID file $file");
	}
	$invoice = $orderID ;
    }

    $cvv2 = "" ;

    $configname =  $opt->{"name"} || charge_param('name');
    ::logDebug("mcve configuration name '$configname'");

    $mcve_id = $configname ;
    $mcve_pw = $opt->{"passwd"} || charge_param('passwd');
    ::logDebug("mcve configuration pw '$mcve_pw'");

    $host = $opt->{"host"} || charge_param('host');
    ::logDebug("mcve configuration host '$host'");

    $port = $opt->{"port"} || charge_param('port');
    ::logDebug("mcve configuration port '$port'");

    $host = "sv1.carlc.com" if ! $host ;
    $port = 8333 if ! $port ;

    $mcve_sale_on_auth = 1 ;
    $mcve_sale_on_auth = $opt{"sale_on_auth"} || charge_param('sale_on_auth') ;

    $mcve_no_sale_bad_avs = 0 ;
    $mcve_no_sale_bad_avs = $opt{"no_sale_bad_avs"} || charge_param('no_sale_bad_avs') ;

    $mcve_no_sale_bad_cvv2 = 0 ;
    $mcve_no_sale_bad_cvv2 = $opt{"no_sale_bad_cvv2"} || charge_param('no_sale_bad_cvv2') ;

    $mcve_success_on_any = 0 ;
    $mcve_success_on_any = $opt{"success_on_any"} || charge_param('success_on_any') ;

    $conn=MCVE::MCVE_InitConn();

    ::logDebug("Connected\n");

    &MCVE::MCVE_SetIP($conn, $host, $port);
    ::logDebug("Set IP\n");

    if ( &MCVE::MCVE_Connect($conn) == 0) {

	::logDebug("Count not Connect\n");

	&MCVE::MCVE_DestroyConn($conn);
	&MCVE::MCVE_DestroyEngine();
	return $mcve_die->("MCVE Connection Failed");
    }

    ::logDebug("Op = $op\n");

    if($op eq 'auth' or $op eq 'sale') {

	$cvv2 = "" ;
	$zip = $actual->{b_zip} ;
	$address = $actual->{"b_address"} ;

## These is specific to HotConnect MCVE implementation
	$comments = $actual->{"b_fname"} . " " . $actual->{"b_lname"} . "|" . $actual->{"b_address"} ;
	$clerkid = "" ;
	$stationid = 0 ;

	$text = "" ;
	$trackdata = "" ;
	$cardno = $actual->{"mv_credit_card_number"} ;

	::logDebug("Before PreAuth\n");

	$identifier=&MCVE::MCVE_PreAuth($conn, $mcve_id, $mcve_pw, $trackdata, $cardno, $exp, $amount, $address, $zip, $cvv2, $comments, $clerkid, $stationid, '');

	if ($identifier == MCVE::MCVE_ERROR()) {

	    ::logDebug("PreAuth Error\n");

	    &MCVE::MCVE_DestroyConn($conn);
	    &MCVE::MCVE_DestroyEngine();
	    return $mcve_die->("Error Making Transaction %s", $configname);
	}

	my $cnt = 0 ;
	while (&MCVE::MCVE_CheckStatus($conn, $identifier) != &MCVE::MCVE_DONE()) { # Wait until this transaction is done....
	    &MCVE::MCVE_Monitor($conn); # MCVE_Monitor does the actual background communication with the MCVE daemon via IP or SSL
	    sleep(1);		# Don't loop too fast :)
	    $cnt ++ ;
	    if ( $cnt == 100 ) {
		return $mcve_die->("CheckStatus Time Out %s", $configname);
	    }
	}

	$decline = 0 ;
	if (&MCVE::MCVE_ReturnStatus($conn, $identifier) == &MCVE::MCVE_SUCCESS()) {
	    $acode = MCVE::MCVE_TransactionAuth($conn, $identifier); #  Authorization Number
	    $sid = MCVE::MCVE_TransactionID($conn, $identifier); #  Authorization Number
	    $result{"pop.error_message"} = $result{"result_text"} = "success" ;
	    $result{"pop.auth-code"} = $acode ;
	} else {
	    $decline = 1 ;
	    $text = MCVE::MCVE_TransactionText($conn, $identifier);
	    $text = "Your card was declined ($text)" ;
	    $result{"pop.error_message"} = $result{"result_text"} = $text ;

	    my $msg = errmsg(
			     "MCVE error: %s %s. Please call in your order or try again.",
			     $result{MStatus},
			     $result{result_text},
			     );
	    $Vend::Session->{errors}{mv_credit_card_valid} = $msg;
	}


	$avs = MCVE::MCVE_TransactionAVS($conn, $identifier);
	$result{"pop.avs_code"} = $avs ;

	$cv = MCVE::MCVE_TransactionCV($conn, $identifier);

	if ( ! $decline && ( $op eq "sale" ) && $mcve_sale_on_auth ) {

## cv = -1 if not entered, 0 if bad, 1 if good
## avs = -1 if not entered, 0 if bad, 1 or 2 or 3 if address/zip match
	    if ((( $avs > 0 ) || ! $mcve_no_sale_bad_avs ) && (($cvv2 && ( $cv > 0 )) || ! $mcve_no_sale_bad_cvv2 )) {

		$identifier=&MCVE::MCVE_PreAuthCompletion($conn, $mcve_id, $mcve_pw, $amount, $sid, '' ) ;

		if ($identifier == MCVE::MCVE_ERROR()) {
		    &MCVE::MCVE_DestroyConn($conn);
		    &MCVE::MCVE_DestroyEngine();
		    return $mcve_die->("Error Forcing Transaction ($acode)");
		}

		while (&MCVE::MCVE_CheckStatus($conn, $identifier) != &MCVE::MCVE_DONE()) { # Wait until this transaction is done....
		    &MCVE::MCVE_Monitor($conn); # MCVE_Monitor does the actual background communication with the MCVE daemon via IP or SSL
		    sleep(1);	# Don't loop too fast :)
		}

		if (&MCVE::MCVE_ReturnStatus($conn, $identifier) == &MCVE::MCVE_SUCCESS()) {
#		$text .= "AVS Response = $avs - CV Response = $cv" ;
		    $decline = 0 ;
		} else {
		    $decline = 1 ;
		    $text= "Force: " . &MCVE::MCVE_TransactionText($conn, $identifier);
		}
	    }

	}

	$result{"order-id"} =  $result{"pop.order-id"} = $invoice ;

	if ( $mcve_success_on_any ) {
	    $decline = 0 ;
	}

	# If everything was succesful, push through the sale.
	if (! $decline) {
	    $result{'pop.status'} =	    $result{MStatus} = 'success';
	    $result{'invoice'} = $invoice;
	}
	else  {			#decline
	    $result{MStatus} = 'failed';
	    my $msg = errmsg(
			     "MCVE error: %s %s. Please call in your order or try again.",
			     $result{MStatus},
			     $result{result_text},
			     );
	    $Vend::Session->{errors}{mv_credit_card_valid} = $msg;
	}
    }

    &MCVE::MCVE_DestroyConn($conn);
    &MCVE::MCVE_DestroyEngine();

#::logDebug("mcve returns, result=" . ::uneval(\%result));
    return %result;
}

package Vend::Payment::MCVE;

1;