Source for file LinkPoint.php
Documentation is available at LinkPoint.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Joe Stump <joe@joestump.net> |
// +----------------------------------------------------------------------+
// $Id: LinkPoint.php,v 1.11 2005/08/11 00:18:52 jstump Exp $
require_once('Payment/Process.php');
require_once('Payment/Process/Common.php');
require_once('Net/Curl.php');
require_once('XML/Parser.php');
$GLOBALS['_Payment_Process_LinkPoint'] = array (
* Payment_Process_LinkPoint
* This is a processor for LinkPoint's merchant payment gateway.
* (http://www.linkpoint.net/)
* This is BETA code, and has not been fully tested. It is not recommended
* that you use it in a production envorinment without further testing.
* @package Payment_Process
* @author Joe Stump <joe@joestump.net>
* Front-end -> back-end field map.
* This array contains the mapping from front-end fields (defined in
* the Payment_Process class) to the field names DPILink requires.
'invoiceNumber' => 'oid',
'customerId' => 'x_cust_id',
'amount' => 'chargetotal',
* @author Joe Stump <joe@joestump.net>
'cardNumber' => 'cardnumber',
'routingCode' => 'routing',
'accountNumber' => 'account',
'driversLicense' => 'dl',
'driversLicenseState' => 'dlstate'
* Default options for this processor.
* @see Payment_Process::setOptions()
var $_defaultOptions = array (
'host' => 'secure.linkpt.net',
* Has the transaction been processed?
* The response body sent back from the gateway.
* @param array $options Class options to set.
* @see Payment_Process::setOptions()
$this->_driver = 'LinkPoint';
* Process the transaction.
* @return mixed Payment_Process_Result on success, PEAR_Error on failure
if (!strlen($this->_options['keyfile']) ||
return PEAR ::raiseError ('Invalid key file');
if (PEAR ::isError ($result)) {
$result = $this->_prepare ();
if (PEAR ::isError ($result)) {
// Don't die partway through
PEAR ::pushErrorHandling (PEAR_ERROR_RETURN );
$xml = $this->_prepareQueryString ();
if (PEAR ::isError ($xml)) {
$url = 'https://'. $this->_options['host']. ':'. $this->_options['port'].
$curl = & new Net_Curl ($url);
if (PEAR ::isError ($curl)) {
PEAR ::popErrorHandling ();
$curl->sslCert = $this->_options['keyfile'];
$curl->userAgent = 'PEAR Payment_Process_LinkPoint 0.1';
$result = &$curl->execute ();
if (PEAR ::isError ($result)) {
PEAR ::popErrorHandling ();
$this->_responseBody = trim($result);
$this->_processed = true;
// Restore error handling
PEAR ::popErrorHandling ();
if (!PEAR ::isError ($response)) {
* Prepare the POST query string.
* @return string The query string
function _prepareQueryString ()
$xml = '<!-- Payment_Process order -->'. "\n";
$xml .= '<merchantinfo>'. "\n";
$xml .= ' <configfile>'. $data['configfile']. '</configfile>'. "\n";
$xml .= ' <keyfile>'. $data['keyfile']. '</keyfile>'. "\n";
$xml .= ' <host>'. $data['authorizeUri']. '</host>'. "\n";
$xml .= ' <appname>PEAR Payment_Process</appname>'. "\n";
$xml .= '</merchantinfo>'. "\n";
$xml .= '<orderoptions>'. "\n";
$xml .= ' <ordertype>'. $data['ordertype']. '</ordertype>'. "\n";
$xml .= ' <result>'. $data['result']. '</result>'. "\n";
$xml .= '</orderoptions>'. "\n";
$xml .= '<payment>'. "\n";
$xml .= ' <subtotal>'. $data['chargetotal']. '</subtotal>'. "\n";
$xml .= ' <tax>0.00</tax>'. "\n";
$xml .= ' <shipping>0.00</shipping>'. "\n";
$xml .= ' <chargetotal>'. $data['chargetotal']. '</chargetotal>'. "\n";
$xml .= '</payment>'. "\n";
// Set payment method to eCheck if our payment type is eCheck.
// Default is Credit Card.
$data['x_method'] = 'CC';
return PEAR ::raiseError ('eCheck not currently supported',
$xml .= '<telecheck>'. "\n";
$xml .= ' <routing></routing>'. "\n";
$xml .= ' <account></account>'. "\n";
$xml .= ' <checknumber></checknumber>'. "\n";
$xml .= ' <bankname></bankname>'. "\n";
$xml .= ' <bankstate></bankstate>'. "\n";
$xml .= ' <dl></dl>'. "\n";
$xml .= ' <dlstate></dlstate>'. "\n";
$xml .= ' <accounttype>pc|ps|bc|bs</accounttype>'. "\n";
$xml .= '<telecheck>'. "\n";
$xml .= '<creditcard>'. "\n";
$xml .= ' <cardnumber>'. $data['cardnumber']. '</cardnumber>'. "\n";
list ($month,$year) = explode('/',$data['expDate']);
$xml .= ' <cardexpmonth>'. $month. '</cardexpmonth>'. "\n";
$xml .= ' <cardexpyear>'. $year. '</cardexpyear>'. "\n";
$xml .= ' <cvmvalue>'. $data['cvm']. '</cvmvalue>'. "\n";
$xml .= ' <cvmindicator>provided</cvmindicator>'. "\n";
$xml .= '</creditcard>'. "\n";
if (isset ($this->_payment->firstName ) &&
$xml .= '<billing>'. "\n";
$xml .= ' <userid>'. $this->_payment->customerId. '</userid>'. "\n";
$xml .= ' <name>'. $this->_payment->firstName. ' '. $this->_payment->lastName. '</name>'. "\n";
$xml .= ' <company>'. $this->_payment->company. '</company>'. "\n";
$xml .= ' <address1>'. $this->_payment->address. '</address1>'. "\n";
$xml .= ' <city>'. $this->_payment->city. '</city>'. "\n";
$xml .= ' <state>'. $this->_payment->state. '</state>'. "\n";
$xml .= ' <zip>'. $this->_payment->zip. '</zip>'. "\n";
$xml .= ' <country>'. $this->_payment->country. '</country>'. "\n";
$xml .= ' <phone>'. $this->_payment->phone. '</phone>'. "\n";
$xml .= ' <email>'. $this->_payment->email. '</email>'. "\n";
$xml .= ' <addrnum>'. $this->_payment->address. '</addrnum>'. "\n";
$xml .= '</billing>'. "\n";
var $_statusCodeMap = array ('APPROVED' => PAYMENT_PROCESS_RESULT_APPROVED ,
'DECLINED' => PAYMENT_PROCESS_RESULT_DECLINED ,
'FRAUD' => PAYMENT_PROCESS_RESULT_FRAUD );
* This array holds many of the common response codes. There are over 200
* response codes - so check the LinkPoint manual if you get a status
* code that does not match (see "Response Reason Codes & Response
* Reason Text" in the AIM manual).
var $_statusCodeMessages = array (
'APPROVED' => 'This transaction has been approved.',
'DECLINED' => 'This transaction has been declined.',
'FRAUD' => 'This transaction has been determined to be fraud.');
var $_avsCodeMap = array (
'YY' => PAYMENT_PROCESS_AVS_MATCH ,
'YN' => PAYMENT_PROCESS_AVS_MISMATCH ,
'YX' => PAYMENT_PROCESS_AVS_ERROR ,
'NY' => PAYMENT_PROCESS_AVS_MISMATCH ,
'XY' => PAYMENT_PROCESS_AVS_MISMATCH ,
'NN' => PAYMENT_PROCESS_AVS_MISMATCH ,
'NX' => PAYMENT_PROCESS_AVS_MISMATCH ,
'XN' => PAYMENT_PROCESS_AVS_MISMATCH ,
'XX' => PAYMENT_PROCESS_AVS_ERROR
var $_avsCodeMessages = array (
'YY' => 'Address matches, zip code matches',
'YN' => 'Address matches, zip code does not match',
'YX' => 'Address matches, zip code comparison not available',
'NY' => 'Address does not match, zip code matches',
'XY' => 'Address comparison not available, zip code matches',
'NN' => 'Address comparison does not match, zip code does not match',
'NX' => 'Address does not match, zip code comparison not available',
'XN' => 'Address comparison not available, zip code does not match',
'XX' => 'Address comparison not available, zip code comparison not available'
var $_cvvCodeMap = array ('M' => PAYMENT_PROCESS_CVV_MATCH ,
'N' => PAYMENT_PROCESS_CVV_MISMATCH ,
'P' => PAYMENT_PROCESS_CVV_ERROR ,
'S' => PAYMENT_PROCESS_CVV_ERROR ,
'U' => PAYMENT_PROCESS_CVV_ERROR ,
'X' => PAYMENT_PROCESS_CVV_ERROR
var $_cvvCodeMessages = array (
'M' => 'Card Code Match',
'N' => 'Card code does not match',
'S' => 'Merchant has indicated that the card code is not present on the card',
'U' => 'Issuer is not certified and/or has not proivded encryption keys',
'X' => 'No response from the credit card association was received'
var $_fieldMap = array ('r_approved' => 'code',
'r_code' => 'approvalCode',
'r_ordernum' => 'transactionId'
$this->Payment_Process_Response ($rawResponse);
* @author Joe Stump <joe@joestump.net>
$xml->parseString ('<response>'. $this->_rawResponse. '</response>');
$this->_mapFields ($xml->response );
// switch to DECLINED since a duplicate isn't *really* fraud
* Payment_Processor_LinkPoint_XML_Parser
* XML Parser for the LinkPoint response
* @author Joe Stump <joe@joestump.net>
* @package Payment_Process
Documentation generated on Mon, 11 Mar 2019 14:15:59 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|