Magento PayPal Advance Iframe Missing AVS CVV2 Data


Magento does not save AVS data or Credit Card Type with the PayPal Advance Iframe. So with the PayPal debug mode enabled you can grab this data in the Payment debug function.
This function is _debug and it is located around line 689 in
app/code/core/Mage/Payment/Model/Method/Abstract.php


Using this function you can grab all the PayPal Advance data and store it. The data is stored in $debugData['response']. So if you are looking for the credit card type, you could grab it with this variable $debugData['response']['CARDTYPE'].


Example PayPal Advance Return Data


The Steps:

  • Copy app/code/core/Mage/Payment/Model/Method/Abstract.php
  • Paste app/code/local/Mage/Payment/Model/Method/Abstract.php
  • Replace the function protected function _debug($debugData) {...} with the version below.


/*
This function is located around line 689 in
app/code/core/Mage/Payment/Model/Method/Abstract.php
Copy that to your local
app/code/local/Mage/Payment/Model/Method/Abstract.php


*/
protected function _debug($debugData)
    {
	if(isset($debugData['response'])
			&& isset($debugData['response']['ACCT'])
			&& isset($debugData['response']['CARDTYPE'])
			)
		{
		$last4 = $debugData['response']['ACCT']; 
		$cc = $debugData['response']['CARDTYPE']; 
		$AVSADDR = 'X';
		if(isset($debugData['response']['AVSADDR']))
			{
			$AVSADDR = $debugData['response']['AVSADDR'];
			}
		$AVSZIP = 'X';
		if(isset($debugData['response']['AVSZIP']))
			{
			$AVSZIP = $debugData['response']['AVSZIP'];
			}
		$CVV2MATCH = 'X';
		if(isset($debugData['response']['CVV2MATCH']))
			{
			$CVV2MATCH = $debugData['response']['CVV2MATCH'];
			}
		$IAVS = 'X';
		if(isset($debugData['response']['IAVS']))
			{
			$IAVS = $debugData['response']['IAVS'];
			}
		$AVSDATA = 'X';
		if(isset($debugData['response']['AVSDATA']))
			{
			$AVSDATA = $debugData['response']['AVSDATA'];
			}
		switch($cc) 
			{
			case 0: 
				$cc_type="Visa";
				break; 
			case 1: 
				$cc_type="Mastercard"; 
				break; 
			case 2: 
				$cc_type="Discover"; 
				break; 
			case 3: 
				$cc_type="American Express"; 
				break; 
			} 
		$avdSerialized["lastfour"] = $last4;
		$avdSerialized["cc_num"] = $cc;
		$avdSerialized["cc_type"] = $cc_type;
		$avdSerialized["cvv2"] = $CVV2MATCH;
		$avdSerialized["avszip"] = $AVSZIP;
		$avdSerialized["avsaddr"] = $AVSADDR;
		$avdSerialized["iavs"] = $IAVS;
		$avdSerialized = serialize($avdSerialized);
		
		$resource = Mage::getSingleton('core/resource'); 
		$writeConnection = $resource->getConnection('core_write');

		$order = Mage::getModel('sales/order')->loadByIncrementId($INVNUM);
		$order_id = $order->getEntityId();
		$query = "UPDATE sales_flat_order_payment 
					SET cc_last4 = '".$last4."'
						,cc_type = '".$cc_type."' 
						,cc_avs_status = '".$AVSDATA."' 
						,cc_debug_response_serialized = '".$avdSerialized."'
					WHERE parent_id = ".(int)$order_id; 
		$writeConnection->query($query);
		
		}
	
	// This is Original Code 
	if ($this->getDebugFlag()) 
		{
		Mage::getModel('core/log_adapter', 'payment_' . $this->getCode() . '.log')
		   ->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
		   ->log($debugData);
	
		}
    }

Comments (0)


( ! ) Notice: Undefined index: id in /home/www/www.image-maps.com/pages/page_blog.php on line 54 Call Stack #TimeMemoryFunctionLocation 10.0003295048{main}( ).../temp_blog.php:0 20.6576602456include( '/home/www/www.image-maps.com/pages/page_blog.php' ).../temp_blog.php:575 "> amit - 2014-09-19 06:56:40

thank you so much giving information



Post a Comment


*Email:
 
*Name:
 
URL:
 
*Comment: