Jump to content

Recommended Posts

hello,
Im needing help with my SecureNet integration. Every thing works and it is sending orders over except the orders is sent over as "Auth_capture" instead of "Charge" Please help, a portion of the code from the file orders_controller.php is below:

    

/************* Function to pay using Securenet**************************************/

    function securenet($id=0){

    

        $orderdetails=$this->Session->read('orderforpayment');

        $orderdetailsforpayment=$this->Session->read('orderdetailsforpayment');

    

        if(empty($orderdetails) && empty($orderdetailsforpayment)){

            $this->redirect(array('controller' => 'users', 'action' => "myaccount"));

            exit;

        }

        $this->__validateLoginStatus('U');

        $sus    =    $this->Session->read('Userlog');        

        $this->set('sus', $sus);

        $cnfg                     =     Configure::read('Neutrino');

        $user_id    =    $sus["id"];

        $orderDetails = $this->Order->findById($id);

        $shipping_cost    =    $orderdetails["shipping_price"];

        $shipping_form             =     "<input type='hidden' name='shipping' value='$shipping_cost'>";

        $tot_price    =    $orderdetails["total_price"]-$orderdetails["shipping_price"];

        $totaltopay =     number_format($tot_price,2,".","");

        $gtotal        =    number_format(($tot_price + $shipping_cost),2,".","");

        $this->set('totaltopay', $totaltopay);

        $this->set('oid', $id);

        $this->set('totaltopay', number_format($tot_price,2,".",""));    

        $taxamt    =0;

        if($cnfg["taxto"]    ==    "gtotal"){

            $taxableamt        =    $tot_price + $shipping_cost;

        }else{

            $taxableamt        =    $tot_price ;

        }



        if($cnfg["tax_option"] == "notax"){



            $taxperc    =    0;



            $taxname    =    "No Tax is applicable";



        }elseif($cnfg["tax_option"] == "fixedtax"){



            $taxperc    =     $cnfg["fixedtax_rate"];



            $taxname    =    $cnfg["fixedtax_name"];



        }else{



            if($cnfg["taxable_address"] == "shipping"){

                $billadd    =    $this->UserAddress->find('UserAddress.user_id = '.$user_id.' AND UserAddress.addr_type = "Shipping"');

            }else{



                $billadd    =    $this->UserAddress->find('UserAddress.user_id = '.$user_id.' AND UserAddress.addr_type = "Billing"');



            }



            $stdetal        =    $this->State->find('State.country_id = "'.$billadd["UserAddress"]["country"].'" AND State.code = "All"');



            if(!empty($stdetal["State"])){



                $taxperc    =    $stdetal["State"]["tax_rate"];



                $taxname    =    $stdetal["State"]["tax_name"];



            }else{



                $stdetal    =    $this->State->find('State.country_id = "'.$billadd["UserAddress"]["country"].'" AND State.code ="'.$billadd["UserAddress"]["state"].'"');



                if(!empty($stdetal["State"])){



                    $taxperc    =    $stdetal["State"]["tax_rate"];



                    $taxname    =    $stdetal["State"]["tax_name"];



                }else{



                    $stdetal    =    $this->State->find('State.country_id = "'.$billadd["UserAddress"]["country"].'" AND State.name ="'.$billadd["UserAddress"]["state"].'"');



                    if(!empty($stdetal["State"])){



                        $taxperc    =    $stdetal["State"]["tax_rate"];



                        $taxname    =    $stdetal["State"]["tax_name"];



                    }else{



                        $taxperc    =    0;



                        $taxname    =    "No Tax is applicable";



                    }



                }



            }



        }



        if($tot_price > 0)



        {



        $taxamt        =    ($taxableamt * $taxperc) / 100;



        $taxamt        =    number_format($taxamt,2,".","")    ;            



        $tot_price    =    $tot_price + $taxamt;                    



        }

//echo $tot_price;exit;

        

        ######################### End of Section to find and add tax amount......................

        $discountamt    =    $orderdetails["reduced_amt"];

        $tot_price =  $tot_price-$discountamt;

        $this->set('taxamnt', $taxamt);    

        if($tot_price > 0)

        $gtotal        =    number_format(($tot_price + $shipping_cost),2,".","");

        else

        $gtotal        =    number_format(0.00 + $shipping_cost,2,".","");

        /////////////////////////////////////////////////////////////

        $paymentMethod = "CC";



        $this->set('totaltopay', $tot_price);



        $this->set('userid', $user_id);



        $this->set('paymentMethod', $paymentMethod);



        $this->set('shipping_cost', $shipping_cost);



        $billadd    =    $this->UserAddress->find("UserAddress.user_id =".$user_id." AND UserAddress.addr_type ='Billing'");



        #$txtUrPayDemo    =    "YES";



        $bp_testmode             = $cnfg["secure_testmode"];

        if($bp_testmode == "Y"){

            $bp_testmode    =    "TEST";

        }else{

            $bp_testmode    = "LIVE";

        }



        $bp_secret                 = $cnfg["bp_secret"];



        $bp_account             = $cnfg["bp_account"];





        



        # BILLING INFO 4111111111111111



        $bad        =    $billadd["UserAddress"];



        $txtEmail                    =    $sus["email"];



        

        ############################################



        $Company                    =    "-NA-";

//echo $_POST["cart_total"];exit;

        //$newinvid                    =    $this->Order->getNewinvid();



        $curr        =    $this->Currency->findByCode($cnfg["currency"]);



        $this->set('curlogo',$curr["Currency"]["logo"]);
        $this->set('gtotal',$gtotal);



        if($_SERVER['REQUEST_METHOD']=='POST'){



            $cardNumber   = urlencode($_POST["txtCCNumber"]);



            $myorder["cardexpmonth"]     = $_POST["txtMM"] ;


            $card_codedd=trim($_POST['txtCVV2']);
            

            $expireMonthYear            = $_POST["txtMM"].'/'.substr($_POST["txtYY"],-2);

            $cardExpire                      = $expireMonthYear;

            //echo $cardExpire;exit;

            $myorder["chargetotal"]      = urlencode($_POST["cart_total"]);

//////////////////////////// Curl Securenet starts here////////////////////////////


if($bp_testmode == "LIVE")
{
$url = 'https://gwapi.securenet.com/api/Payments/Charge';

}
else
{
    
    $url = 'https://gwapi.demo.securenet.com/api/Payments/Charge';
}
$ch = curl_init($url);


$dvlpr_id=$cnfg['securenet_developerid'];

$cardNumber=str_replace('+'," ",$cardNumber);
$aunthi= trim($cnfg['securenet_Id']).':'.trim($cnfg['securenet_key']);

//$data_string = json_encode($data);
$u_fn=$bad['fname'];
$u_ln=$bad['lname'];
$u_add=$bad['address'];
$u_cit=$bad['city'];
$u_state=$bad['state'];
$u_zip=$bad['zip'];

$df="{amount: $gtotal,

card: {
    number: '$cardNumber',
    cvv: '$card_codedd',
    expirationDate: '$cardExpire',
    address: {
      line1: '$u_add',
      city: '$u_cit',
      state: '$u_state',
      zip: '$u_zip'
    },
    firstname: '$u_fn',
    lastname: '$u_ln'
  },
  extendedInformation: {
    typeOfGoods: 'PHYSICAL'
  },
  developerApplication: {developerId: $dvlpr_id,version: '1.2'}}";//echo $df;exit;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $df );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
                                        
                                        
'Authorization: Basic '. base64_encode($aunthi),
'Content-Type: application/json',
'Content-Length: ' . strlen($df)
));
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
//the HTTP Header is vital and SecureNet won't accept the request if this is incorrect and their error handling isn't explicit.
$response = curl_exec($ch);
//print_r(curl_error($ch));
//print_r($response);
//echo $url;exit;
//print_r($response);
curl_close($ch);
//exit;
$responses=json_decode($response);
//print_r($responses);
//echo $responses->result;
//echo $responses->transaction->result;exit;

             if($responses->result == "APPROVED"){




                       $paymentsuccessful = true;



                       $transactionid = $transactionid;

                       $id=$this->updateordetable($orderdetails,$orderdetailsforpayment);

                       $this->__payorder($id,'Securenet',$trans_id);

                    $this->Session->setFlash('Your order has been successfully placed and an e-mail with order details has sent to your e-mail ID!', 'default',array('class'=> 'success'));

                    $this->redirect(array('controller' => 'users','action'=>'myaccount'));

                    exit;

            }else{

                $paymentsuccessful = false;



                $paymenterror = "Error";



                $paymenterror ="An error has occurred. Please Try again.";

                 $this->Session->setFlash($paymenterror, 'default',array('class'=> 'failure'));


}







///////////////////////////securenet ends here///////////////////////
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.