Magento: Configuring Orbital Chase Paymentech Gateway

May 23, 2009 15:52 by Rafeek

Magento Commerce, is a direct response to the emerging new needs of today's online merchants. More than any feature or functionality what our clients really needs is "flexibility" is done through the magento.

We have a lot of payment gateways today to integrate with our e-commerce application. Here we see how to integrate one of the leading Gateway providers CHASE Payment Tech Gateway with Magento Commerce.

 

1. Creating CHASE Payment Module

The CHASE Payment Module is included as Magento Commerce Extension, by using Magento Module Creator. Using Module Creator the Payment Module template for both Administrator and Client Section will get added.

Magento Module Creator Orbital Chase Paymentech Gateway

The module will get created and integrated into our existing magento site by specifying the parameters properly as mentioned above. The parameters are Name Space, Module, Magento Root Directory, Design Interface and Design.

 

1.1 Installing Module Creator

In order to download, visit Module Creator page in Magento Wiki.

After dowloading, to install the Module Creator, copy the index.php file into a Blank folder on your webserver. You have to put it in it’s own folder so that the index file does not conflict with other index files. Example: mysite.com/module_creator/

Open the module creator index page in your web browser, and fill in the desired module information. If you enter your Magento directory, the module creator will attempt to install the module directly into Magento, so file permissions must be set correctly for this to happen. If your file permissions are incorrect, or you do not want the module installed right away, you can leave the Magento Directory blank, and the module creator will create the module in a folder called 'new', and place it under module creator’s folder.

Please note that if you enter in your magento directory to install to you must have the correct path. Let’s say that you have Magento installed here:
http://www.my_site.com/magento/
And you have the Module Creator installed here:
http://www.my_site.com/module_creator/
This means that the path that you would need to enter in the Module Creator is this:
../magento
The ‘..’ signifies one directory up.

The new payment gateway gets installed in the /App/Core/Code/local folder with default folder right permission without disturbing the existing payment gateways. 

For more information on Module Creator visit,
http://www.magentocommerce.com/wiki/custom_module_with_custom_database_table

Note:
Once the new payment module installed properly, go to the /var/cache folder and delete all the files inside the folder and then run the application, now the new changes get reflected.

 

2. CHASE Module in Administrator Section

Now we will add the Chase Paymentech Module to the administration section, so that we can update the Merchant ID, Terminal ID and Gateway URL as seen in the below screen.

The fields configured in administration section can be customized in the system.xml file located at the /App/Core/Code/Local/Mage/newmodule/etc folder.

Magento Orbital Chase Paymentech Configuration

 

3. CHASE Module in Client Section

After the payment module is integrated in the Magento application using the Module Creator, the Orbtiz Chase Module on the Client Section will look like in the below screen.

Client section Payment Information fields can be modified directly at, App/design/frontend/default/example-module/template/payment/form/cc.phtml

 

4. Payment Processing with CHASE

Once the Chase module payment process is integrated in the client section, the paymentmethod.php will do the backend process like checking the card details by sending to the Chase Paymentech and return the response from the Chase.

The paymentmethod.php is located in the new module created by Module Creator, at /app/local/CHASE_Paymentech/Orbitz/Model/PaymentMethod.php,

You can download the code from the below link.

PaymentMethod.zip (2.95 kb)

The PHP code will explain you the process of reading the card information from the payment page and post it to the Chase using the payment gateway and receive the response back from the Chase.

 

4.1. Specifing the Payment Gateway URL

In the code we are using CURL to receive payment gateway response so we need to enable the extension=php_curl.dll in php.ini. Update the php.ini as per the requirement and restart the server.

Payment Gateway URL for Production –
'https://orbital1.paymentech.net'
'https://orbital2.paymentech.net'
 
Payment Gateway URL for Test –
'https://orbitalvar2.paymentech.net/authorize'

$value = Mage::getStoreConfig('payment/ Orbitz_Paymentech/cgi_url');
if (!$value || $value === false) {
  return 'https://orbital1.paymentech.net';
}
return $value;

The Authorize and Capture event is done on the each order process. The Credit Card is get processed the specified amount sent as XML Request. The xml request was constructed as below,

$xml="";
$xml .= "";
$xml .= "";
$xml .= "EC";
$xml .= "AC";
$xml .= "".htmlentities(trim($this->getConfigData('bin_no')),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($this->getConfigData('merchant_id')),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($this->getConfigData('terminal_id')),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($payment->getCcType()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($payment->getCcNumber()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($exp),ENT_QUOTES, 'UTF-8')."";
if(($payment->getCcType()=='VI') || ($payment->getCcType()=='DI')) {
  $xml .= "1";
}
$xml .= "".htmlentities(trim($payment->getCcCid()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($billing->getPostcode()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($billing->getStreet(1)),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($billing->getCity()),ENT_QUOTES, 'UTF-8')."";
$xml .= "CA";
$xml .= "".htmlentities(trim($billing->getFirstname()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($order->getIncrementId()),ENT_QUOTES, 'UTF-8')."";
$xml .= "".htmlentities(trim($amt),ENT_QUOTES, 'UTF-8')."";
$xml .= "AC";
$xml .= "";
$xml .= "";
$xml .= "";

The request is sent as CURL post to Chase is as follows,

$http = new Varien_Http_Adapter_Curl();
$config = array('timeout' => 30);
$http->setConfig($config);

$header= "POST /AUTHORIZE HTTP/1.0\r\n"; // HTTP/1.1 should work fine also
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-type: application/PTI40\r\n";
$header.= "Content-length: " .strlen($xml) . "\r\n";
$header.= "Content-transfer-encoding: text\r\n";
$header.= "Request-number: 1\r\n";
$header.= "Document-type: Request\r\n";
$header.= "Interface-Version: Test 1.4\r\n";
$header.= "Connection: close \r\n\r\n";
$header.= $xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$this->getApiGatewayUrl());
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

The Chase response will get parsed from xml to array format and validate the response by each parameter as per the Chase Certification_WS document.

Chase will request you the code to scrutinize before approval. They will look through the parameters that you are sending in the Request, and how you are parsing their Response & its error codes.

 


Comments

buddytoupsjr.com January 28. 2010 21:31
Pingback from buddytoupsjr.com

Bookmarks for January 28th from 15:00 to 15:00 | Buddy's Blog
pingback

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading