public function shoppingcart() { if (isset($_POST['first_name'])) { $app = new \iSDK(); if ($app->cfgCon("connectionName")) { $qry = array('Email' => $_POST['emailAddress']); $ret = array("Id"); $dups = $app->dsQuery("Contact", 1, 0, $qry, $ret); if (empty($dups)) { $contact = array("FirstName" => $_POST['first_name'], "LastName" => $_POST['last_name'], "State" => $_POST['state'], "Phone1" => $_POST['phoneNumber'], "City" => $_POST['city'], "Email" => $_POST['emailAddress'], "Address1Type" => $_POST['addressLine1'], "ZipFour1" => $_POST['last_name'], "Country" => $_POST['last_name'], "Company" => $_POST['company']); $date = date('d/m/y'); $cid = $app->addCon($contact); } else { $cid = $dups[0]['Id']; $contact = array("FirstName" => $_POST['first_name'], "LastName" => $_POST['last_name'], "State" => $_POST['state'], "Phone1" => $_POST['phoneNumber'], "City" => $_POST['city'], "Email" => $_POST['emailAddress'], "Address1Type" => $_POST['addressLine1'], "ZipFour1" => $_POST['last_name'], "Country" => $_POST['last_name'], "Company" => $_POST['company']); $contact_ID = $app->updateCon($cid, $contact); } $fullname = explode(" ", $_POST['nameoncard']); $card['FirstName'] = $fullname[0]; $card['LastName'] = $fullname[1]; $card['CardNumber'] = $_POST['cnumber']; $card['ExpirationMonth'] = $_POST['cardmonth']; $card['ExpirationYear'] = $_POST['cardyear']; $card['CVV2'] = $_POST['CVV']; $result = $app->validateCard($card); if ($result['Valid'] == 'false') { $msg = "Order cancel due to credit card"; return view('licenses.shoppingcart', compact('msg')); } else { $ccid = $app->dsAdd("CreditCard", $card); //$timezone = new DateTimeZone( "America/New_York" ); //$date = new DateTime(); //$date->setTimezone( $timezone ); $currentDate = date('Y-m-d H:i:s'); $oDate = $app->infuDate($currentDate); try { $invID = $app->blankOrder($cid, "Order for Licenses" . $cid, $oDate, 0, 0); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } $ord = $app->getOrderId($invID); $Quantity = $_POST['Quantity']; $subID = array(); for ($i = 1; $i <= $Quantity; $i++) { $app->addOrderItem((int) $invID, (int) 50, (int) 4, (double) 0.1, (int) 1, 'Licenses Item' . $i, ''); $_intproductid = $app->addRecurringAdv((int) $cid, true, (int) 34, (int) 1, (double) 0.1, false, (int) 2, (int) $ccid, (int) 0, (int) 30); $_nextBillDate = date("d-m-Y", strtotime("1 Months + 1 day")); $subID[$i] = $_intproductid; $thedate = $app->infuDate($_nextBillDate); $app->updateSubscriptionNextBillDate($_intproductid, $thedate); $service["Frequency"] = 1; $service["BillingCycle"] = 2; $app->dsUpdate("RecurringOrder", $_intproductid, $service); } $payStat = $app->chargeInvoice((int) $invID, "Payment Via API", (int) $ccid, (int) 2, false); if (substr($payStat['Message'], 0, 2) == "91") { $payStat = $app->chargeInvoice((int) $invID, "Payment Via API", (int) $ccid, (int) 2, false); } if ($payStat['RefNum'] != "E" && $payStat['Code'] == "APPROVED") { $msg = "Thanks For Order"; $user_id = Auth::user()->id; $users = User::findOrFail($user_id); for ($i = 1; $i <= $Quantity; $i++) { $date = new \DateTime(); $license = new License(); $license->life = 1; $license->license_key = $subID[$i]; $license->company_id = $users->company_id; $license->user_id = 0; $license->status = 'ACTIVE'; $license->created_by = Auth::user()->id; $license->created_at = $date; $license->updated_at = $date; $license->save(); } return view('licenses.shoppingcart', compact('msg')); } else { $msg = "Order cancel due payment"; return view('licenses.shoppingcart', compact('msg')); } } } } $msg = ""; return view('licenses.shoppingcart', compact('msg')); }
//connect to the API - change demo to be whatever your connectionName is! if ($app->cfgCon("demo")) { //action set Id number to run on the posted contact $actionId = 123; //grab our posted contact fields $contact = array('Email' => $_POST['Contact0Email'], 'FirstName' => $_POST['Contact0FirstName'], 'LastName' => $_POST['Contact0LastName']); //grab the returnURL $returnURL = $_POST['returnURL']; //dup check on email if it exists. if (!empty($contact['Email'])) { //check for existing contact; $returnFields = array('Id'); $dups = $app->findByEmail($contact['Email'], $returnFields); if (!empty($dups)) { //update contact $app->updateCon($dups[0]['Id'], $contact); //run an action set on the contact $app->runAS($dups[0]['Id'], $actionId); } else { //Add new contact $newCon = $app->addCon($contact); //run an action set on the contact $app->runAS($newCon, $actionId); } //Send them to the success page header('location: ' . $returnURL); } else { //Let them know how it is ;) die('You must provide at least an email address.'); } } else {
$data['Password'] = $IS_DATA['FirstName'] . '524193'; } $password = $IS_DATA['FirstName'] . '524193'; $wldata = array('user_login' => $IS_DATA['Username'], 'user_email' => $IS_DATA['Email'], 'user_pass' => $password, 'display_name' => $IS_DATA['FirstName'] . " " . $IS_DATA['LastName'], 'first_name' => $IS_DATA['FirstName'], 'last_name' => $IS_DATA['LastName'], 'Levels' => array($level)); $wlresponse = wlmapi_add_member($wldata); //print wlresponse print_r($wlresponse); //*=============================== //* WISHLIST SUCCESS //*=============================== if ($wlresponse['success'] == 1) { echo 'SUCCESS. User has been added to the Mojo lead Mastery: ' . $member; //*=============================== //* UPDATE INFUSIONSOFT //*=============================== //STORE WISHLIST INFORMATION $data['_WishListId'] = $wlresponse['member'][0]['ID']; // <------------NEED TO CHECK RESPONSE-------------- $data['_WishListLevels'] = $level; //print_r($data); $update = $infusion->updateCon((int) $order_id, $data); //*=============================== //* WISHLIST FAILURE //*=============================== } else { echo "\n" . '<br/>Error Code: ' . $wlresponse['ERROR_CODE']; echo "\n" . '<br/>'; echo "\n" . 'Error Description: ' . $wlresponse['ERROR']; } ?> Displaying wishlist-infusionsoft-add.php.
function UpdateInfusionsoftUser($infusionsoft_id) { //this is used for update the user activity info to infusionsoft and categories them into 4 levels. //auth.php will access this funciton. //fistly, use user id to find the infusionsoft id $contactId = $infusionsoft_id; //check the infusionsoft id, //0 -> no infusionsoft id, //-1 -> do not need infusionsoft id, //others are correct infusionsoft id. if ($contactId > 0) { require_once 'isdk.php'; $app = new iSDK(); if ($app->cfgCon("mps")) { //remove all tags level 5 is (316) level 4 is (318) Lvel 3 is (320) level 2 is (322) $result = $app->grpRemove($contactId, 316); $result = $app->grpRemove($contactId, 318); $result = $app->grpRemove($contactId, 320); $result = $app->grpRemove($contactId, 322); //Get the last login time $returnFields = array('_LastLogin'); $data = $app->loadCon($contactId, $returnFields); $current_date = date("Ymd\\T00:00:00"); if (!empty($data)) { //existing last login time, get the last login date $last_login_date = $data['_LastLogin']; //calc the day difference between current_time and last login $current_date_time = mktime(0, 0, 0, substr($current_date, 4, 2), substr($current_date, 6, 2), substr($current_date, 0, 4)); //echo "full:".$current_date."\nM:".substr($current_date,4,2)."\nD:".substr($current_date,6,2)."\nY:".substr($current_date,0,4)."\n"; $last_login_date_time = mktime(0, 0, 0, substr($last_login_date, 4, 2), substr($last_login_date, 6, 2), substr($last_login_date, 0, 4)); //echo "full:".$last_login_date."\nM:".substr($last_login_date,4,2)."\nD:".substr($last_login_date,6,2)."\nY:".substr($last_login_date,0,4)."\n"; $datediff = floor(($current_date_time - $last_login_date_time) / (60 * 60 * 24)); //echo $datediff; if ($datediff <= 7) { //within 7 days assign level 5 tag $app->grpAssign($contactId, 316); //$app->achieveGoal("om185", "TriggerSizzling", $contactId); } else { if ($datediff >= 8 and $datediff <= 14) { //within 8-14 days assign level 4 tag $app->grpAssign($contactId, 318); } else { if ($datediff >= 15 and $datediff <= 21) { //within 15-21 days assign level 3 tag $app->grpAssign($contactId, 320); } else { //over 22 days assign level 2 tag $app->grpAssign($contactId, 322); } } } } else { //last login time not existed, assign to level 5 tag $app->grpAssign($contactId, 316); } //update last login $conDat = array('_LastLogin' => $current_date); $conID = $app->updateCon($contactId, $conDat); return TRUE; } } else { return FALSE; } }
<?php include 'config.php'; require "src/isdk.php"; $app = new iSDK(); if ($app->cfgCon("connectionName")) { echo "app connected<br/>"; $contactId = (int) $_POST['contactId']; $number = (int) $_POST['number']; $field = $_POST['field']; // Get Value of Current Field $counter = $app->loadCon($contactId, array("{$field}")); $countervalue = $counter[$field]; // Do Some Math $newvalue = $countervalue + $number; echo "Old value = {$countervalue} <br> New Value = {$newvalue} <br> Field Incrased by {$number}"; // Update The field With New Value $conDat = array($field => $newvalue); $app->updateCon($contactId, $conDat); } else { echo "Connection to API failed"; }
//print_r($wlresponse); //*=============================== //* WISHLIST SUCCESS //*=============================== if ($wlresponse['success'] == 1) { echo 'SUCCESS. Performed ' . $action . ' on ContactId ' . $contact_id . ' on membership ' . $membership; //*=============================== //* UPDATE INFUSIONSOFT //*=============================== //STORE WISHLIST INFORMATION if (!empty($wlresponse['member'][0]['ID'])) { $data['_WishListId'] = $wlresponse['member'][0]['ID']; } $data['_WishListLevels'] = $level; //print_r($data); $update = $infusion->updateCon((int) $contact_id, $data); //*=============================== //* WISHLIST FAILURE //*=============================== } //else //{ // echo "\n".'<br/>Error Code: ' . $wlresponse['ERROR_CODE']; // echo "\n".'<br/>'; // echo "\n".'Error Description: ' . $wlresponse['ERROR']; // } function add_user_meta_val($user_meta_values = array(), $user_id) { $db_connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die(mysqli_error('cant connect to database')); $meta_options = array('first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'wp_capabilities', 'wp_user_level', 'dismissed_wp_pointers'); $counter = 0;
$key = md5($fxn . '__' . $Secret . '__' . implode('|', $params)); $URL = "http://www.mojovideouniversity.com/?WLMAPI={$fxn}/{$key}/{$WLId}/{$levels}/{$txid}/{$autoresponder}"; //POST $ch = curl_init($URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($ch); curl_close($ch); list($status, $return) = unserialize($return); if ($status) { //SUCCESS echo 'SUCCESS! A Mojo Video University user account has been setup on The Gold Plan 1<br/>'; } else { //FAILURE, SHOW ERROR echo 'FAILURE: ' . $return . '<br/>'; } } else { //FAILURE, SHOW ERROR echo 'FAILURE: ' . $return . '<br/>'; } //*=============================== //* UPDATE INFUSIONSOFT //*=============================== //STORE WISHLIST INFORMATION if ($WLId) { $data['_WishListId'] = $WLId; } if ($levelsarray) { $data['_WishListLevels'] = implode(",", $levelsarray); } $update = $app->updateCon((int) $contactId, $data);
} if (isset($_POST['first_name'])) { require_once "infusion/isdk.php"; $app = new iSDK(); if ($app->cfgCon("connectionName")) { $qry = array('Email' => $_POST['emailAddress']); $ret = array("Id"); $dups = $app->dsQuery("Contact", 1, 0, $qry, $ret); if (empty($dups)) { $contact = array("FirstName" => $_POST['first_name'], "LastName" => $_POST['last_name'], "State" => $_POST['state'], "Phone1" => $_POST['phoneNumber'], "City" => $_POST['city'], "Email" => $_POST['emailAddress'], "Address1Type" => $_POST['addressLine1'], "ZipFour1" => $_POST['zipCode'], "Country" => $_POST['country'], "Company" => $_POST['company']); $date = date('d/m/y'); $cid = $app->addCon($contact); } else { $cid = $dups[0]['Id']; $contact = array("FirstName" => $_POST['first_name'], "LastName" => $_POST['last_name'], "State" => $_POST['state'], "Phone1" => $_POST['phoneNumber'], "City" => $_POST['city'], "Email" => $_POST['emailAddress'], "Address1Type" => $_POST['addressLine1'], "ZipFour1" => $_POST['last_name'], "Country" => $_POST['last_name'], "Company" => $_POST['company']); $contact_ID = $app->updateCon($cid, $contact); } $fullname = explode(" ", $_POST['nameoncard']); $card['FirstName'] = $fullname[0]; $card['LastName'] = $fullname[1]; $card['CardNumber'] = $_POST['cnumber']; $card['ExpirationMonth'] = $_POST['cardmonth']; $card['ExpirationYear'] = $_POST['cardyear']; $card['CVV2'] = $_POST['CVV']; $result = $app->validateCard($card); if ($result['Valid'] == 'false') { $error = "Order cancel due to credit card"; } else { $ccid = $app->dsAdd("CreditCard", $card); //$timezone = new DateTimeZone( "America/New_York" ); //$date = new DateTime();