/**
  * Override of parent::dsUpdate to support auto-retry
  *
  * @param  string  $table  The target table being updated
  * @param  int     $id     The ID of the record being updated
  * @param  mixed[] $fields Assoc. array of data to update
  * @return mixed
  */
 public function dsUpdate($table, $id, $fields)
 {
     $tries = 0;
     do {
         $result = parent::dsUpdate($table, $id, $fields);
     } while ($id != $result && ++$tries < 3);
     if ($id != $result) {
         file_put_contents(dirname(__FILE__) . '/log.txt', "Call to dsUpdate failed ({$tries} tries): " . PHP_EOL . print_r($table, TRUE) . PHP_EOL . print_r($id, TRUE) . PHP_EOL . print_r($fields, TRUE) . PHP_EOL . print_r($result, TRUE) . PHP_EOL . PHP_EOL, FILE_APPEND);
     }
     return $result;
 }
 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'));
 }
<?php

require_once "../src/isdk.php";
$app = new iSDK();
echo "created object<br/>";
if ($app->cfgCon("connectionName")) {
    echo "app connected<br/>";
    $orderId = 673;
    $firstName = 'API';
    $lastName = 'Has Updated Me';
    $street = '333 API st';
    $city = 'Chandler';
    $dat = array('ShipFirstName' => $firstName, 'ShipLastName' => $lastName, 'ShipStreet1' => $street, 'ShipCity' => $city);
    $jobId = $app->dsUpdate("Job", $orderId, $dat);
    echo "JobId={$jobId}<br/>";
} else {
    echo "connection failed";
}
 } 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") {
     $email = $_POST['emailAddress'];
     $first_name = $_POST['first_name'];
     $last_name = $_POST['last_name'];
     $address1 = $_POST['addressLine1'];
     $address2 = $_POST['addressLine1'];
     $contact_number = $_POST['phoneNumber'];
     $company = $_POST['company'];
     $created_by = 0;
     $created_at = date('Y-m-d H:i:s');
Esempio n. 5
0
$app = new iSDK();
if ($app->cfgCon("connectionName")) {
    echo "app connected<br/>";
    /*
    $data = array('FirstName'  => 'Test Group', 'ContactType' => 'Order', '_OrderNumber' => '123', '_OrderDate' => '20140626T04:22:03', '_Status' => 'Received', '_PaymentMethod' => 'Direct Debit', '_Price' => '10.00', '_Coupon' => 'Test123Coupon', '_Paid' => '1', '_PaymentDate' => '20140626T04:22:03', '_DeedVersion' => '2013-1');
    $contactId = 404;
    $grpID = $app->dsUpdate("Contact", $contactId, $data);
    */
    $name = "paul";
    $order_id = "123";
    $orderDate = "20140626T04:22:03";
    $method = "Direct Debit";
    $price = "30";
    $coup = "";
    $paidstatus = 0;
    $paymentdate = $orderDate;
    $email = "*****@*****.**";
    if ($method == "Direct Debit") {
        $paidstatus = 0;
        $paymentdate = "";
    } else {
        $paidstatus = 1;
        $paymentdate = $orderDate;
    }
    $data = array('FirstName' => $name, 'ContactType' => 'Order', '_OrderNumber' => $order_id, '_OrderDate' => $orderDate, '_Status' => 'Received', '_PaymentMethod' => $method, '_Price' => $price, '_Coupon' => $coup, '_Paid' => $paidstatus, '_PaymentDate' => $paymentdate, 'Company' => $name, 'Email' => $email);
    $contactId = 404;
    $grpID = $app->dsUpdate("Contact", $contactId, $data);
    echo "<br>updated contact Id {$contactId}";
} else {
    echo "Connection to API failed";
}