[interchange-cvs] interchange - jon modified
lib/Vend/Payment/Linkpoint.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Fri Feb 18 23:00:15 EST 2005
User: jon
Date: 2005-02-19 04:00:14 GMT
Modified: lib/Vend/Payment Linkpoint.pm
Log:
Updates to the Linkpoint payment module from Ron Phipps
<rphipps at reliant-solutions.com>. His comments:
I have fixed up Linkpoint.pm to be compatible with the new Linkpoint
Perl API (v6.0). This is not backwards compatible with Linkpoint Perl
API (v5.4.1). Linkpoint users are being forced to upgrade by Feb 28
2005.
There are a few outstanding issues in this module. First the latest API
release from Linkpoint has an issue with the "scompany" and "saddress1"
fields. Neither one of these will show up in Linkpoint Central. The
suggested fix is to send Shipping Address Line 1 and Shipping Address
Line 2 in the "saddress2" field. Once the API is fixed we will need to
remove this kludge from the payment module, there currently is no public
time frame for when this will happen. The Shipping Company is currently
being sent in "scompany" and once they fix the API it will show up
properly in Linkpoint Central.
The other issue is that the new Perl API allows you to call two
different methods to contact linkpoint. You can either call it this
way:
my %result = $lperl->curl_process(\%query);
This uses curl to process the request. Or you can call it this way:
my %result = $lperl->process(\%query);
This uses shared ssl libraries (liblperl.so and liblpssl.so).
The curl method just worked out of the box for me so that's the method
that is in use in Linkpoint.pm.
Revision Changes Path
1.3 +82 -87 interchange/lib/Vend/Payment/Linkpoint.pm
rev 1.3, prev_rev 1.2
Index: Linkpoint.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Payment/Linkpoint.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- Linkpoint.pm 7 Jun 2004 20:59:18 -0000 1.2
+++ Linkpoint.pm 19 Feb 2005 04:00:14 -0000 1.3
@@ -1,6 +1,6 @@
# Vend::Payment::Linkpoint - Interchange Linkpoint support
#
-# $Id: Linkpoint.pm,v 1.2 2004/06/07 20:59:18 mheins Exp $
+# $Id: Linkpoint.pm,v 1.3 2005/02/19 04:00:14 jon Exp $
#
# Copyright (C) 2002 Stefan Hornburg (Racke) <racke at linuxia.de>
#
@@ -73,9 +73,9 @@
or
- Variable LINKPOINT_ID YourLinkpointID
+ Variable MV_PAYMENT_ID YourLinkpointID
-Required settings are C<host>, C<keyfile> and C<bin>.
+Required settings are C<id> and C<keyfile>.
The active settings are:
@@ -83,7 +83,8 @@
=item host
-Your LinkPoint Secure Payment Gateway (LSPG) hostname. Usually secure.linkpt.net (production) or staging.linkpt.net (testing).
+Your LinkPoint Secure Payment Gateway (LSPG) hostname. Usually
+secure.linkpt.net (production) or staging.linkpt.net (testing).
=item keyfile
@@ -91,11 +92,6 @@
RSA private key and the certificate, otherwise you get an error like
"Unable to open/parse client certificate file."
-=item bin
-
-File name of the LinkPoint binary. You get an "Unknown error" if you
-specify another executable.
-
=item id
Store number assigned to your merchant account.
@@ -127,16 +123,21 @@
=item *
-Make sure LPERL is installed and working. You can test to see
+Make sure lpperl (v3.0.012+) is installed and working. You can test to see
whether your Perl thinks they are:
- perl -MLPERL -e 'print "It works.\n"'
+ perl -Mlpperl -e 'print "It works.\n"'
If it "It works." and returns to the prompt you should be OK (presuming
they are in working order otherwise).
=item *
+Make sure curl is installed and working. Lpperl uses curl to contact
+Linkpoint.
+
+=item *
+
Check the error logs, both catalog and global.
=item *
@@ -168,17 +169,18 @@
=head1 AUTHOR
Stefan Hornburg (Racke) <racke at linuxia.de>
+Ron Phipps <rphipps at reliant-solutions.com>
=cut
BEGIN {
eval {
package Vend::Payment;
- require LPERL or die __PACKAGE__ . " requires LPERL";
+ require lpperl or die __PACKAGE__ . " requires LPPERL";
};
if ($@) {
- $msg = __PACKAGE__ . ' requires LPERL';
+ $msg = __PACKAGE__ . ' requires LPPERL';
::logGlobal ($msg);
die $msg;
}
@@ -194,12 +196,13 @@
my $opt;
my $keyfile;
+ my $host;
if(ref $user) {
$opt = $user;
$user = $opt->{id} || undef;
$keyfile = $opt->{keyfile} || undef;
- $bin = $opt->{bin} || undef;
+ $host = $opt->{host} || undef;
}
else {
$opt = {};
@@ -215,8 +218,9 @@
}
#::logDebug("actual map result: " . ::uneval($actual));
+#::logDebug("opt map result: " . ::uneval($opt));
- # we need to check for customer id, keyfile and binary
+ # we need to check for customer id and keyfile
# location, as these are the required parameters
if (! $user ) {
@@ -234,31 +238,13 @@
MErrMsg => errmsg('No certificate file'),
);
}
-
- if (! $bin ) {
- $bin = charge_param('bin')
- or return (
- MStatus => 'failure-hard',
- MErrMsg => errmsg('No LinkPoint binary'),
- );
- }
-
- unless (-x $bin) {
- return (
- MStatus => 'failure-hard',
- MErrMsg => errmsg('LinkPoint binary not executable'),
- );
- }
- unless ($opt->{host}) {
- $opt->{host} = charge_param('host') || 'secure.linkpt.net';
+ if (! $host ) {
+ $host = charge_param('host') || 'secure.linkpt.net';
}
-
- my $precision = $opt->{precision} || 2;
- my $referer = $opt->{referer}
- || charge_param('referer');
+ my $precision = $opt->{precision} || 2;
$actual->{mv_credit_card_exp_month} =~ s/\D//g;
$actual->{mv_credit_card_exp_year} =~ s/\D//g;
@@ -272,11 +258,11 @@
my $transtype = $opt->{transaction} || charge_param('transaction') || 'sale';
my %type_map = (
- auth => 'preauth',
- authorize => 'preauth',
- mauthcapture => 'sale',
- mauthonly => 'preauth',
- sale => 'sale',
+ auth => 'PREAUTH',
+ authorize => 'PREAUTH',
+ mauthcapture => 'SALE',
+ mauthonly => 'PREAUTH',
+ sale => 'SALE',
);
if (defined $type_map{$transtype}) {
@@ -289,53 +275,68 @@
$amount = Vend::Interpolate::total_cost();
$amount = Vend::Util::round_to_frac_digits($amount,$precision);
}
- $amount =~ s/\D//g;
+
+ $amount =~ s/\D//g;
$amount = int ($amount / 100) . '.' . ($amount % 100);
$shipping = Vend::Interpolate::tag_shipping();
$subtotal = Vend::Interpolate::subtotal();
$salestax = Vend::Interpolate::salestax();
$order_id = gen_order_id($opt);
+
+ my $addrnum = $actual->{b_address1};
+ my $bcompany = $Values->{b_company};
+ my $scompany = $Values->{company};
+
+ $addrnum =~ s/^(\d+).*$//g;
+ $scompany =~ s/\&/ /g;
+ $bcompany =~ s/\&/ /g;
my %varmap = ( qw /
- baddr1 b_address1
- baddr2 b_address2
- bcity b_city
- bcountry b_country
- bname b_name
- bstate b_state
- bzip b_zip
+ name b_name
+ address1 b_address1
+ address2 b_address2
+ city b_city
+ state b_state
+ zip b_zip
+ country b_country
email email
phone phone_day
- saddr1 address1
- saddr2 address2
- scity city
- scountry country
sname name
+ saddress1 address1
+ saddress2 address2
+ scity city
sstate state
szip zip
+ scountry country
/ );
my %query =
- (hostname => $opt->{host},
- port => '1139',
- storename => $user,
- keyfile => $keyfile,
+ (host => $host,
+ port => '1129',
+ configfile => $user,
+ keyfile => $keyfile,
+ result => 'LIVE',
+ terminaltype => 'UNSPECIFIED',
shipping => $shipping,
chargetotal => $amount,
subtotal => $subtotal,
tax => $salestax,
- cardnumber => $actual->{mv_credit_card_number},
- expmonth => sprintf ("%02d", $actual->{mv_credit_card_exp_month}),
- expyear => sprintf ("%02d", $actual->{mv_credit_card_exp_year}),
- bcompany => $Values->{company},
- scompany => $Values->{company},
- debuglevel => $opt->{debuglevel},
+ vattax => '0.00',
+ cardnumber => $actual->{mv_credit_card_number},
+ cardexpmonth => sprintf ("%02d", $actual->{mv_credit_card_exp_month}),
+ cardexpyear => sprintf ("%02d", $actual->{mv_credit_card_exp_year}),
+ addrnum => $addrnum,
+ debbugging => $opt->{debuglevel},
+ company => $bcompany,
+ scompany => $scompany, # API is broken for Shipping Company per Linkpoint support
);
- for (keys %varmap) {
+ for (keys %varmap) {
$query{$_} = $actual->{$varmap{$_}};
}
+
+ $query{saddress2} = $actual->{address1} . ' ' . $actual->{address2}; # API is broken for Shipping Address Line 1, put line 1 and line 2 in API line 2 per Linkpoint support
# delete query keys with undefined values
for (keys %query) {
@@ -344,28 +345,18 @@
#::logDebug("linkpoint query: " . ::uneval(\%query));
- my $tempfile = "$Vend::Cfg->{ScratchDir}/linkpoint.$order_id";
- my $lperl = new LPERL($bin, "FILE", $tempfile);
-
- my %result;
+ my $lperl = new LPPERL();
- if ($transtype eq 'preauth') {
- %result = $lperl -> CapturePayment (\%query);
- } elsif ($transtype eq 'sale') {
- %result = $lperl->ApproveSale(\%query);
- } else {
- return (
- MStatus => 'failure-hard',
- MErrMsg => errmsg('Unrecognized transaction: %s', $transtype),
- );
- }
+ my %result = $lperl->curl_process(\%query);
# Interchange names are on the left, Linkpoint on the right
my %result_map = ( qw/
- order-id neworderID
- pop.order-id neworderID
- pop.auth-code code
- pop.avs_code AVSCode
+ order-id r_ordernum
+ pop.order-id r_ordernum
+ pop.auth-code r_code
+ pop.avs_code r_avs
+ pop.status r_code
+ pop.error-message r_error
/
);
@@ -376,12 +367,16 @@
if defined $result{$result_map{$_}};
}
- if ($result{statusCode}) {
- $result{MStatus} = 'success';
- }
- else {
+ if ($result{'r_approved'} eq "APPROVED") {
+ $result{'MStatus'} = 'success';
+ $result{'MErrMsg'} = $result{'r_code'};
+ } else {
+ my $msg = errmsg("Charge error: %s Please call in your order or try again.",
+ $result{'r_error'},
+ );
+
$result{MStatus} = 'failure';
- $result{MErrMsg} = $result{statusMessage} || 'Unknown error';
+ $result{MErrMsg} = $msg;
}
#::logDebug("result given to interchange " . ::uneval(\%result));
More information about the interchange-cvs
mailing list