$v) { $_SESSION[$k]=$v; } $creditcard_type = $_POST['creditcard_type']; if ($creditcard_type == 'visa') { $creditcard_type = 'Visa'; } iper_hook_css(); get_header('product'); global $wpdb; $_POST["firstName_shipping"] = strip_tags($_POST["firstName_shipping"]); $_POST["lastName_shipping"] =strip_tags($_POST["lastName_shipping"]); $_POST["address1_shipping"] =strip_tags($_POST["address1_shipping"]); $_POST["address2_shipping"] =strip_tags($_POST["address2_shipping"]); $_POST["city_shipping"] =strip_tags($_POST["city_shipping"]); $_POST["state_shipping"] =strip_tags($_POST["state_shipping"]); $_POST["zip_shipping"] =strip_tags($_POST["zip_shipping"]); $_POST["zip_shipping"] =strip_tags($_POST["zip_shipping"]); $_POST["country_shipping"] =strip_tags($_POST["country_shipping"]); $_POST["phone_shipping"] =strip_tags($_POST["phone_shipping"]); $_POST["lastName_billing"] =strip_tags($_POST["lastName_billing"]); $_POST["firstName_billing"] =strip_tags($_POST["firstName_billing"]); $_POST["phone_billing"] =strip_tags($_POST["phone_billing"]); $_POST["address1_billing"] =strip_tags($_POST["address1_billing"]); $_POST["address2_billing"] =strip_tags($_POST["address2_billing"]); $_POST["email_shipping"] =strip_tags($_POST["email_shipping"]); $_POST["city_billing"] =strip_tags($_POST["city_billing"]); $_POST["state_billing"] =strip_tags($_POST["state_billing"]); $_POST["zip_billing"] =strip_tags($_POST["zip_billing"]); $_POST["country_billing"] =strip_tags($_POST["country_billing"]); $_POST["creditcard_name"] =strip_tags($_POST["creditcard_name"]); $_POST["creditcard_type"] =strip_tags($_POST["creditcard_type"]); $_POST["creditcard_number"] =strip_tags($_POST["creditcard_number"]); $_POST["creditcard_month"] =strip_tags($_POST["creditcard_month"]); $_POST["creditcard_year"] =strip_tags($_POST["creditcard_year"]); $_POST["gclid_field"] =strip_tags($_POST["gclid_field"]); $_POST["gCard"] =strip_tags($_POST["gCard"]); $_POST["subid1"] =strip_tags($_POST["subid1"]); $_POST["subid2"] =strip_tags($_POST["subid2"]); $_POST["subid3"] =strip_tags($_POST["subid3"]); $_POST["subid4"] =strip_tags($_POST["subid4"]); $post_medical_shipping = array( $_POST["firstName_shipping"], $_POST["lastName_shipping"], $_POST["address1_shipping"], $_POST["city_shipping"], $_POST["state_shipping"], $_POST["zip_shipping"], $_POST["email_shipping"], $_POST["country_shipping"], $_POST["phone_shipping"], $_POST["lastName_billing"], $_POST["firstName_billing"], $_POST["phone_billing"], $_POST["address1_billing"], $_POST["email_shipping"], $_POST["city_billing"], $_POST["state_billing"], $_POST["zip_billing"], $_POST["country_billing"], $_POST["creditcard_name"], $_POST["creditcard_type"], $_POST["creditcard_number"], $_POST["creditcard_year"], $_POST["creditcard_month"], $_POST["gclid_field"], $_POST["gCard"], $_POST["subid1"], $_POST["subid2"], $_POST["subid3"], $_POST["subid4"], $_POST["subid4"] ); $expiration_credit_card_date = $_POST["cc_date"]; foreach($post_medical_shipping as $post_medical){ if(!$post_medical && $post_medical!=''){ header('Location: '.get_permalink($config['id_medical_shipping'])); } } $orderID=md5("iperdesign|".microtime()); $_SESSION["md_profile"]=array( "first_name"=>$_POST["firstName_billing"], "last_name"=>$_POST["lastName_billing"], ); /** * @param $AccessoryID * @param $Quantity * @return array */ function createAccessory($AccessoryID,$Quantity, $ProgrammingFee){ $Accessory= array( "AccessoryID" => $AccessoryID, "Price" => $ProgrammingFee, "Quantity" => $Quantity ); return $Accessory; } /** * @param $PaymentType * @param $CardholderName * @param $CardType * @param $CardNumber * @param $CVV * @param $AccountHolderName * @param $AccountType * @param $AccountNumber * @param $RoutingNumber * @return array */ function createPaymentInformation($PaymentType,$CardholderName,$CardType,$CardNumber,$ExpDate, $CVV=NULL,$AccountHolderName=NULL,$AccountType=NULL,$AccountNumber=NULL,$RoutingNumber=NULL){ if($CardType=="American" ){ $CardType = "American Express"; } if($CardType=="Master" ){ $CardType = "MasterCard"; } $PaymentInformation = array( "PaymentType" => $PaymentType ,"CardholderName" => $CardholderName ,"CardType" => $CardType ,"CardNumber" => $CardNumber ,"ExpirationDate" => $ExpDate ); return $PaymentInformation; } $objPaymentInformation=createPaymentInformation("Credit Card",$_POST["creditcard_name"], $_POST["creditcard_type"], $_POST["creditcard_number"], $expiration_credit_card_date); /** * @param $ProductID * @param $Quantity * @param $RatePlanID * @param $PromotionID * @param $Accessories * @return array */ function createOrderProduct($ProductID,$Quantity,$RatePlanID, $PromotionID=null ,$Accessories=null){ $OrderProduct= array( "ProductID" => $ProductID , "Quantity" => $Quantity , "RatePlanID" => $RatePlanID , "PromotionID" => $PromotionID , "Accessories" => $Accessories ); if(!$PromotionID){ unset($OrderProduct["PromotionID"]); } if(is_null($Accessories)){ unset($OrderProduct["Accessories"]); } return $OrderProduct; } $aProductPromotion=$_SESSION['PromotionID']; $aProductAccessories=array($_SESSION['Accessories']); $aProductUpsells=$_SESSION['Upsells']; foreach($_SESSION["iper_cart"]["products"] as $single){ $aProduct=$single; } $accessories=NULL; $arrAccessories=array(); if(!empty($aProductAccessories)){ $accessories=array(); $i = 0; foreach($aProductAccessories[0] as $key => $value){ $AccessoryID = $value[0]; $ProgrammingFee = $value[2]; $accessories[]=createAccessory($AccessoryID,1,$ProgrammingFee); $arrAccessories[]=$single; } } $aRatePlan=$_SESSION['RatePlanID']; $dbProduct=$_SESSION['ProductName']; $orderProducts=array( createOrderProduct($_SESSION['ProductID'], 1, $aRatePlan, $aProductPromotion, $accessories) ); $arrUpsells=array(); if(!empty($aProductUpsells)){ foreach($aProductUpsells as $single){ $aUpsell=$single[0]; $arrUpsells[]=$aUpsell; $orderProducts[]=createOrderProduct($aUpsell, 1, $aRatePlan, $single[4]); } } /** * @param $Name * @param $Phone * @param $Street1 * @param $Street2 * @param $City * @param $State * @param $PostalCode * @param $Country * @return array */ function createAddress($FirstName, $LastName, $Phone, $Street1, $Street2, $City, $State,$PostalCode,$Country){ $Address = array( "FirstName" => $FirstName , "LastName" => $LastName , "Phone" => $Phone , "Street1" => $Street1 , "Street2" => $Street2 , "City" => $City , "State" => $State , "PostalCode" => $PostalCode , "Country" => $Country ); return $Address; } function fix_dash($num){ $number = $num; $number = str_replace("-","",$number); $number = str_split($number); $number1 = array_slice($number, 0, 3); array_push($number1, '-'); $number2 = array_slice($number, 3, 3); array_push($number2, '-'); $number3 = array_slice($number, 6, 4); $number = array_merge($number1, $number2, $number3); $number = implode('', $number); return $number; } $phone_shipping = $_POST["phone_shipping"]; $phone_billing = $_POST["phone_billing"]; $phone_shipping = fix_dash($phone_shipping); $phone_billing = fix_dash($phone_billing); $objAddressShipping=createAddress(rtrim($_POST["firstName_shipping"]), rtrim($_POST["lastName_shipping"]),$phone_shipping, $_POST["address1_shipping"], $_POST["address2_shipping"],$_POST["city_shipping"],$_POST["state_shipping"],$_POST["zip_shipping"],$_POST["country_shipping"]); $objAddressBilling=createAddress(rtrim($_POST["firstName_billing"]), rtrim($_POST["lastName_billing"]),$phone_billing,$_POST["address1_billing"], $_POST["address2_billing"],$_POST["city_billing"],$_POST["state_billing"],$_POST["zip_billing"],$_POST["country_billing"]); /** * @param $CustomerFirstName * @param $CustomerLastName * @param $CustomerEmail * @param $CustomerPhoneNumber * @param $DiscountCode * @param $MarketingCampaign * @param $ShippingID * @param $PaymentInformation * @param $ShippingInformation * @param $BillingInformation * @param $OrderProducts * @return array */ function createOrder($CustomerFirstName,$CustomerLastName,$CustomerEmail,$CustomerPhoneNumber,$gclid_field,$control,$subid1,$subid2,$subid3,$subid4,$DiscountCode,$MarketingCampaign,$ShippingID,$PaymentInformation,$ShippingInformation,$BillingInformation,$OrderProducts){ if(isset($_COOKIE['SESSabtest']) && $_COOKIE['SESSabtest']== "1" ) { $control = "Control"; } $Order = array( "CustomerFirstName" => $CustomerFirstName , "CustomerLastName" => $CustomerLastName , "CustomerEmail" => $CustomerEmail , "CustomerPhoneNumber" => $CustomerPhoneNumber , "GCLID" => $gclid_field , "UserExperience" => $control , "CustomField1" => $subid1 , "CustomField2" => $subid2 , "CustomField3" => $subid3 , "CustomField4" => $subid4 , "MarketingCampaign" => IperCampaignController::getCampaignID()!=null?IperCampaignController::getCampaignID():"ecom campaign" , "ShippingID" => $ShippingID , "PaymentInformation" => $PaymentInformation , "ShippingInformation" => $ShippingInformation , "BillingInformation" => $BillingInformation , "OrderProducts" => $OrderProducts ); return $Order; } $shippingPackage = explode(',',$_POST["shippingType"]); $idShipping=$shippingPackage[1]; $shippingPrice=$shippingPackage[0]; $objOrder=createOrder($_POST["firstName_shipping"], $_POST["lastName_shipping"] , $_POST["email_shipping"], $phone_shipping, $_POST["gclid_field"], $_POST["control"],$_POST["subid1"] , $_POST["subid2"] , $_POST["subid3"] , $_POST["subid4"] , NULL, NULL, $idShipping, $objPaymentInformation, $objAddressShipping,$objAddressBilling,$orderProducts); /** * @param $RequestHeader * @param $RequestBody * @param $ResumeID * @return array */ /** * @return array */ function orderLogs($result) { $ups1 = $_SESSION['Upsells'][0][2]; $ups2 = $_SESSION['Upsells'][1][2]; $op_id = $_SESSION['Opportunity_ID_Profile_Page']; $firstname = $_POST['firstName_shipping']; $lastname = $_POST['lastName_shipping']; $phone = $_POST["phone_shipping"]; $email = $_POST['email_shipping']; $productsel = $_SESSION['Package']['productName']; $rateplansel = $_SESSION['Package']['ratePlan']; global $wpdb; $table_name = $wpdb->prefix . "ecom_log"; $wpdb->insert($table_name, array( 'id' => insert_id, 'sfdc_id' => $op_id, 'first_name' => $firstname, 'last_name' => $lastname, 'phone' => $phone, 'email' => $email, 'product' => $productsel, 'rateplan' => $rateplansel, 'upsell1' => $ups1, 'upsell2' => $ups2, 'order_date' => date("Y-m-d H:i:s"), 'res_text' => $result )); return $orderlogs; } function createRequestHeader(){ $RequestHeader = array( "RequestID" =>"Request_".microtime() ); return $RequestHeader; } function createOrderRequest($order,$request, $resume_id){ $order_request = array( "RequestHeader"=>$request, "RequestBody"=>$order, "ResumeID" => $resume_id ); if(is_null($resume_id) || empty($resume_id) || $resume_id==''){ unset($order_request["ResumeID"]); } return $order_request; } function createProfile($FirstName, $LastName, $Country_shipping, $Street1, $Street2, $City, $State, $PostalCode, $Mail, $Phone){ $Profile = array( "Name" => $FirstName , "LastName" => $LastName , "Country" => $Country_shipping , "Street1" => $Street1 , "Street2" => $Street2 , "City" => $City , "State" => $State , "PostalCode" => $PostalCode , "Mail" => $Mail , "Phone" => $Phone ); return $Profile; } $objProfile=createProfile($_POST["firstName_shipping"], $_POST["lastName_shipping"], $_POST["country_shipping"], $_POST["address1_shipping"],$_POST["address2_shipping"], $_POST["city_shipping"],$_POST["state_shipping"],$_POST["zip_shipping"], $_POST['email_shipping'], $phone_shipping ); $_SESSION['shipping_info']=$objProfile; $req=createOrderRequest($objOrder,createRequestHeader(), $_SESSION['Opportunity_ID_Profile_Page']); $sf=new IperSalseforceSync(IperSalseforceSync::kACTION_ORDER_CREATE,$req, "POST"); $res=json_decode(json_decode($sf->sendRequest())); $error_response = serialize($res->ErrorList); foreach($res->ErrorList as $errorinlist){ if(strpos($errorinlist, 'OpportunityID') !== false){ $errorinlist1 = str_replace('OpportunityID=', '', $errorinlist); $_SESSION['Opportunity_ID_Profile_Page'] = $errorinlist1; } } if($res->ResponseBody){ $_SESSION['Opportunity_ID_Profile_Page'] = $res->ResponseBody; } function check_card_error_presence($x){ $e_1 = array( 'Customer account is in the “known bad” account list (EFT only)', 'Void/capture and original transaction types do not agree (CC/EFT)', 'Transaction was previously voided or captured', 'Void or Capture failed', 'Credit card number is invalid', 'Date is malformed', 'Swipe data is malformed', 'Malformed expiration date', 'Negative amount', 'Invalid data present in transaction', 'Transaction was declined due to preauthorization (ATM Verify) result', 'Preauthorizer not responding (Verify Only transactions only)', 'Preauthorizer error (Verify Only transactions only)', 'Transaction was declined due to authorizer declination', 'Authorizer not responding', 'Authorizer error', 'Authorizer AVS check failed', 'Authorizing Vendor busy, may be resubmitted (CC only)'); $result_presence = 0; foreach($e_1 as $error){ if(strpos($x, $error) !== false){ $result_presence += 1;} } return $result_presence; } function check_general_error_presence($x){ $e_1 = array( "CustomerFirstName was null", "CustomerLastName was null", "CustomerEmail was null", "Street1 was null", "City was null", "State was null", "PostalCode was null", "Country was null", "Street1 was null", "City was null", "State was null", "PostalCode was null", "Country was null", "CardholderName was null", "CardType provided is invalid", "CardNumber was null"); $result_presence = 0; foreach($e_1 as $error){ if(strpos($x, $error) !== false){ $result_presence += 1;} } return $result_presence; } $result_card_presence_error = check_card_error_presence($error_response); $result_general_error_presence = check_general_error_presence($error_response); global $response; if(isset($res->ResponseBody) && $res->ResponseBody !=''){ $res_text = 'Success'; $response = 'Success'; } if(!isset($res->ResponseBody) || $res->ResponseBody ==''){ slack(); $res_text = 'Failed'; $response = 'Failed'; } function slack() { global $error_response; $pantheon_env = $_ENV['PANTHEON_ENVIRONMENT']; $sf_status = $error_response; $slack_message = $sf_status; if ($pantheon_env == 'live') { $slack_webhook_url = 'https://hooks.slack.com/services/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'; // #medicalalert-order } else { $slack_webhook_url = 'https://hooks.slack.com/services/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'; // #medicalalert-order-qa } $slack_data = array( 'text' => $slack_message ); $slack_data_string = json_encode( $slack_data ); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $slack_webhook_url ); curl_setopt( $ch, CURLOPT_POST, 1 ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $slack_data_string ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen( $slack_data_string ) ) ); $result = curl_exec( $ch ); curl_close( $ch ); } orderLogs($response); if($_SERVER["REMOTE_ADDR"]=='79.3.196.80'): ?>
Setting up your profile now will save you time when your receive and set up your system.
Name:
Address 1:
Address 2:
City:
State:
Postal Code:
Phone:
Email:
Payment Details ***
Order ID
$
$
Programming Fee$99.95
Item(s) Subtotal$
Shipping & Handling$
Grand Total$