![]() |
![]() |
|
Configure Protx Direct UK/EU Version
To use the 3D Secure you need to change the code in the GBU_OLP.php file for the function protx3dauth to: // +------------------------------------------------------------------+
// | Function: protx3dauth |
// +------------------------------------------------------------------+
function protx3dauth () {
// +--
// | This function processes handles Protx Direct 3D Auth.
// | functions and initiates proper order processing functions.
// +--
$orderid = $this->globals('khxc_cgi.orderid');
if (empty($orderid)) {
if ($this->debug) {$this->debugger("protx3dauth: Problem encountered processing internal gateway request. Returning to checkout.");}
$this->print_message($this->app,'genericolperr');
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// +--
// | Now look up the order and handle errors.
// +--
$order = $this->exec_namespace(array('app' => $this->app,
'namespace' => 'orderlookup',
'type' => '*',
'params' => $orderid));
if ($this->IsError($order)) {
if ($this->debug) {$this->debugger("protx3dauth: Error returned while looking up order. Returning to checkout.");}
$this->print_message($this->app,'genericolperr');
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// +--
// | Ensure the Protx Direct gateway is active.
// +--
$table = $this->app . '_gateway';
$where = 'id=' . $this->KHXC_DB->quote('protxdirect') . ' AND ';
$where .= 'active=' . $this->KHXC_DB->quote(1);
$count = $this->KHXC_DB->sql_count(array('table' => $table,
'where' => $where));
if (($this->IsError($count)) || (empty($count))) {
if ($this->debug) {$this->debugger("protx3dauth: Requested processing module is not activated. Returning to checkout.");}
$this->print_message($this->app,'genericolperr');
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// +--
// | Handle off the order information to the gateway object
// | for processing.
// +--
$reqok = 1;
$protxdata = '';
$cgi = array('gwurl' => 1,
'MD' => 1,
'PaRes' => 1,
'cardtype' => 0,
'expirydate' => 0);
foreach ($cgi as $name => $num) {
$cgivalue = $this->globals('khxc_cgi.' . $name);
if (isset($cgivalue)) {
$cgi[$name] = $cgivalue;
if ($name != 'gwurl') {
// The Protx Data does not have the gateway url
if (($name == 'ExpiryDate') || ($name == 'StartDate')) {
// Remove / in date
$cgivalue = preg_replace('/\//','',$cgivalue);
}
}
if ((empty($cgivalue)) && (!($cgivalue === 0)) && (!(empty($num)))) {$reqok = 0;if ($this->debug) {$this->debugger("protx3dauth: Missing Required field '{$name}' '{$num}'.");}}
} else {
$cgi[$name] = '';
if (!(empty($num))) {$reqok = 0;if ($this->debug) {$this->debugger("protx3dauth: Missing Required field '{$name}' '{$num}'.");}}
} // End of if statement.
} // End of foreach statement.
// +--
// | Handle required fields.
// +--
if (empty($reqok)) {
$this->print_message($this->app,'reqnotcompgen');
if ($this->debug) {$this->debugger("protx3dauth: Required fields not completed.");}
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// Set-up Protx Data
$protxdata = 'MD=' . $cgi['MD'] . '&PARes=' . $cgi['PaRes'];
/// Figure out which URL to sed this 3D Callback Request To.
if ((preg_match('/VSPSimulator/',$cgi['gwurl']))) {
// Simulator
$callbackurl = 'https://ukvpstest.protx.com/VSPSimulator/direct3dcallback.vsp';
} elseif ((preg_match('/ukvpstest.protx.com/',$cgi['gwurl']))) {
// Test
$callbackurl = 'https://ukvpstest.protx.com/vspgateway/service/direct3dcallback.vsp';
} else {
// Live
$callbackurl = 'https://ukvps.protx.com/vspgateway/service/direct3dcallback.vsp';
}
// +--
// | Build the request.
// +--
$result = $this->KHXC_Remote->exec(array('url' => $callbackurl,
'type' => 'POST',
'mode' => 'HTTPS',
'data' => $protxdata,
'referer' => $callbackurl));
if (($this->IsError($result)) || (empty($result))) {
$this->print_message($this->app,'genericolperr');
if ($this->debug) {$this->debugger("protx3dauth: Trouble communicating with processor.");}
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// Remove 3DSecureStatus
if ($this->debug) {$this->debugger("protx3dauth: Result '{$result}'.");}
$result = preg_replace('/3DSecureStatus=/','',$result);
if ($this->debug) {$this->debugger("protx3dauth: Result1 '{$result}'.");}
$result_code = 'FAIL';
if (preg_match('/Status=OK/',$result)) {
$result_code = 'OK';
}
if (empty($result_code)) {$result_code = 'FAIL';}
$validrc = $this->make_list($order['gateway']['validrc']);
$validrc = array_flip($validrc);
if (!(array_key_exists($result_code,$validrc))) {
$this->print_message($this->app,'olpdecline');
if ($this->debug) {$this->debugger("protx3dauth: Processor declined transaction with code: {$result_code}.");}
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statemenet.
// +--
// | Update the Protx Direct.
// +--
$resultarray = preg_split("/[\s]+/", $result);
if ($this->debug) {$this->debugger("validate: Result Array." . print_r($resultarray,1));}
foreach ($resultarray as $id => $data) {
if (preg_match('/VPSTxId=/',$data)) {
$VPSTxId = preg_replace('/VPSTxId=/','',$data);
$order['order']['vpstxid'] = $VPSTxId;
if ($this->debug) {$this->debugger("validate:VPSTxId {$VPSTxId}.");}
} // End of if statemenet.
if (preg_match('/SecurityKey=/',$data)) {
$SecurityKey = preg_replace('/SecurityKey=/','',$data);
$order['order']['securitykey'] = $SecurityKey;
if ($this->debug) {$this->debugger("validate:SecurityKey {$SecurityKey}.");}
} // End of if statemenet.
if (preg_match('/TxAuthNo=/',$data)) {
$TxAuthNo = preg_replace('/TxAuthNo=/','',$data);
$order['order']['txauthno'] = $TxAuthNo;
if ($this->debug) {$this->debugger("validate:TxAuthNo {$TxAuthNo}.");}
} // End of if statemenet.
}// End of foreach statemenet.
$order['order']['cardtype'] = $cgi['cardtype'];
$order['order']['expirydate'] = $cgi['expirydate'];
// +--
// | Return true if we were able to process this order.
// +--
$result = true;
if ($this->debug) {$this->debugger("protx3dauth: Processed order.");}
// +--
// | If we received an empty result we need to go back to the
// | checkout page. Messages would have already been printed.
// +--
if (empty($result)) {
// +--
// | Remove the processor selection and any tokens from the
// | cosess var.
// +--
$cosess = $this->globals('khxc_session.' . $this->app . '.cosess');
if (empty($cosess)) {$cosess = array();}
if (!(is_array($cosess))) {$cosess = array();}
$cosess['gateway_select'] = '';
$cosess['gateway_token'] = '';
$this->KHXC_Session->sessvalues($this->app . '.cosess',$cosess);
// +--
// | Log to the debugger and return to checkout.
// +--
if ($this->debug) {$this->debugger("protx3dauth: Received bad response. Returning to checkout.");}
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'checkout',
'type' => '*',
'params' => null));
} // End of if statement.
// +--
// | At this point we've got a valid response code and a copy of the order.
// | Print a confirmation message and direct to the order processing namespace.
// +--
$this->print_message($this->app,'olpaccept');
// +--
// | Return an instance of the order processing namespace.
// +--
return $this->exec_namespace(array('app' => $this->app,
'namespace' => 'orderprocess',
'type' => '*',
'params' => $order));
} // End of function.CategoryPaymentGateways |
||
![]() |
|
![]() |
There are 847 comments on this page. [Display comments]