I'm stuck on the payment processor.
I'm using the defacto authorize.net and made modifications to work with the USAePay.com details.
Basically, I can entered my details and send them to the payment processor (through curl), the receipts look perfect.
But it's not validating on the ubercart site.
I can go the the ubercart orders (ex:11) and it will show the information presented in there with card details, user information, etc. But, the comments I'm entered are not showing as well.
Here is a snippet from USAePay's php api:
//get the result and parse it for the response line.
if(!strlen($result))
{
$this->result="Error";
$this->resultcode="E";
$this->error="Error reading from card processing gateway.";
$this->errorcode=10132;
$this->blank=1;
$this->curlerror=curl_error($ch);
curl_close ($ch);
return false;
}
curl_close ($ch);
$this->rawresult=$result;
if(!$result) {
$this->result="Error";
$this->resultcode="E";
$this->error="Blank response from card processing gateway.";
$this->errorcode=10132;
return false;
}
// result will be on the last line of the return
$tmp=split("\n",$result);
$result=$tmp[count($tmp)-1];
// result is in urlencoded format, parse into an array
parse_str($result,$tmp);
// check to make sure we received the correct fields
if(!isset($tmp["UMversion"]) || !isset($tmp["UMstatus"]))
{
$this->result="Error";
$this->resultcode="E";
$this->error="Error parsing data from card processing gateway.";
$this->errorcode=10132;
return false;
}
// Store results
$this->result=(isset($tmp["UMstatus"])?$tmp["UMstatus"]:"Error");
$this->resultcode=(isset($tmp["UMresult"])?$tmp["UMresult"]:"E");
$this->authcode=(isset($tmp["UMauthCode"])?$tmp["UMauthCode"]:"");
$this->refnum=(isset($tmp["UMrefNum"])?$tmp["UMrefNum"]:"");
$this->batch=(isset($tmp["UMbatch"])?$tmp["UMbatch"]:"");
$this->avs_result=(isset($tmp["UMavsResult"])?$tmp["UMavsResult"]:"");
$this->avs_result_code=(isset($tmp["UMavsResultCode"])?$tmp["UMavsResultCode"]:"");
$this->cvv2_result=(isset($tmp["UMcvv2Result"])?$tmp["UMcvv2Result"]:"");
$this->cvv2_result_code=(isset($tmp["UMcvv2ResultCode"])?$tmp["UMcvv2ResultCode"]:"");
$this->vpas_result_code=(isset($tmp["UMvpasResultCode"])?$tmp["UMvpasResultCode"]:"");
$this->convertedamount=(isset($tmp["UMconvertedAmount"])?$tmp["UMconvertedAmount"]:"");
$this->convertedamountcurrency=(isset($tmp["UMconvertedAmountCurrency"])?$tmp["UMconvertedAmountCurrency"]:"");
$this->conversionrate=(isset($tmp["UMconversionRate"])?$tmp["UMconversionRate"]:"");
$this->error=(isset($tmp["UMerror"])?$tmp["UMerror"]:"");
$this->errorcode=(isset($tmp["UMerrorcode"])?$tmp["UMerrorcode"]:"10132");
$this->custnum=(isset($tmp["UMcustnum"])?$tmp["UMcustnum"]:"");
// Obsolete variable (for backward compatibility) At some point they will no longer be set.
$this->avs=(isset($tmp["UMavsResult"])?$tmp["UMavsResult"]:"");
$this->cvv2=(isset($tmp["UMcvv2Result"])?$tmp["UMcvv2Result"]:"");
if(isset($tmp["UMcctransid"])) $this->cctransid=$tmp["UMcctransid"];
if(isset($tmp["UMacsurl"])) $this->acsurl=$tmp["UMacsurl"];
if(isset($tmp["UMpayload"])) $this->pareq=$tmp["UMpayload"];
if($this->resultcode == "A") return true;
return false;The code above is using class information from a file that I'm not pulling in.
The below code is what I'm using for validation. It's quite screwy.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0);
$authorize = curl_exec($ch);
if ($error = curl_error($ch)) {
watchdog('uc_usaepaycom', $error, WATCHDOG_ERROR);
}
curl_close($ch);
$response = explode(variable_get('authnet_aim_delimiter', ','), $authorize);
$UMresult = $response[0];
$UMstatus = $response[3];
$UMauthCode = $response[4];
if ($UMresult != '1') {
$message = t('Credit card declined: !amount', array('!amount' => uc_currency_format($amount)));
$result = array(
'success' => FALSE,
'comment' => t('Credit card payment declined: @text', array('@text' => $UMstatus)),
'message' => t('Credit card payment declined: @text', array('@text' => $UMstatus)),
'uid' => $user->uid,
);
}
else {
$message = t('Credit card charged: !amount', array('!amount' => uc_currency_format($amount)));
$result = array(
'success' => TRUE,
'comment' => t('Credit card payment processed successfully.<br/>Approval code: @code', array('@code' => $UMauthCode)),
'message' => t('Credit card payment processed successfully.<br/>Approval code: @code', array('@code' => $UMauthCode)),
'uid' => $user->uid,
);
}
uc_order_comment_save($order_id, $user->uid, $message . t('<br />Response code: @code - @text', array('@code' => $UMresult, '@text' => $UMstatus)), 'admin');
return $result;If it would help speed things up, I can move this to bounty.
I've also attached the usaepay.php file itself, just because.
| Attachment | Size |
|---|---|
| usaepay.php_.txt | 27.89 KB |



I generally do just like doing things manually in the module itself to avoid the extra dependency or licensing issues. I guess I'd just say do whatever works for you in this situatio, though...


Joined: 01/18/2008