cancel
Showing results for 
Search instead for 
Did you mean: 

Character Issues

Hi,

 

I am trying to take payments through my website. I have a manual paymnt system. I am having an issue where "spaces" between characters changes to a "+" symbol and "@" symbol chnages to %40. whichis preventing emails to be send out to my customers.

vkreator
Member
6 REPLIES 6

On which field? which api?  sdks?

RaynorC1emen7
Expert

I am using PHP as a language and AIM, get this while printing Receipts from Account

 

"Valerie+ Lewis

706+Locust+St

Bastrop, TX+ 78602

USA

Phone: ********

support%40winprotechnologies.com

"

 

Please advise

I have uploaded a sample transaction here :

 

Sample Receipt

That the billing info, how are you passing it to authorize.net ? since it is AIM, did you encode it before sending it?

<div class="contents" style="width:70%;  margin:0px auto;">
<?php
	if ($_POST){
	
		$firstName =urlencode( $_POST['firstname']);
		$lastName =urlencode($_POST['lastname']);
		$creditCardType =urlencode( $_POST['cardtype']);
		$creditCardNumber = urlencode($_POST['cardnumber']);
		$expDateMonth =urlencode( $_POST['cardmonth']);		
		$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);		
		$expDateYear =urlencode( $_POST['cardyear']);
		$cvv2Number = urlencode($_POST['cardcvv']);
		$address1 = urlencode($_POST['address']);
		$city = urlencode($_POST['city']);
		$state =urlencode( $_POST['state']);
		$zip = urlencode($_POST['zip']);		
		$customer_id =urlencode( $_POST['customerid']);
		$phone = urlencode($_POST['phone']);
		$amount = "300";
		$currencyCode="USD";
		$paymentType="Sale";
		$date = $expDateMonth.$expDateYear;
			
		$post_values = array(
			"x_login"			=> '********',   // change here
			"x_tran_key"		=> '**************', // change here
			"x_version"			=> "3.1",
			"x_delim_data"		=> "TRUE",
			"x_delim_char"		=> "|",
			"x_relay_response"	=> "FALSE",
			//"x_market_type"		=> "2",
			"x_device_type"		=> "1",
			"x_type"			=> "AUTH_CAPTURE",
			"x_method"			=> "CC",
			"x_card_num"		=> $creditCardNumber,
			//"x_exp_date"		=> "0115",
			"x_exp_date"		=> $date,
			"x_amount"			=> $amount,
			//"x_description"		=> "Sample Transaction",
			"x_first_name"		=> $firstName,
			"x_last_name"		=> $lastName,
			"x_address"			=> $address1,
			"x_state"			=> $state,
			"x_response_format"	=> "1",
			"x_zip"				=> $zip,		
			"x_customer_id"	    => $customer_id,
			"x_phone"			=> $phone			
		);


		$post_string = "";
		foreach( $post_values as $key => $value )$post_string .= "$key=" . urlencode( $value ) . "&";
		$post_string = rtrim($post_string,"& ");

		//for test mode use the following url
		$post_url = "https://test.authorize.net/gateway/transact.dll"; // comment it on live
		//for live use this url
		// $post_url = "https://secure.authorize.net/gateway/transact.dll"; // remove comment it on live

		$request = curl_init($post_url); 
		curl_setopt($request, CURLOPT_HEADER, 0); 
		curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($request, CURLOPT_POSTFIELDS, $post_string);
		curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); 
		$post_response = curl_exec($request); 

		curl_close ($request); 
		$response_array = explode($post_values["x_delim_char"],$post_response);

		if($response_array[0]==2||$response_array[0]==3) 
		{
			//success 
			echo '<div class="response">';
			echo '<b>Payment Failure</b>. <br>';
			echo '<b>Error String</b>: '.$response_array[3];
			echo '</div>';
		}
		else
		{
			$ptid = $response_array[6];
			$ptidmd5 = $response_array[7];
			echo "Payment Success";
			
			// Mail On payment success
			
			$to = "fff@gmail.com";  // change here
			$subject = "Payment Successfully Submitted :";
			
			$txt = "Hello Admin, \r\n \r\n";
			$txt .= "Details of customer is as follows : \r\n";
			$txt .= "Name : " . $firstName . " " .$lastName ."\r\n";
			$txt .= "Address : ". $address1 ."\r\n";
			$txt .= "City : ". $city ."\r\n";
			$txt .= "State : ". $state ."\r\n";
			$txt .= "Phone No : ". $phone ."\r\n";
			$txt .= "Paid Amount : ". $amount ."\r\n";
			$txt .= "\r\n \r\n \r\n";
			
			$headers = "From: admin@greenforce.com" . "\r\n" . // change here
			"CC: somebodyelse@example.com";  // change here

			mail($to,$subject,$txt,$headers);
		}
	}
