Jump to content

Recommended Posts

I am trying to record a part of this string. Should I format this some other way?

 

1,1,1,some text here,ABCD,Y,55678759949,FGRTUD  <<<string

$split = explode(',', $xml->directResponse[6]);
$txnid = $split[6];

$txnid should equal '55678759949' but it doesn't like that format for some reason. If I put $txnid ="1234"; my page will save it with that value.

 

Link to comment
https://forums.phpfreaks.com/topic/276296-help-using-explode/
Share on other sites

Thanks Actually the string comes from a XML reply

<directResponse>1,1,1,some text here,ABCD,Y,55678759949,FGRTUD</directResponse>

 

If I echo $xml->directResponse   I will get 1,1,1,some text here,ABCD,Y,55678759949,FGRTUD

 

I need $txnid to hold the value of 55678759949

Link to comment
https://forums.phpfreaks.com/topic/276296-help-using-explode/#findComment-1421838
Share on other sites

$split = explode(',', $xml->directResponse[6]);
$txnid = $split[6];

echo $txnid;  //I don't need to echo it.

I tried that also tried this. I need to assign the value to $txnid. If I hard code a value in there like $txnid = "123456"  my shopping cart will save it like that. Anything else will fail. So maybe the value needs a function around it.

 

$txnid = "55678759949" ; //shopping cart will use it and save it
$txnid = $split[6]; // doesn't work

maybe something like $txnid = " .$split[6] . ";
Edited by mallen
Link to comment
https://forums.phpfreaks.com/topic/276296-help-using-explode/#findComment-1421843
Share on other sites

I have a variable scope problem. I need to be able to access $xml in the process() method.

 

class AuthorizeNet extends GatewayFramework implements GatewayModule {

	var $cards = array("visa", "mc");
    var $status = array("1" => "CHARGED","4" => "PENDING");
	
	
	public $xml;
       public $splitted;
	public $txnstatus;
	function AuthorizeNet () {
		parent::__construct();
		$this->setup('login','password','testmode');
	}

	function actions () {
		add_action('mycart_process_order',array(&$this,'process'));
	}

	
	
		function process () {
		global $Mycart;
		$message = $this->build();
		$Response = $this->send($message);
		$status = $splitted[0]; 
		
		
		if ($status == "2" || $status == "4"){ 
	
		    $message = $xml->messages->message->code; 
			
			$code = $splitted[0];
			
			if (empty($message)) { 
				new MycartError(__("A configuration error occurred while processing this transaction. Please contact the site administrator.","Mycart"),'authnet_error',MYCART_TRXN_ERR);
				
				return;
			}
			new MycartError($xml->messages->message->code,'authnet_error',MYCART_TRXN_ERR);
				var_dump($xml->messages->message->code);
			
				return;
		}
		
		
var_dump($xml->directResponse[6]);echo "\n<br />\n";
$splitted = explode(',', $xml->directResponse[0]); 
//var_dump($this->$splitted);echo "\n<br />\n";
//echo var_dump($this->$splitted[6]);echo "\n<br />\n";
$txnid = $splitted[6]; 
var_dump($txnid);echo "\n<br />\n"; 

		$txnstatus = $xml->messages->resultCode; /
		
		$Mycart->Order->transaction($txnid,$txnstatus);

	}
	

	

	function build () {
		$Order = $this->Order;
	

 
	$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
    $xml->createCustomerProfileTransactionRequest(array(
  
    ));

echo "Response: " . $xml->messages->message->code  . "<br><br>";
echo "Code: " . $xml->messages->resultCode .  "<br><br>";
echo "Text: " . $xml->messages->message->text .  "<br><br>"; 
$splitted = explode(',', $xml->directResponse[0]);
echo "Direct Code: " . $splitted[0] . "<br><br>"; 
echo "Dir Response: " . $xml->directResponse.  "<br><br>"; 
echo "TXID: " . $splitted[6] .  "<br><br>"; //Successful
//echo "Direct Response: " . $xml->directResponse[0] .  "<br><br>"; 
echo "Transaction ID: " . $splitted[6] .  "<br><br>";
var_dump($splitted[6]);
echo "Raw request: " . $xml . "<br><br>";

//echo "Raw response: " . $response->customerProfileId . "<br><br>";

return $xml;//end function

 }	

	
	
function send ($message) {
	 //  $url = $this->url();//added
		$url = 'https://apitest.authorize.net/xml/v1/request.api';
		$url = apply_filters('mycart_authorize_net_url',$url);
		
	}


} // END class AuthorizeNet

Link to comment
https://forums.phpfreaks.com/topic/276296-help-using-explode/#findComment-1422295
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.