Location: PHPKode > projects > MembersGear > membersgear/user_onetimeoffer_product_subscribe.php
<?php require_once "config/config.php";
 //**********************************************Begin Page code**********************************************     
    require_once INCLUDE_DIR."/users_class.php";
    require_once INCLUDE_DIR."/users_signup_class.php";
    require_once INCLUDE_DIR."/product_class.php";
    require_once INCLUDE_DIR."/location_class.php";   
    require_once INCLUDE_DIR."/PaygearWebserviceClient.php"; 
    $objPayGear=new PaygearWebserviceClient();    
    
    $users=new users_class();
    $lsSelectedProduct=$_POST['products'];
    //$puserid=decrypt($_COOKIE[COOKIE_PREFIX.'onetimeofferuserid']
    $userid=$_POST['hdn_userid'];
    //echo $lsSelectedProduct;
   // echo "<br>";
    //echo $userid;
     $objProclass=new product_class();
     $res=$objProclass->deleteDuplicateTransaction($userid,$lsSelectedProduct);  
     $usersignuupObj=new users_signup_class();
     $lsInsertToProductUser=$usersignuupObj->insertToProductUser($lsSelectedProduct,$userid);
     $usersignuupClass=new users_signup_class();
     $lsSalePageId=$usersignuupClass->getPayGearSalePageUrl($_POST['products']);

     
     $objcountry=new location_class();
     
     $get_product_info =$objProclass->GetSpecificProduct(trim($_POST['products']));
     $paygearProdId=$get_product_info[0]['paygear_productid'] ;
     $isFreeProduct=$get_product_info[0]['price'];
     $formatedPrice=number_format($isFreeProduct, 2, '.', ''); 
      
                
        
    $objUserInfo=$users->getSpecificUserInfoById($userid);
   
    if($objUserInfo[0]['country']!="" and $objUserInfo[0]['country']!=null)
       $country=$objcountry->getCountryStateNameById($objUserInfo[0]['country']);
    else
      $country="";
     
    if($objUserInfo[0]['state']!="" and $objUserInfo[0]['state']!=null)
       $state=$objcountry->getCountryStateNameById($objUserInfo[0]['state']);
    else
      $state="";
      
    if($objUserInfo[0]['billing_country']!="" and $objUserInfo[0]['billing_country']!=null)
       $billing_country=$objcountry->getCountryStateNameById($objUserInfo[0]['billing_country']);
    else
      $billing_country="";

    if($objUserInfo[0]['billing_state']!="" and $objUserInfo[0]['billing_state']!=null)
       $billing_state=$objcountry->getCountryStateNameById($objUserInfo[0]['billing_state']);
    else
      $billing_state=""; 
      

     if($formatedPrice=="0.00")
     {
       
         $iUserId=$objUserInfo[0]['id'];
         $postedArry=ARRAY();
         $postedArry['pg_amount']='0';
         $postedArry['e_txn_id']='0';
         $postedArry['e_processor_name']='N/A';
         $postedArry['pg_txn_stat']='1';
         $postedArry['payment_type']='N/A';
         $postedArry['pg_order_id']='0';
         $postedArry['payment_date']=date("m/d/Y");  
         
         $results=$objProclass->GetSpecificProductPaymentOptions(trim($_POST['products']));
        
         if($results!=false)
          { 
         
                 $ProductId=trim($_POST['products']);
                 $PaymentOptionId=trim($results[0]['paygear_productpaymentoptionid']);
                 $FirstName=trim($objUserInfo[0]['firstname']);
                 $LastName=trim($objUserInfo[0]['lastname']);
                 $Email=trim($objUserInfo[0]['email']);
                 $Address=isset($objUserInfo[0]['address1'])?trim($objUserInfo[0]['address1']):''; 
                 $City=isset($objUserInfo[0]['city'])?trim($objUserInfo[0]['city']):''; 
                 $State=$state;
                 $ZiporPostalCode=isset($objUserInfo[0]['zipcode'])?trim($objUserInfo[0]['zipcode']):''; 
                 $Country=$country;
                 $Phone=isset($objUserInfo[0]['phone_main'])?trim($objUserInfo[0]['phone_main']):''; 
                 $spFirstName=trim($objUserInfo[0]['firstname']);
                 $spLastName=trim($objUserInfo[0]['lastname']);
                 $spEmail=trim($objUserInfo[0]['email']);
                 $spAddress=isset($objUserInfo[0]['billing_address'])?trim($objUserInfo[0]['billing_address']):''; 
                 $spCity=isset($objUserInfo[0]['billing_city'])?trim($objUserInfo[0]['billing_city']):''; 
                 $spState=$billing_state;
                 $spZip=isset($_POST['zipcodeSHP'])?trim($_POST['zipcodeSHP']):''; 
                 $spCountry=$billing_country;
                 $spPhone=isset($objUserInfo[0]['billing_phone'])?trim($objUserInfo[0]['billing_phone']):''; 
                 $IPAddress=$_SERVER['REMOTE_ADDR'];
                    
                 $addUserToPaygear=$objPayGear->freePorductEntry($paygearProdId,$PaymentOptionId,$FirstName,
                                                                 $LastName,$Email,$Address,$City,$State,
                                                                 $ZiporPostalCode,$Country,$Phone,$spFirstName,
                                                                 $spLastName,$spEmail,$spAddress,$spCity,$spState,
                                                                 $spZip,$spCountry,$spPhone,$IPAddress);  
                 
                 if(strtoupper($addUserToPaygear['FreeSaleTransactionEntryResult'])==strtoupper("TRUE"))
                  {   
                     $usersignuupObj=new users_signup_class();
                     $usersignuupObj->updateToProductUser($postedArry,trim($_POST['products']),$iUserId);
                    
                     $thankyoupageUrl=urldecode($results[0]['thankyoupageurl']);
                    
                     Redirect($thankyoupageUrl,true);
                  }
                 else
                 {
                 
                     Redirect(WEB_URL."/user_login.php"); 
                 
                 }    
          }
         else
          Redirect(WEB_URL."/user_login.php");        
       
         
     }  
    else
    { 
       
   
        $browsUrl=PAYGEAR_WEB_URL."/sell.aspx?productpaymentoption=".urlencode(stripslashes(str_replace('.','[[dot]]',$lsSalePageId)))."&userid=".urldecode(stripslashes(str_replace('.','[[dot]]',$userid)))."&productid=".urlencode(stripslashes(str_replace('.','[[dot]]',$_POST['products'])))."&firstname=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['firstname'])))."&lastname=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['lastname'])))."&email=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['email'])));   
        $browsUrl.= "&address=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['address1'])))."&city=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['city'])))."&country=".urlencode(stripslashes(str_replace('.','[[dot]]',$country)))."&state=".urlencode(stripslashes( str_replace('.','[[dot]]',$state)))."&zipcode=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['zipcode'])))."&phone=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['phone_main'])));
        $browsUrl.="&shaddress=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['billing_address'])))."&shcity=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['billing_city'])))."&shcountry=".urlencode(stripslashes(str_replace('.','[[dot]]',$billing_country)))."&shstate=".urlencode(stripslashes(str_replace('.','[[dot]]',$billing_state)))."&shzipcode=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['billing_zip'])))."&shphone=".urlencode(stripslashes(str_replace('.','[[dot]]',$objUserInfo[0]['billing_phone'])));

        //$browsUrl="https://www.paygear.com/user/sell/productpaymentoption/".urlencode($lsSalePageId)."/userid/".urldecode($userid)."/productid/".$_POST['products'];
        //$browsUrl="http://localhost:1002/sscPayGear/user/sell/productpaymentoption/".urlencode($lsSalePageId)."/userid/".urldecode($userid)."/productid/".$_POST['products'];
        //$browsUrl=PAYGEAR_WEB_URL."/sell.aspx?productpaymentoption=".urlencode($lsSalePageId)."&userid=".urldecode($userid)."&productid=".$_POST['products'];
       // $url=WEB_URL."/ipn.php" ;
      Redirect($browsUrl);    
    } 
?>
Return current item: MembersGear