function transactionResultHandler($transaction_result = '', $message = '', $source = 'frontend')
 {
     $log = '';
     if ($source == 'handler') {
         $ID = $_POST['ID'];
         $FUNCTION = $_POST['FUNCTION'];
         $RRN = $_POST['RRN'];
         $PAYER = $_POST['PAYER'];
         $AMOUNT = $_POST['AMOUNT'];
         $ACCOUNT = $_POST['ACCOUNT'];
         $STATUS = $_POST['STATUS'];
         $DATETIME = $_POST['DATETIME'];
         $MERCH_TYPE = $_POST['MERCH_TYPE'];
         $AMOUNT_FULL = $_POST['AMOUNT_FULL'];
         $KEY = $this->_getSettingValue('CONF_PAYMENTMODULE_ARSENALPAY_MK_SHARED_SECRET');
         if (isset($_POST['SIGN']) && $_POST['SIGN'] == md5(md5($ID) . md5($FUNCTION) . md5($RRN) . md5($PAYER) . md5($AMOUNT) . md5($ACCOUNT) . md5($STATUS) . md5($KEY))) {
             $function = isset($_POST['FUNCTION']) ? $_POST['FUNCTION'] : 0;
             if ($function && $function == 'check') {
                 $orderID = isset($_POST['ACCOUNT']) ? $_POST['ACCOUNT'] : 0;
                 if ($orderID && ($order = _getOrderById($orderID))) {
                     $order_amount = $order['order_amount'];
                     if ($MERCH_NAME == 0 && $order_amount == $AMOUNT) {
                         $log = "Order with id {$orderID} check";
                         $transaction_result = 'YES';
                     } elseif ($MERCH_NAME == 1 && $order_amount >= $AMOUNT && $order_amount == $AMOUNT_FULL) {
                         $log = "Order with id {$orderID} and amount {$AMOUNT} check";
                         $transaction_result = 'YES';
                     } else {
                         $log = "Order  {$orderID} amount mismatch with callback. {$AMOUNT}  in callback vs {$order_amount} in db";
                         $orderID = false;
                         $transaction_result = 'NO';
                     }
                 } else {
                     $log = "Order with id {$orderID} not exists";
                     $orderID = false;
                     $transaction_result = 'NO';
                 }
             } elseif ($function && $function == 'payment') {
                 $orderID = isset($_POST['ACCOUNT']) ? $_POST['ACCOUNT'] : 0;
                 if ($orderID && ($order = _getOrderById($orderID))) {
                     $order_amount = $order['order_amount'];
                     if ($MERCH_NAME == 0 && $order_amount == $AMOUNT) {
                         $log = "Order with id {$orderID} PAYMENT recieved";
                         $transaction_result = 'OK';
                         $statusID = $this->_getSettingValue('CONF_PAYMENTMODULE_ARSENALPAY_MK_ORDERSTATUS');
                         if ($statusID != -1) {
                             $comment = $sys_invs_no ? sprintf("Заказ оплачен по ArsenalPay%s. Номер счета — %s, номер платежа — %s.", $mode ? ' (тестовый режим)' : '', $sys_invs_no, $sys_trans_no) : 'Заказ оплачен по ArsenalPay';
                             ostSetOrderStatusToOrder($orderID, $statusID, $comment, 0, true);
                         }
                     } elseif ($MERCH_NAME == 1 && $order_amount >= $AMOUNT && $order_amount == $AMOUNT_FULL) {
                         $log = "Order with id {$orderID} and amount {$AMOUNT} PAYMENT recieved";
                         $transaction_result = 'OK';
                         $statusID = $this->_getSettingValue('CONF_PAYMENTMODULE_ARSENALPAY_MK_ORDERSTATUS');
                         if ($statusID != -1) {
                             $comment = $sys_invs_no ? sprintf("Заказ оплачен по ArsenalPay%s. Номер счета — %s, номер платежа — %s, сумма заказа — %s.", $mode ? ' (тестовый режим)' : '', $sys_invs_no, $sys_trans_no, $AMOUNT) : 'Заказ оплачен по ArsenalPay';
                             ostSetOrderStatusToOrder($orderID, $statusID, $comment, 0, true);
                         }
                     } else {
                         $log = "Order  {$orderID} amount mismatch with callback. {$AMOUNT}  in callback vs {$order_amount} in db";
                         $orderID = false;
                         $transaction_result = 'ERR';
                     }
                 } else {
                     $log = "Order with id {$orderID} not exists";
                     $orderID = false;
                     $transaction_result = 'ERR';
                 }
             } else {
                 $log = "Failed ARSENAL PAY callback call";
                 $orderID = false;
                 $transaction_result = 'ERR';
             }
         } else {
             $log = "ARSENAL PAY sign fail";
             $orderID = false;
             $transaction_result = 'ERR';
         }
         $responce = $transaction_result;
         echo $responce;
         return parent::transactionResultHandler($transaction_result, $message . $log, $source);
     }
 }
