I’m trying to create a custom payment gateway the redirects to Chase paymentech DPP. I have the module working up until I reach the gateway when I receieve this error message:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:ws.paymentech.net/PaymentechGateway">
<SOAP-ENV:Body id="_0">
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode>SOAP-ENV:VersionMismatch</faultcode>
<faultstring>SOAP version mismatch or invalid SOAP message</faultstring>
<SOAP-ENV:Code/>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I’m not sure if its to do with formatting the form to post in the correct format i.e XML so would like to ask for some advice on how to post values in the correct format
This is my form named redirect.phtml which redirects to the payment gateway.
<?php
$session = Mage::getSingleton('checkout/session');
$orderIncrementId = $session->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$billingaddress = $order->getBillingAddress();
$shippingaddress = $order->getShippingAddress();
$currencyDesc = Mage::app()->getStore()->getCurrentCurrencyCode();
$totals = number_format($order->getGrandTotal(), 2, '.', '');
$address = $billingaddress->getStreet();
$address1 = $shippingaddress->getStreet();
$data = array(
'api_username' => trim(Mage::getStoreConfig('payment/redirect/api_username')),
'api_password' => trim(Mage::getStoreConfig('payment/redirect/api_password')),
'Merchant_ID' => trim(Mage::getStoreConfig('payment/redirect/Merchant_ID')),
'Terminal_ID' => trim(Mage::getStoreConfig('payment/redirect/Terminal_ID')),
'BIN_Number' => trim(Mage::getStoreConfig('payment/redirect/BIN_Number')),
'Amount' => $totals,
'billing_cust_name' =>$order->getCustomerFirstname(),
'billing_last_name'=>$order->getCustomerLastname(),
'billing_cust_tel_No' => $billingaddress->getTelephone(),
'billing_cust_email'=>$order->getCustomerEmail(),
'billing_cust_address'=>$address[0] . ' '.$address[1],
'billing_cust_city'=>$billingaddress->getCity(),
'billing_cust_country'=>$billingaddress->getCountryId(),
'billing_cust_state'=>$billingaddress->getRegion(),
'billing_cust_zip' =>$billingaddress->getPostcode(),
'delivery_cust_name' =>$shippingaddress->getCustomerFirstname(),
'delivery_last_name'=>$shippingaddress->getCustomerLastname(),
'delivery_cust_tel_No' => $shippingaddress->getTelephone(),
'delivery_cust_email'=>$shippingaddress->getCustomerEmail(),
'delivery_cust_address'=>$address1[0] . ' '.$address1[1],
'delivery_cust_city'=>$shippingaddress->getCity(),
'delivery_cust_country'=>$shippingaddress->getCountryId(),
'delivery_cust_state'=>$shippingaddress->getRegion(),
'delivery_cust_zip' =>$shippingaddress->getPostcode(),
'Order_Id' => $order->getIncrementId(),
'TxnType' => 'A',
'actionID' => 'TXN',
'Currency' => 'GBP',
);
?>
<form action="https://wsvar.paymentech.net/PaymentechGateway" method="post" id="chase">
<?php foreach($data as $key => $value): ?>
<input type='hidden' name='<?php echo $key?>' value='<?php echo $value;?>' />
<?php endforeach;?>
<input type="submit" class="btn btn-success btn-large" value='Complete my order!'/>
</form>
<?php echo $this->__('If Page Doesn\'t Redirect In 5 Sectonds, Please press Buy button');?>
<script type="text/javascript">
function myfunc () {
var frm = document.getElementById("chase");
frm.submit();
}
window.onload = myfunc;
</script>
Standard.php
<?php
class Custom_Gateway_Model_Standard extends Mage_Payment_Model_Method_Abstract {
protected $_code = 'chase';
protected $_isInitializeNeeded = true;
protected $_canUseInternal = true;
protected $_canUseForMultishipping = false;
public function getOrderPlaceRedirectUrl() {
return Mage::getUrl('chase/payment/redirect', array('_secure' => true));
}
//create xml and send info to gateway
private function callApi(Varien_Object $payment, $amount,$type){
//call your authorize api here, incase of error throw exception.
//only example code written below to show flow of code
$order = $payment->getOrder();
$types = Mage::getSingleton('payment/config')->getCcTypes();
if (isset($types[$payment->getCcType()])) {
$type = $types[$payment->getCcType()];
}
$billingaddress = $order->getBillingAddress();
$totals = number_format($amount, 2, '.', '');
$orderId = $order->getIncrementId();
$currencyDesc = $order->getBaseCurrencyCode();
$url = $this->getConfigData('gateway_url');
$fields = array(
'api_username'=> $this->getConfigData('api_username'),
'api_password'=> $this->getConfigData('api_password'),
'Merchant_ID'=> $this->getConfigData('Merchant_ID'),
'Terminal_ID'=> $this->getConfigData('Terminal_ID'),
'BIN_Number'=> $this->getConfigData('BIN_Number'),
'customer_firstname'=> $billingaddress->getData('firstname'),
'customer_lastname'=> $billingaddress->getData('lastname'),
'customer_phone'=> $billingaddress->getData('telephone'),
'customer_email'=> $billingaddress->getData('email'),
'customer_ipaddress'=> $_SERVER['REMOTE_ADDR'],
'bill_firstname'=> $billingaddress->getData('firstname'),
'bill_lastname'=> $billingaddress->getData('lastname'),
'Bill_address1'=> $billingaddress->getData('street'),
'bill_city'=> $billingaddress->getData('city'),
'bill_country'=> $billingaddress->getData('country_id'),
'bill_state'=> $billingaddress->getData('region'),
'bill_zip'=> $billingaddress->getData('postcode'),
'customer_cc_expmo'=> $payment->getCcExpMonth(),
'customer_cc_expyr'=> $payment->getCcExpYear(),
'customer_cc_number'=> $payment->getCcNumber(),
'customer_cc_type'=> strtoupper($type),
'customer_cc_cvc'=> $payment->getCcCid(),
'merchant_ref_number'=> $order->getIncrementId(),
'currencydesc'=>$currencyDesc,
'amount'=>$totals
);
$fields_string="";
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
$fields_string = substr($fields_string,0,-1);
//open connection
$ch = curl_init($url);
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // Timeout on connect (2 minutes)
//execute post
$result = curl_exec($ch);
curl_close($ch);
return array('status'=>1,'transaction_id' => time() , 'fraud' => rand(0,1));
}
}
?>
Authorize.php
protected function _getTransactionDetails($transactionId)
{
$requestBody = sprintf(
'<?xml version="1.0" encoding="utf-8"?>'
. '<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'
. '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>'
. '<transId>%s</transId>'
. '</getTransactionDetailsRequest>',
$this->getConfigData('login'),
$this->getConfigData('trans_key'),
$transactionId
);
$client = new Varien_Http_Client();
$uri = $this->getConfigData('cgi_url_td');
$client->setUri($uri ? $uri : self::CGI_URL_TD);
$client->setConfig(array('timeout'=>45));
$client->setHeaders(array('Content-Type: text/xml'));
$client->setMethod(Zend_Http_Client::POST);
$client->setRawData($requestBody);
$debugData = array('request' => $requestBody);
try {
$responseBody = $client->request()->getBody();
$debugData['result'] = $responseBody;
$this->_debug($debugData);
libxml_use_internal_errors(true);
$responseXmlDocument = new Varien_Simplexml_Element($responseBody);
libxml_use_internal_errors(false);
} catch (Exception $e) {
Mage::throwException(Mage::helper('paygate')->__('Payment updating error.'));
}
$response = new Varien_Object;
$response
->setResponseCode((string)$responseXmlDocument->transaction->responseCode)
->setResponseReasonCode((string)$responseXmlDocument->transaction->responseReasonCode)
->setTransactionStatus((string)$responseXmlDocument->transaction->transactionStatus)
;
return $response;
}
Thanks in advance
To my knowledge you should only use one of these method (and not both), because they represent two different type of gateway.
What I would recommend is start over (i am not sure what ‘Standard.php’ and ‘Authorize.php’ does) using this example http://www.excellencemagentoblog.com/magento-create-custom-payment-method-api-based and make changes to
callApiAlso take a look of
protected function _postRequest(Varien_Object $request)protected function _buildRequest(Varien_Object $payment)In