public function submitPayment()
 {
     $dir = $this->getMethodDirectory();
     require_once $dir . 'anet_php_sdk/AuthorizeNet.php';
     $METHOD_TO_USE = "AIM";
     define("AUTHORIZENET_API_LOGIN_ID", Config::get('vividstore.authnetLoginID'));
     // Add your API LOGIN ID
     define("AUTHORIZENET_TRANSACTION_KEY", Config::get('vividstore.authnetTransactionKey'));
     // Add your API transaction key
     define("AUTHORIZENET_SANDBOX", Config::get('vividstore.authnetTestmode'));
     // Set to false to test against production
     define("TEST_REQUEST", "FALSE");
     // You may want to set to true if testing against production
     //define("AUTHORIZENET_MD5_SETTING","");                // Add your MD5 Setting.
     //$site_root = ""; // Add the URL to your site
     if (AUTHORIZENET_API_LOGIN_ID == "") {
         die('Enter your merchant credentials');
     }
     $transaction = new AuthorizeNetAIM();
     $transaction->setSandbox(AUTHORIZENET_SANDBOX);
     $transaction->setFields(array('amount' => Price::getFloat(VividCart::getTotal()), 'card_num' => $_POST['authnet-checkout-credit-card'], 'exp_date' => $_POST['authnet-checkout-exp-month'] . $_POST['authnet-checkout-exp-year']));
     $response = $transaction->authorizeAndCapture();
     if ($response->approved) {
         return true;
     } else {
         return array('error' => 1, 'errorMessage' => $response->error_message . " Error Code: " . $response->response_code . ". Message: " . $response->response_reason_text);
     }
 }
Example #2
0
 public function getSubTotal()
 {
     $price = Price::getFloat($this->getPricePaid());
     $qty = $this->getQty();
     $subtotal = $qty * $price;
     return $subtotal;
 }
Example #3
0
 public function add($data, $oID, $tax = 0, $taxIncluded = 0, $taxName = '')
 {
     $db = Database::get();
     $product = VividProduct::getByID($data['product']['pID']);
     $productName = $product->getProductName();
     $productPrice = Price::getFloat($product->getFormattedPrice());
     $qty = $data['product']['qty'];
     $inStock = $product->getProductQty();
     $newStock = $inStock - $qty;
     $product->setProductQty($newStock);
     $pID = $product->getProductID();
     $values = array($oID, $pID, $productName, $productPrice, $tax, $taxIncluded, $taxName, $qty);
     $db->Execute("INSERT INTO VividStoreOrderItems (oID,pID,oiProductName,oiPricePaid,oiTax,oiTaxIncluded,oiTaxName,oiQty) VALUES (?,?,?,?,?,?,?,?)", $values);
     $oiID = $db->lastInsertId();
     foreach ($data['productAttributes'] as $optionGroup => $selectedOption) {
         $optionGroupID = str_replace("pog", "", $optionGroup);
         $optionGroupName = VividProduct::getProductOptionGroupNameByID($optionGroupID);
         $optionValue = VividProduct::getProductOptionValueByID($selectedOption);
         $values = array($oiID, $optionGroupName, $optionValue);
         $db->Execute("INSERT INTO VividStoreOrderItemOptions (oiID,oioKey,oioValue) VALUES (?,?,?)", $values);
     }
     if ($product->hasDigitalDownload()) {
         $fileObjs = $product->getProductDownloadFileObjects();
         $fileObj = $fileObjs[0];
         $pk = \Concrete\Core\Permission\Key\FileKey::getByHandle('view_file');
         $pk->setPermissionObject($fileObj);
         $pao = $pk->getPermissionAssignmentObject();
         $u = new User();
         $uID = $u->getUserID();
         $ui = UserInfo::getByID($uID);
         $user = \Concrete\Core\Permission\Access\Entity\UserEntity::getOrCreate($ui);
         $pa = $pk->getPermissionAccessObject();
         if ($pa) {
             $pa->addListItem($user);
             $pao->assignPermissionAccess($pa);
         }
     }
 }
Example #4
0
 public function calculateProduct($productObj, $qty)
 {
     if (is_object($productObj)) {
         if ($productObj->isTaxable()) {
             //if this tax rate is in the tax class associated with this product
             if ($productObj->getTaxClass()->taxClassContainsTaxRate($this)) {
                 $taxCalc = $taxCalc = Config::get('vividstore.calculation');
                 if ($taxCalc == 'extract') {
                     $taxrate = 10 / ($this->getTaxRate() + 100);
                 } else {
                     $taxrate = $this->getTaxRate() / 100;
                 }
                 switch ($this->getTaxBasedOn()) {
                     case "subtotal":
                         $productSubTotal = $productObj->getActivePrice() * $qty;
                         $tax = $taxrate * $productSubTotal;
                         $taxtotal = $taxtotal + $tax;
                         break;
                     case "grandtotal":
                         $productSubTotal = $productObj->getActivePrice() * $qty;
                         $shippingTotal = StorePrice::getFloat(StoreCalculator::getShippingTotal());
                         $taxableTotal = $productSubTotal + $shippingTotal;
                         $tax = $taxrate * $taxableTotal;
                         $taxtotal = $taxtotal + $tax;
                         break;
                 }
             }
             //if in products tax class
         }
         //if product is taxable
     }
     //if obj
     return $taxtotal;
 }
Example #5
0
 public function getTotals()
 {
     $subTotal = Price::getFloat(Cart::getSubTotal());
     $taxes = self::getTaxes();
     $addedTaxTotal = 0;
     $includedTaxTotal = 0;
     if ($taxes) {
         foreach ($taxes as $tax) {
             if ($tax['calculation'] != 'extract') {
                 $addedTaxTotal += $tax['taxamount'];
             } else {
                 $includedTaxTotal += $tax['taxamount'];
             }
         }
     }
     $shippingTotal = Price::getFloat(Cart::getShippingTotal());
     $total = $subTotal + $addedTaxTotal + $shippingTotal;
     return array('subTotal' => $subTotal, 'taxes' => $taxes, 'taxTotal' => $addedTaxTotal + $includedTaxTotal, 'shippingTotal' => $shippingTotal, 'total' => $total);
 }