?>

<style type="text/css">
<!--
.clear {clear:both; line-height:1px; font-size:1px; height:1px; }
.contents {background-color:#EDF4F8; padding:10px; border:2px dashed #C2DAE7; }
.leftbox {float:left; border-right:1px dashed #cecece; width:48%; }
.leftone {float: left; width:150px; padding:3px; margin-left:5px; }
.maindiv {width:700px; border:0px dashed #cecece; overflow:hidden; }
.rightbox {float:left; width:48%; margin-left:5px; }
.rightone {float:left; padding:3px;}
.sel {border:1px inset gray; }
-->
.response {
    border: 1px solid #f00000;
    color: #f00000;
    padding: 10px;
}
</style>
  <form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" name="payform" id="payform">
    <div class="maindiv">
      <div class="leftbox">
        <div class="leftone" style="color: #0099FF"><strong>Personal Details</strong></div>
        <div class="rightone" style="width:80px;">&nbsp;</div>
		
        <div class="leftone">Customer id</div>
        <div class="rightone">
          <input name="customerid" type="text" />
        </div>        
		<div class="leftone">First Name</div>
        <div class="rightone">
          <input name="firstname" type="text" />
        </div>
        <div class="leftone">Last Name</div>
        <div class="rightone">
          <input name="lastname" type="text" />
        </div>
        <div class="leftone">Email</div>
        <div class="rightone">
          <input name="email" type="text" />
        </div>
		<div class="leftone">Phone No.</div>
        <div class="rightone">
          <input name="phone" type="text" />
        </div>
        <div class="leftone">Address</div>
        <div class="rightone">
          <input name="address" type="text" />
        </div>
        <div class="leftone">City</div>
        <div class="rightone">
          <input name="city" type="text" />
        </div>
        <div class="leftone">State</div>
        <div class="rightone">
          <input name="state" type="text" maxlength="30" />
        </div>
	    <div class="leftone">Zip</div>
        <div class="rightone">
          <input name="zip" type="text" />
        </div>
      </div>
      <div class="rightbox">
        <div class="leftone" style="color: #0099FF"><strong>Payment Details</strong></div>
        <div class="rightone" style="width:80px;">&nbsp;</div>
        <div class="leftone">Card Type</div>
        <div class="rightone">
          <select name="cardtype" >
            <option value="visa">Visa</option>
            <option value="MasterCard">Master Card</option>
            <option value="AmericanExpress">American Express</option>
          </select>
        </div>
        <div class="leftone">Cardholder Name</div>
        <div class="rightone">
          <input name="cardholder" type="text" />
        </div>
        <div class="leftone">Card Number</div>
        <div class="rightone">
          <input name="cardnumber" type="text" />
        </div>
        <div class="leftone">Expiration <span style=" font:7pt arial; color:gray;">[ mm / yyyy ]</span></div>
        <div class="rightone">
          <input name="cardmonth" class="sel" type="text" style="width:40px;" />
          &nbsp;
          <input type="text" name="cardyear" class="sel" style=" width:98px;" />
        </div>
        <div class="leftone">CVV Number</div>
        <div class="rightone">
            <input type="password" name="cardcvv">
        </div>
		<div class="leftone">Amount</div>
        <div class="rightone">
          <input name="amount" type="text" />
        </div>
        <div class="leftone" style="width:255px; text-align:right;">
          <input name="submit" type="submit" style="border:1px outset gray; width:100px;" value="Pay Now" />
        </div>
      </div>
      <div class="clear"></div>
    </div>
  </form>
</div>

 This is the total code that I have used in the form. Also, x_email is aslo used which doesn;t show in the code above but in live form it is.

You are double urlencode

$address1 = urlencode($_POST['address']);

which add to

$post_values = array(
...
"x_address"            => $address1,

Then you

foreach( $post_values as $key => $value )$post_string .= "$key=" . urlencode( $value ) . "&";