Ejemplo n.º 2
0
function _sendOrderNotifycationToAdmin($orderID, &$smarty_mail, $tax)
{
    $order = _getOrderById($orderID);
    $smarty_mail->assign('customer_firstname', $order['customer_firstname']);
    $smarty_mail->assign('customer_lastname', $order['customer_lastname']);
    $smarty_mail->assign('customer_email', $order['customer_email']);
    $smarty_mail->assign('customer_ip', $order['customer_ip']);
    $smarty_mail->assign('order_time', format_datetime($order['order_time']));
    $smarty_mail->assign('customer_comments', $order['customers_comment']);
    $smarty_mail->assign('discount', $order['order_discount']);
    $smarty_mail->assign('shipping_type', $order['shipping_type']);
    $smarty_mail->assign('shipping_cost', _formatPrice(roundf($order['currency_value'] * $order['shipping_cost']), $order['currency_round']) . ' ' . $order['currency_code']);
    $smarty_mail->assign('payment_type', $order['payment_type']);
    $smarty_mail->assign('shipping_firstname', $order['shipping_firstname']);
    $smarty_mail->assign('shipping_lastname', $order['shipping_lastname']);
    $smarty_mail->assign('shipping_country', $order['shipping_country']);
    $smarty_mail->assign('shipping_state', $order['shipping_state']);
    $smarty_mail->assign('shipping_city', $order['shipping_city']);
    $smarty_mail->assign('shipping_address', chop($order['shipping_address']));
    $smarty_mail->assign('billing_firstname', $order['billing_firstname']);
    $smarty_mail->assign('billing_lastname', $order['billing_lastname']);
    $smarty_mail->assign('billing_country', $order['billing_country']);
    $smarty_mail->assign('billing_state', $order['billing_state']);
    $smarty_mail->assign('billing_city', $order['billing_city']);
    $smarty_mail->assign('billing_address', chop($order['billing_address']));
    $smarty_mail->assign('order_amount', _formatPrice(roundf($order['currency_value'] * $order['order_amount']), $order['currency_round']) . ' ' . $order['currency_code']);
    $smarty_mail->assign('orderID', $order['orderID']);
    $smarty_mail->assign('total_tax', _formatPrice(roundf($order['currency_value'] * $tax), $order['currency_round']) . ' ' . $order['currency_code']);
    $smarty_mail->assign('shippingServiceInfo', $order['shippingServiceInfo']);
    $smarty_mail->assign('tax', $tax);
    // clear cost ( without shipping, discount, tax )
    $q1 = db_query('select Price, Quantity from ' . ORDERED_CARTS_TABLE . ' where orderID=' . (int) $orderID);
    $clear_total_price = 0;
    while ($row = db_fetch_row($q1)) {
        $clear_total_price += $row['Price'] * $row['Quantity'];
    }
    $order_discount_ToShow = _formatPrice(roundf($order['currency_value'] * $clear_total_price * ((100 - $order['order_discount']) / 100)), $order['currency_round']) . ' ' . $order['currency_code'];
    $smarty_mail->assign('order_discount_ToShow', $order_discount_ToShow);
    //additional reg fields
    $addregfields = GetRegFieldsValuesByOrderID($orderID);
    $smarty_mail->assign('customer_add_fields', $addregfields);
    //fetch order content from the database
    $content = ordGetOrderContent($orderID);
    for ($i = 0; $i < count($content); $i++) {
        $productID = GetProductIdByItemId($content[$i]['itemID']);
        if ($productID == null || trim($productID) == '') {
            continue;
        }
        $q = db_query('select name, product_code, default_picture from ' . PRODUCTS_TABLE . ' where productID=' . (int) $productID);
        $product = db_fetch_row($q);
        $content[$i]['product_code'] = $product['product_code'];
        $content[$i]['product_idn'] = $productID;
        /*
        $qz = db_query('select filename FROM '.PRODUCT_PICTURES.' WHERE photoID='.$product['default_picture'].' AND productID='.$productID);
        $rowz = db_fetch_row($qz);
        if (strlen($rowz['filename'])>0 && file_exists( 'data/small/'.$rowz['filename']))
        $content[$i]['product_picture'] = $rowz['filename'];
        else $content[$i]['product_picture'] = null;
        */
        $variants = GetConfigurationByItemId($content[$i]['itemID']);
        $options = GetStrOptions($variants);
        if ($options != '') {
            $content[$i]['name'] = $product['name'] . '(' . $options . ')';
        } else {
            $content[$i]['name'] = $product['name'];
        }
    }
    $smarty_mail->assign('content', $content);
    $html = $smarty_mail->fetch('admin_order_notification.tpl');
    if (!CONF_ACTIVE_ORDER) {
        xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, STRING_ORDER . ' #' . $orderID . ' - ' . CONF_SHOP_NAME, $html);
    } else {
        xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, STRING_ORDER . ' #' . $orderID . ' (' . ADMIN_SEND_INACT_ORDER . ') - ' . CONF_SHOP_NAME, $html);
    }
}