/**
  * Processes the sale payment
  *
  * @param  array   $data IPN data
  * @return boolean Did the IPN Validate?
  * @access protected
  */
 public function _processSale($data, $ipnValidationFailed = '')
 {
     /*
      * validate the payment data
      */
     $errors = array();
     if (!empty($ipnValidationFailed)) {
         $errors[] = $ipnValidationFailed;
     }
     // is the recipient correct?
     if (empty($data['receiver_email']) || $data['receiver_email'] != $this->_getParam('merchant_email')) {
         $errors[] = JText::_('PAYPAL MESSAGE RECEIVER INVALID');
     }
     if (empty($data['custom'])) {
         $errors[] = JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'CitruscartTable');
     $orderpayment->load($data['custom']);
     if (empty($data['custom']) || empty($orderpayment->orderpayment_id)) {
         $errors[] = JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     $orderpayment->transaction_details = $data['transaction_details'];
     $orderpayment->transaction_id = $data['txn_id'];
     $orderpayment->transaction_status = $data['payment_status'];
     // check the stored amount against the payment amount
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $stored_amount = CitruscartHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = CitruscartHelperBase::number($data['mc_gross'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('PAYPAL MESSAGE AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // check the payment status
     if (empty($data['payment_status']) || $data['payment_status'] != 'Completed' && $data['payment_status'] != 'Pending') {
         $errors[] = JText::sprintf('PAYPAL MESSAGE STATUS INVALID', $data['payment_status']);
     }
     // set the order's new status and update quantities if necessary
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'CitruscartTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } elseif ($data['payment_status'] == 'Pending') {
         // if the transaction has the "pending" status,
         $order->order_state_id = Citruscart::getInstance('pending_order_state', '1');
         // PENDING
         // Update quantities for echeck payments
         CitruscartHelperOrder::updateProductQuantities($orderpayment->order_id, '-');
         // remove items from cart
         CitruscartHelperCarts::removeOrderItems($orderpayment->order_id);
         // send email
         $send_email = true;
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Citruscart::load("CitruscartHelperBase", 'helpers._base');
         $helper = CitruscartHelperBase::getInstance('Email');
         $model = Citruscart::getClass("CitruscartModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Example #2
0
</label></td>
</tr>
<tr>
    <th><a href="<?php 
echo $stats->link;
?>
"><?php 
echo JText::_('COM_CITRUSCART_LIFETIME_SALES');
?>
</a></th>
    <td style="text-align: right;"><?php 
echo CitruscartHelperBase::number($stats->lifetime->num, $options_int);
?>
</td>
	<td style="text-align: right;"><?php 
echo CitruscartHelperBase::number($stats->lifetime->average_daily, $options_decimal);
?>
</td>
	<td style="text-align: right;"><label class="label label-warning"><?php 
echo CitruscartHelperBase::currency($stats->lifetime->average, '', $options_decimal);
?>
</label></td>
    <td style="text-align: right;"><label class="label label-success"><?php 
echo CitruscartHelperBase::currency($stats->lifetime->amount, '', $options_decimal);
?>
</label></td>
</tr>

</tbody>
</table>
Example #3
0
    echo CitruscartSelect::range($state->stats_interval, 'stats_interval', $attribs, null, true);
    ?>
</h3></td>
				<?php 
}
?>
				<td class="dashboard_profits_data float-shadow"><h1><?php 
echo CitruscartHelperBase::currency($this->sum);
?>
</h1></td>
				<td class="dashboard_profits_data float-shadow"><h1><?php 
echo CitruscartHelperBase::number($this->total, array('num_decimals' => '0'));
?>
</h1></td>
			    <td class="dashboard_profits_data"><h1><?php 
echo CitruscartHelperBase::number($this->orderedItems, array('num_decimals' => '0'));
?>
</h1></td>
			    
			</tr>
			</tbody>
			</table>
            <div class="section">
                <?php 
require_once JPATH_SITE . '/libraries/dioscouri/highroller/highroller/highroller.php';
$chart = new HighRoller();
$chart->chart->renderTo = 'chart';
$chart->chart->type = 'mixed';
$chart->plotOptions = new stdClass();
$chart->plotOptions->column = new stdClass();
$chart->plotOptions->column->pointStart = strtotime($this->revenue[0][0]) * 1000;
Example #4
0
        ?>
'>
            <?php 
        $i = 1;
        foreach ($vars->orderitems as $item) {
            //TODO
            /* CitruscartHelperBase::number( @$item->orderitem_final_price / @$item->orderitem_quantity, array( 'thousands' =>'', 'decimal'=> '.' ) );
             * CitruscartHelperBase::number( @$item->orderitem_price + @$item->orderitem_attributes_price, array( 'thousands' =>'', 'decimal'=> '.' ) );
             *  THis doesn't work because it doesn't take into account pricing discounts from coupons
             * */
            ?>
              <input type='hidden' name='amount_<?php 
            echo $i;
            ?>
' value='<?php 
            echo CitruscartHelperBase::number($item->orderitem_final_price / $item->orderitem_quantity, array('thousands' => '', 'decimal' => '.'));
            ?>
'>
                <input type='hidden' name='item_name_<?php 
            echo $i;
            ?>
' value='<?php 
            echo $item->_description;
            ?>
'>
                <input type='hidden' name='item_number_<?php 
            echo $i;
            ?>
' value='<?php 
            echo $item->product_id;
            ?>