Skip to content

Commit

Permalink
Linkpoint: Add CVV capability, and partial pay_cert payments
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 1e104ad
Author: Josh Lavin <josh@perusion.com>
Date:   Fri Aug 28 14:18:28 2009 -0500

    Fix typo, reinstate support for shipping/salestax/subtotal

    Do better regex check on CVV; fix typo in 'message'; send shipping/salestax/subtotal normally, unless using a pay_cert for part of the order, in which case don't send any shipping etc data, since totals would not balance. Update copyright, remove $id.

commit bd343eb
Author: Josh Lavin <josh@perusion.com>
Date:   Thu Aug 27 14:54:40 2009 -0500

    Add CVV capability, and partial pay_cert payments.

    Added CVV support, which needs the check_sub to work. The example check_sub succeeds if either AVS or CVV matches or is unknown. Removed shipping, subtotal and tax values, since they cause orders partially paid with a pay_cert to fail. Added cargs option for curl arguments (I have to use -k [insecure] with my test cert).
  • Loading branch information
Josh Lavin authored and jonjensen committed Aug 29, 2009
1 parent 02589c9 commit d6bfd0f
Showing 1 changed file with 45 additions and 22 deletions.
67 changes: 45 additions & 22 deletions lib/Vend/Payment/Linkpoint.pm
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Vend::Payment::Linkpoint - Interchange Linkpoint support
#
# $Id: Linkpoint.pm,v 1.13 2009-03-16 19:34:01 jon Exp $
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 2002-2009 Interchange Development Group
# Copyright (C) 2002 Stefan Hornburg (Racke) <racke@linuxia.de>
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -101,8 +99,9 @@ The type of transaction to be run. Valid values are:
Interchange Linkpoint
---------------- -----------------
auth preauth
sale sale
auth PREAUTH
sale SALE
settle_prior POSTAUTH
Default is C<sale>.
Expand All @@ -114,34 +113,41 @@ passed into the subroutine, and it should return true (in the Perl truth
sense) if its checks were successful, or false if not.
This can come in handy since LinkPoint has no option to decline a charge
when AVS data come back negative.
when AVS or CVV data come back negative.
If you want to fail based on a bad AVS check, make sure you're only
If you want to fail based on a bad AVS/CVV check, make sure you're only
doing an auth -- B<not a sale>, or your customers would get charged on
orders that fail the AVS check and never get logged in your system!
orders that fail the AVS/CVV check and never get logged in your system!
Add the parameters like this:
Route linkpoint check_sub avs_check
Route linkpoint check_sub link_check
This is a matching sample subroutine you could put in interchange.cfg:
GlobalSub <<EOR
sub avs_check {
sub link_check {
my ($result) = @_;
my $avs = $result->{r_avs};
my ($addr, $zip) = split m{}, $avs;
my ($addr, $zip, $nothing, $cvv) = split m{}, $avs;
#::logDebug("avs=$avs, addr=$addr zip=$zip banks=$nothing cvv=$cvv");
return 1 if $addr eq 'Y' or $zip eq 'Y';
return 1 if $addr eq 'X' and $zip eq 'X';
return 1 if $cvv =~ /^[MPSUX]$/;
$result->{MStatus} = 'failure';
$result->{r_error} = $result->{MErrMsg} = "The billing address you entered does not match the cardholder's billing address";
return 0;
if ($cvv eq 'N' || '') {
$result->{r_error} = "The card security code you entered does not match. Additional failed attempts may hold your available funds.";
}
else {
$result->{r_error} = "The billing address you entered does not match the cardholder's billing address. Additional failed attempts may hold your available funds.";
}
}
EOR
That would work equally well as a Sub in catalog.cfg. It will succeed if
either the address or zip is 'Y', or if both are unknown. If it fails,
it sets the error message in the result hash.
either the address or zip is 'Y', or if both are unknown, or if the CVV
matches or is unknown. If it fails, it sets the error message in the
result hash.
Of course you can use this sub to do any other post-processing you
want as well.
Expand Down Expand Up @@ -322,9 +328,16 @@ sub linkpoint {
$amount = Vend::Util::round_to_frac_digits($amount,$precision);
}

$shipping = Vend::Interpolate::tag_shipping();
$subtotal = Vend::Interpolate::subtotal();
$salestax = Vend::Interpolate::salestax();
if($Values->{use_pay_cert}) {
$shipping = '';
$subtotal = '';
$salestax = '';
}
else {
$shipping = Vend::Interpolate::tag_shipping();
$subtotal = Vend::Interpolate::subtotal();
$salestax = Vend::Interpolate::salestax();
}
$order_id = gen_order_id($opt);

my $addrnum = $actual->{b_address1};
Expand All @@ -334,6 +347,11 @@ sub linkpoint {
$addrnum =~ s/^(\d+).*$//g;
$scompany =~ s/\&/ /g;
$bcompany =~ s/\&/ /g;

my $cvmindicator = 'not_provided';
if($actual->{cvv2} || $actual->{mv_credit_card_cvv2}) {
$cvmindicator = 'provided';
}

my %check_transaction = ( PREAUTH => 1, SALE => 1 );

Expand All @@ -348,6 +366,8 @@ sub linkpoint {
cardexpmonth
cardexpyear
addrnum
cvmvalue
cvmindicator
company
)
],
Expand Down Expand Up @@ -389,7 +409,10 @@ sub linkpoint {
cardexpmonth => sprintf ("%02d", $actual->{mv_credit_card_exp_month}),
cardexpyear => sprintf ("%02d", $actual->{mv_credit_card_exp_year}),
addrnum => $addrnum,
debbugging => $opt->{debuglevel},
cvmvalue => $actual->{cvv2} || $actual->{mv_credit_card_cvv2},
cvmindicator => $cvmindicator,
debugging => $opt->{debuglevel},
cargs => $opt->{curl_args},
company => $bcompany,
scompany => $scompany, # API is broken for Shipping Company per Linkpoint support
oid => $order_id,
Expand Down Expand Up @@ -425,7 +448,7 @@ sub linkpoint {
pop.auth-code r_code
pop.avs_code r_avs
pop.status r_code
pop.error-message r_error
pop.error-message r_error
/
);

Expand Down Expand Up @@ -467,7 +490,7 @@ sub linkpoint {
);

$result{MStatus} = 'failure';
$result{MErrMsg} = $msg;
$result{MErrMsg} = $result{'pop.error-message'} = $msg;
}

#::logDebug("result given to interchange " . ::uneval(\%result));
Expand Down

0 comments on commit d6bfd0f

Please sign in to comment.