Example #1
0
 function createOrder()
 {
     global $gData, $gOptions;
     // Connect to Data
     $gData = data_connect();
     $goods = $_SESSION['goods_info'];
     $client =& $_SESSION['client_info'];
     $gData = data_connect();
     $command = "SELECT * FROM " . DB_NICK . "_archive_order WHERE id='" . $_SESSION['order_info']['id'] . "'";
     $res = mysql_query($command);
     $order = mysql_fetch_assoc($res);
     $success_url = 'http://' . $_SERVER['SERVER_NAME'] . '/pay_get.php?type=kaznachey&show_result=1';
     $result_url = 'http://' . $_SERVER['SERVER_NAME'] . '/pay_get.php?type=kaznachey';
     $currency = 'UAH';
     $i = 0;
     $amount = 0;
     $product_count = 0;
     $order_id = $_SESSION['order_info']['id'];
     $command_b = "SELECT * FROM " . DB_NICK . "_archive_basket WHERE order_id='" . $order_id . "'";
     $resbasket = mysql_query($command_b);
     while ($pr_item = mysql_fetch_assoc($resbasket)) {
         $img_path_true = $_SERVER["DOCUMENT_ROOT"] . "/files/store{$pr_item['store_id']}.jpg";
         $img_path = $_SERVER["SERVER_NAME"] . "/files/store{$pr_item['store_id']}.jpg";
         $products[$i]['ImageUrl'] = file_exists($img_path_true) ? $img_path : '';
         $products[$i]['ProductItemsNum'] = number_format($pr_item['how'], 2, '.', '');
         $products[$i]['ProductName'] = $pr_item['name'];
         $products[$i]['ProductPrice'] = number_format($pr_item['price'], 2, '.', '');
         $amount += $pr_item['price'] * $pr_item['how'];
         $products[$i]['ProductId'] = $pr_item['store_id'];
         $product_count += $products[$i]['ProductItemsNum'];
         $i++;
     }
     $paymentDetails = array("MerchantInternalPaymentId" => $order_id, "MerchantInternalUserId" => $order['client_id'], "EMail" => $client['email'], "PhoneNumber" => $client['CLIENT19'], "CustomMerchantInfo" => $client['CLIENT17'], "StatusUrl" => "{$result_url}", "ReturnUrl" => "{$success_url}", "BuyerCountry" => '', "BuyerFirstname" => $order['notice'], "BuyerPatronymic" => '', "BuyerLastname" => '', "BuyerStreet" => $order['notice'], "BuyerZone" => '', "BuyerZip" => '', "BuyerCity" => '', "DeliveryFirstname" => '', "DeliveryLastname" => "", "DeliveryZip" => "", "DeliveryCountry" => '', "DeliveryPatronymic" => "", "DeliveryStreet" => '', "DeliveryCity" => '', "DeliveryZone" => "");
     $product_count = number_format($product_count, 2, '.', '');
     $amount = number_format($amount, 2, '.', '');
     $selectedPaySystemId = $this->GetMerchnatInfo(false, 1);
     $signature = md5($this->merchantGuid . "{$amount}" . "{$product_count}" . $paymentDetails["MerchantInternalUserId"] . $paymentDetails["MerchantInternalPaymentId"] . $selectedPaySystemId . $this->merchnatSecretKey);
     $request = array("SelectedPaySystemId" => $selectedPaySystemId, "Products" => $products, "PaymentDetails" => $paymentDetails, "Signature" => $signature, "MerchantGuid" => $this->merchantGuid, "Currency" => $currency);
     $res = $this->sendRequestKaznachey($this->urlGetMerchantInfo, json_encode($request));
     $result = json_decode($res, true);
     if ($result['ErrorCode'] != 0) {
         return false;
     }
     return base64_decode($result["ExternalForm"]);
 }
Example #2
0
/**
 * Function pay_get
 **/
function pay_get()
{
    global $gData;
    //    echo "<pre>";
    //    print_r($_POST);
    //    exit;
    // Connect to Data
    $gData = data_connect();
    list($orderId, ) = explode(FONDY::ORDER_SEPARATOR, $_POST['order_id']);
    list(, $orderId) = explode('-', $orderId);
    $order = $gData->GetArchiveOrder($orderId * 1);
    $fondy = new Fondy();
    $settings = array('merchant' => MERCHANT_ID, 'secretkey' => MERCHANT_SECRET);
    $invoice_url = HOST_NAME . 'invoice.php?order_id=' . $orderId . '&order_sid=' . $order['sid'];
    if ($_POST['order_status'] == Fondy::ORDER_DECLINED) {
        header('location: ' . $invoice_url);
    }
    $paymentInfo = $fondy->isPaymentValid($settings, $_REQUEST);
    if ($paymentInfo === true && isset($_REQUEST['send_email']) && !empty($_REQUEST['send_email'])) {
        $content = sendEmailToAdmin($order);
        return $content;
    } else {
        header('location: ' . $invoice_url);
    }
}