archivo example.php
Código PHP:
<form name="payment_form" method="POST" action="firepay.php">
<input type="Text" name="firepay[cardType]" value="VI">
<input type="Text" name="firepay[cardNumber]" value="5194178153650576">
<input type="Text" name="firepay[cardExp]" size="7" maxlength="5" value="01/10">
<input type="Text" name="firepay[amount]" value="1500">
<input type="Text" name="firepay[operation]" value="P">
<input type="Text" name="firepay[merchantTxn]" size="10" value="123">
<input type="Text" name="firepay[cvdIndicator]" value="1">
<input type="Text" name="firepay[cvdValue]" value="123">
<table width="100%" border="0" cellspacing="3" cellpadding="2">
BILLING ADDRESS INFORMATION
<input type="Text" name="firepay[custName1]" value="John Doe">
<input type="Text" name="firepay[streetAddr]" size=30 value="123 Broadway">
<input type="Text" name="firepay[streetAddr2]" size=30 value="Apt 1">
<input type="Text" name="firepay[city]" value="New York">
<input type="Text" name="firepay[province]" value="NY">
<input type="Text" name="firepay[zip]" value="123456">
<input type="Text" name="firepay[country]" value="US">
<input type="Text" name="firepay[phone]" value="123-4567">
<input type="Text" name="firepay[email]" size=30 value="[email protected]">
<input type="Submit" name="Submit" value="Submit Form">
</form>
Código PHP:
<?
function get_microtime(){
$mtime=microtime();
$mtime=explode(" ",$mtime);
$mtime=doubleval($mtime[1])+doubleval($mtime[0]);
return $mtime;
}
function dp($call,$cname) {
echo "<br/>".$cname.":<pre>";
if(!is_array($call)){$call=htmlspecialchars($call);}
print_r($call);
if(is_array($call)){reset($call);}
echo "</pre><hr/>\n";
}
function post_firepay($firepay,$debug){
// Your Merchant Account Parameters
$account='yourAccountNumberHere';
$merchantId='yourMerchantIDhere';
$merchantPwd='yourMerchantPWDhere';
$clientVersion='1.1';
$operation='P';
$data_stream='';
$url='';
$start=get_microtime();
// Array of account parameters
$params = array( 'account' => $account, 'merchantId' => $merchantId, 'merchantPwd' => $merchantPwd,
'clientVersion' => $clientVersion,
'operation' => $operation );
// Append account parameters to firepay array
$data = (array)$firepay + (array)$params;
if($debug==true){
// DEBUG MODE: Display paramters being sent and set url to test gateway
dp($data,'Input Parameters: DEBUG Mode');
// Test gateway
$url='https://realtime.test.firepay.com:443/servlet/DPServlet';
}else{
// Production gateway
$url='https://realtime.firepay.com:443/servlet/DPServlet';
}
//prep the incoming array to be sent via POST
foreach($data as $k=>$v){
if(strlen($data_stream)>0){
$data_stream.='&';
}
$data_stream.="$k=".urlencode($v);
}
//send the data and retrieve response from FirePay
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_stream);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result_tmp = curl_exec ($ch);
curl_close ($ch);
//re-arrange the results into an array
$result_tmp=explode('&',urldecode($result_tmp));
foreach($result_tmp as $v){
list($key,$val)=explode('=',$v);
$result[$key]=$val;
}
$end=get_microtime();
$tmp = array( 'transactionTime' => $end-$start );
$result = (array)$result + (array)$tmp;
if($debug==true){
dp($result,'FirePay Response: DEBUG Mode');
return $result;
}else{
return $result;
}
}
// DEBUG MODE
$result=post_firepay($_POST['firepay'],true);
// PRODUCTION MODE
//$result=post_firepay($_POST['firepay'],false);
if($result['status']=='SP'){
// Put success logic here
echo("Transaction successful");
} elseif($result['status']=='E'){
// Put failed logic here
echo("Transaction failed");
} else {
// Possible issue invoking cURL extension
echo("Could not sent request to FirePay. Please verify the cURL extension is installed and loaded.");
}
?>
Account Name: Passion Leaf Test Account
> > Merchant Account Number: ****
> > merchantId: ***
> > merchantPwd: **
pero la verdad que no entiendo varias cosas: como toma los productos que eligio en el carrito, o eso es aparte de este sistema? si al llenar los datos de la tarjeta va al sitio de optical payments para verificar o no ? si alguien lo uso o conoce alguno parecido, le pido una mano..... gracias !