Ejemplo n.º 1
0
 public function processPayment(Payments $payment)
 {
     $workWithCurrency = self::workWithCurrency();
     if (!in_array($payment->currency_charcode, $workWithCurrency)) {
         $currency = $workWithCurrency[0];
         $amount = round(Currency::convert($payment->amount, $payment->currency_charcode, $currency), 0);
     } else {
         $amount = $payment->amount;
         //$currency = $payment->currency_charcode;
     }
     $sign = array($this->login, $amount, $payment->id, $this->password1);
     $sign = md5(implode(':', $sign));
     $description = Yii::t('module_payment', 'Paid service #{id} ({name}) with the price {price}', array('{id}' => $payment->id, '{name}' => $payment->paidservice->name, '{price}' => $payment->amount . ' ' . $payment->currency_charcode));
     $url = $this->mode ? 'https://merchant.roboxchange.com/Index.aspx?' : 'http://test.robokassa.ru/Index.aspx?';
     $data = array('MrchLogin' => $this->login, 'OutSum' => $amount, 'InvId' => $payment->id, 'Desc' => $description, 'SignatureValue' => $sign, 'IncCurrLabel' => $this->incCurrLabel, 'Email' => Yii::app()->user->email, 'Culture' => Yii::app()->language);
     $url .= http_build_query($data);
     Yii::app()->controller->redirect($url);
 }
Ejemplo n.º 2
0
 public function processPayment(Payments $payment)
 {
     $workWithCurrency = self::workWithCurrency();
     if (!in_array($payment->currency_charcode, $workWithCurrency)) {
         $currency = $workWithCurrency[0];
         $currencyName = $currency;
         if ($currency == 'RUB') {
             $currencyName = 'RUR';
         }
         $amount = round(Currency::convert($payment->amount, $payment->currency_charcode, $currencyName), 0);
     } else {
         $amount = $payment->amount;
         $currency = $payment->currency_charcode;
     }
     /*$currencyCodeArr = self::workWithCurrencyCode();
     		$currencyCode = $currencyCodeArr[$currency];*/
     $description = Yii::t('module_payment', 'Paid service #{id} ({name}) with the price {price}', array('{id}' => $payment->id, '{name}' => $payment->paidservice->name, '{price}' => $payment->amount . ' ' . $payment->currency_charcode));
     $url = 'https://paymaster.ru/Payment/Init?';
     $data = array('LMI_MERCHANT_ID' => $this->MERCHANT_ID, 'LMI_PAYMENT_AMOUNT' => $amount, 'LMI_CURRENCY' => $currency, 'LMI_PAYMENT_NO' => $payment->id, 'LMI_PAYMENT_DESC' => $description, 'LMI_PAYER_EMAIL' => Yii::app()->user->email);
     $url .= http_build_query($data);
     Yii::app()->controller->redirect($url);
 }
Ejemplo n.º 3
0
    public function processPayment(Payments $payment)
    {
        $workWithCurrency = self::workWithCurrency();
        if (!in_array($payment->currency_charcode, $workWithCurrency)) {
            $currency = $workWithCurrency[0];
            $amount = round(Currency::convert($payment->amount, $payment->currency_charcode, $currency), 0);
        } else {
            $amount = $payment->amount;
            $currency = $payment->currency_charcode;
        }
        $description = Yii::t('module_payment', 'Paid service #{id} ({name}) with the price {price}', array('{id}' => $payment->id, '{name}' => $payment->paidservice->name, '{price}' => $payment->amount . ' ' . $payment->currency_charcode));
        $xml = "<request>\n              <version>1.2</version>\n              <merchant_id>" . $this->merchant_id . "</merchant_id>\n              <result_url>" . Yii::app()->controller->createAbsoluteUrl('/payment/main/income', array('only_return' => 1)) . "</result_url>\n              <server_url>" . Yii::app()->controller->createAbsoluteUrl('/payment/main/income', array('sys' => 'liqpay')) . "</server_url>\n              <order_id>" . $payment->id . "</order_id>\n              <amount>{$amount}</amount>\n              <currency>{$currency}</currency>\n              <description>{$description}</description>\n              <default_phone></default_phone>\n              <pay_way>card</pay_way>\n              <goods_id>" . $payment->id . "</goods_id>\n        </request>";
        $sign = base64_encode(sha1($this->merchant_sig . $xml . $this->merchant_sig, 1));
        $xml_encoded = base64_encode($xml);
        // Формирование HTML-кода платежной формы
        $form = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js"></script>';
        $form .= '<h3>' . $payment->paidservice->name . '</h3>
        <p><strong>' . tc('Cost of service') . ': ' . $payment->amount . ' ' . $payment->currency_charcode . '</strong></p>
        <p><strong id="notice_mess"></strong></p>
		';
        $form .= '<form id="payment_form" action="https://www.liqpay.com/?do=clickNbuy" method="POST">';
        $form .= '<input type="hidden" name="operation_xml" value="' . $xml_encoded . '" />
                  <input type="hidden" name="signature" value="' . $sign . '" />';
        $form .= '<input id="submit_payment_form" type="submit" value="' . tt('Pay Now', 'payment') . '"/></form>';
        $form .= '
		<script type="text/javascript">
        $(document).ready(function(){
            $("#notice_mess").html("' . tt('Please_wait_payment_Liqpay', 'payment') . '");
            $("#submit_payment_form").attr("disabled", "disabled");
            $("#payment_form").submit();
        });
        </script>
		';
        echo $form;
        exit;
    }
Ejemplo n.º 4
0
 /**
  * Возвращает сумму в указанной валюте
  * @param Currency $currency валюта в которой вернуть сумму
  * @param bool $signed
  * @return float
  */
 public function getAmountForBudget(Currency $currency, $signed)
 {
     if ($this->getType() == self::TYPE_BALANCE) {
         throw new Exception('В бюджете не должно быть балансовых операций');
     }
     if ($this->getTransferAccount() && $this->getTransferAccount()->getCurrency() == $currency) {
         $amount = $this->getTransferAmount();
     } else {
         $amount = $currency->convert($this->getAmount(), $this->getAccount()->getCurrency());
     }
     // Операции без категорий в бюджете не нужны
     // Это обычные внутренние переводы
     $sign = $this->getCategory() ? Category::TYPE_PROFIT == $this->getCategory()->getType() ? 1 : -1 : 0;
     return $signed ? $sign * abs($amount) : abs($amount);
 }
Ejemplo n.º 5
0
 public function createBankLinkPayment()
 {
     return new CPayment($this->getId(), 'Faye', Currency::convert(BasketCheckedOut::getInstance($this->getId())->price(BasketCheckedOut::TOTAL_PAYABLE), 'EEK'), 'EEK');
 }
Ejemplo n.º 6
0
function price_convert($q, $toCurrency, $fromCurrency = Currency::DEFAULT_CURRENCY, $culture = null)
{
    $r = Currency::convert($q, $toCurrency, $fromCurrency);
    return $r;
}
Ejemplo n.º 7
0
    public function processPayment(Payments $payment)
    {
        $workWithCurrency = self::workWithCurrency();
        if (!in_array($payment->currency_charcode, $workWithCurrency)) {
            $currency = $workWithCurrency[0];
            $amount = round(Currency::convert($payment->amount, $payment->currency_charcode, $currency), 0);
        } else {
            $amount = $payment->amount;
            $currency = $payment->currency_charcode;
        }
        //Секретный ключ интернет-магазина
        $key = $this->secret_key;
        $description = Yii::t('module_payment', 'Paid service #{id} ({name}) with the price {price}', array('{id}' => $payment->id, '{name}' => $payment->paidservice->name, '{price}' => $payment->amount . ' ' . $payment->currency_charcode));
        $fields = array();
        // Добавление полей формы в ассоциативный массив
        $fields["WMI_MERCHANT_ID"] = $this->merchant_id;
        $fields["WMI_PAYMENT_AMOUNT"] = $amount;
        $fields["WMI_CURRENCY_ID"] = "643";
        // RUR
        $fields["WMI_PAYMENT_NO"] = $payment->id;
        //$fields["WMI_DESCRIPTION"] = "BASE64:" . base64_encode($description);
        $fields["WMI_DESCRIPTION"] = "BASE64:" . base64_encode($this->transliterate($description));
        //$fields["WMI_DESCRIPTION"] = $this->transliterate($description);
        //$fields["WMI_EXPIRED_DATE"] = "2019-12-31T23:59:59";
        $fields["WMI_SUCCESS_URL"] = Yii::app()->controller->createAbsoluteUrl('/payment/main/income', array('sys' => 'w1', 'payment' => 'success'));
        $fields["WMI_FAIL_URL"] = Yii::app()->controller->createAbsoluteUrl('/payment/main/income', array('sys' => 'w1', 'payment' => 'fail'));
        //Если требуется задать только определенные способы оплаты, раскоментируйте данную строку и перечислите требуемые способы оплаты.
        //$fields["WMI_PTENABLED"] = array("ContactRUB", "UnistreamRUB", "SberbankRUB", "RussianPostRUB");
        //Сортировка значений внутри полей
        foreach ($fields as $name => $val) {
            if (is_array($val)) {
                usort($val, "strcasecmp");
                $fields[$name] = $val;
            }
        }
        // Формирование сообщения, путем объединения значений формы,
        // отсортированных по именам ключей в порядке возрастания.
        uksort($fields, "strcasecmp");
        $fieldValues = "";
        foreach ($fields as $value) {
            if (is_array($value)) {
                foreach ($value as $v) {
                    //Конвертация из текущей кодировки (UTF-8)
                    //необходима только если кодировка магазина отлична от Windows-1251
                    $v = iconv("utf-8", "windows-1251", $v);
                    $fieldValues .= $v;
                }
            } else {
                //Конвертация из текущей кодировки (UTF-8)
                //необходима только если кодировка магазина отлична от Windows-1251
                $value = iconv("utf-8", "windows-1251", $value);
                $fieldValues .= $value;
            }
        }
        // Формирование значения параметра WMI_SIGNATURE, путем
        // вычисления отпечатка, сформированного выше сообщения,
        // по алгоритму MD5 и представление его в Base64
        $signature = base64_encode(pack("H*", md5($fieldValues . $key)));
        //Добавление параметра WMI_SIGNATURE в словарь параметров формы
        $fields["WMI_SIGNATURE"] = $signature;
        // Формирование HTML-кода платежной формы
        $form = '<html>';
        $form .= '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">';
        $form .= '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js"></script>';
        $form .= '<body>';
        $form .= '<h3>' . $payment->paidservice->name . '</h3>
        <p><strong>' . tc('Cost of service') . ': ' . $payment->amount . ' ' . $payment->currency_charcode . '</strong></p>
        <p><strong id="notice_mess"></strong></p>
		';
        $form .= '<form id="w1_form" method="post" action="https://www.walletone.com/checkout/default.aspx" accept-charset="UTF-8">';
        foreach ($fields as $key => $val) {
            if (is_array($val)) {
                foreach ($val as $value) {
                    $form .= "<input type=\"hidden\" name=\"{$key}\" value=\"{$value}\"/>\n";
                }
            } else {
                $form .= "<input type=\"hidden\" name=\"{$key}\" value=\"{$val}\"/>\n";
            }
        }
        $form .= '<input id="submit_w1_form" type="submit" value="' . tt('Pay Now', 'payment') . '"/></form>';
        $form .= '
		<script type="text/javascript">
        $(document).ready(function(){
            $("#notice_mess").html("' . tt('Please_wait_payment_W1', 'payment') . '");
            $("#submit_w1_form").attr("disabled", "disabled");
            $("#w1_form").submit();
        });
        </script>
		';
        $form .= '</body>';
        $form .= '</html>';
        echo $form;
        exit;
    }
* and distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* Sample File
*
* @package    Google Currency Converter API
* @author     Ekachai Omkaew <*****@*****.**>
* @copyright  1997-2015 Ekachai Omkaew
* @license    GNU General Public License (GNU GPL or GPL): http://www.gnu.org/licenses/
*/
require_once 'currency.class.php';
header('Content-type: text/html; charset=ISO8859-1');
$currency = new Currency();
echo '<body style="color: white; background-color:black;">';
echo '<div style="text-align: center;">';
echo '@xxxx[{::::::::::::::::::::::::::::::::::> Convert US Dollar to Thai Bath for real time sample <::::::::::::::::::::::::::::::::::}]xxxx@<br>';
echo "Code: \$currency->convert('USD', 'THB', 1);<br>";
$result = $currency->convert('USD', 'THB', 1);
$date = new DateTime();
$datetime = $date->format('Y-m-d H:i:s');
echo "Result: current date and time is {$datetime} and 1 US Dollar = {$result} Thai Bath<br><br>";
echo '@xxxx[{::::::::::::::::::::::::::::::::::> Print all currency full/abbreviation sample <::::::::::::::::::::::::::::::::::}]xxxx@<br>';
echo "Code: \$currency->getAllCurrency();<br>";
$allCurrency = $currency->getAllCurrency();
echo "Result: <br>";
foreach ($allCurrency as $key => $value) {
    echo $value["full"] . ' = ' . $value["abb"] . '<br>';
}
echo '</div></body>';
Ejemplo n.º 9
0
 public function beforeSave()
 {
     if (!$this->square) {
         $this->square = 0;
     }
     /***изменено - вставляем пустые значения */
     if (!$this->title_ru) {
         $this->title_ru = '';
     }
     if (!$this->description_ru) {
         $this->description_ru = '';
     }
     if (!$this->description_near_ru) {
         $this->description_near_ru = '';
     }
     if (!$this->address_ru) {
         $this->address_ru = '';
     }
     if (!$this->date_up_search) {
         $timestamp = '01/01/2100 00:00:00';
         $timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
         $this->date_up_search = $timestamp->format('Y-m-d H:i:s');
     }
     if (!$this->is_special_offer) {
         $this->is_special_offer = '';
     }
     if (!$this->is_free_from) {
         $timestamp = '01/01/2000 00:00:00';
         $timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
         $this->is_free_from = $timestamp->format('Y-m-d H:i:s');
     }
     if (!$this->is_free_to) {
         $timestamp = '01/01/2100 00:00:00';
         $timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
         $this->is_free_to = $timestamp->format('Y-m-d H:i:s');
     }
     if (!$this->exchange_to_ru) {
         $this->exchange_to_ru = '';
     }
     if (!$this->note) {
         $this->note = '';
     }
     if (!$this->phone) {
         $this->phone = '';
     }
     if (!$this->sublocation_id) {
         $this->sublocation_id = 0;
     }
     if (!$this->location_id) {
         $this->location_id = '';
     }
     if (!$this->price_old) {
         $this->price_old = 0;
     }
     /*************************/
     if (!$this->land_square) {
         $this->land_square = 0;
     }
     if ($this->isNewRecord) {
         $this->owner_id = $this->owner_id ? $this->owner_id : Yii::app()->user->id;
         $userInfo = User::model()->findByPk($this->owner_id, array('select' => 'isAdmin'));
         if ($userInfo && $userInfo->isAdmin == 1) {
             $this->owner_active = self::STATUS_ACTIVE;
         }
         if ($this->active != Apartment::STATUS_DRAFT) {
             // if admin
             if ($userInfo && $userInfo->isAdmin == 1) {
                 $this->active = Apartment::STATUS_ACTIVE;
             } else {
                 if (param('useUseradsModeration')) {
                     $this->active = self::STATUS_MODERATION;
                 }
             }
         }
         $maxSorter = Yii::app()->db->createCommand()->select('MAX(sorter) as maxSorter')->from($this->tableName())->queryScalar();
         $this->sorter = $maxSorter + 1;
         if ($this->obj_type_id == 0) {
             $this->obj_type_id = Yii::app()->db->createCommand('SELECT MIN(id) FROM {{apartment_obj_type}}')->queryScalar();
         }
     }
     if (!isFree()) {
         $defaultCurrencyCharCode = Currency::getDefaultCurrencyModel()->char_code;
         if ($defaultCurrencyCharCode != $this->in_currency) {
             $this->price = (int) Currency::convert($this->price, $this->in_currency, $defaultCurrencyCharCode);
             if (isset($this->price_to) && $this->price_to) {
                 $this->price_to = (int) Currency::convert($this->price_to, $this->in_currency, $defaultCurrencyCharCode);
             }
         }
     }
     switch ($this->type) {
         case self::TYPE_SALE:
             $this->price_type = self::PRICE_SALE;
             break;
         case self::TYPE_BUY:
             $this->price_type = self::PRICE_BUY;
             break;
         case self::TYPE_RENTING:
             $this->price_type = self::PRICE_RENTING;
             break;
         case self::TYPE_CHANGE:
             $this->price_type = self::PRICE_CHANGE;
             break;
         case self::TYPE_MORTGAGE:
             $this->price_type = self::PRICE_MORTGAGE;
             break;
         case self::TYPE_PRIVATISATION:
             $this->price_type = self::PRICE_PRIVATISATION;
             break;
     }
     if (isset($_POST['set_period_activity']) && $_POST['set_period_activity'] == 1 && $this->period_activity) {
         $list = self::getPeriodActivityList();
         if (isset($list[$this->period_activity])) {
             if ($this->period_activity == 'always') {
                 $this->activity_always = 1;
             } else {
                 $this->date_end_activity = date('Y-m-d', strtotime($this->period_activity, time()));
                 $this->activity_always = 0;
             }
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 10
0
    public function processPayment(Payments $payment)
    {
        $workWithCurrency = self::workWithCurrency();
        if (!in_array($payment->currency_charcode, $workWithCurrency)) {
            $currency = $workWithCurrency[0];
            $amount = round(Currency::convert($payment->amount, $payment->currency_charcode, $currency), 0);
        } else {
            $amount = $payment->amount;
            if ($payment->currency_charcode == "RUR") {
                $payment->currency_charcode = "RUB";
            }
            $currency = $payment->currency_charcode;
        }
        $payUrl = $this->mode == Paysystem::MODE_TEST ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
        $form = '
        <h3>' . $payment->paidservice->name . '</h3>
        <p><strong>' . tc('Cost of service') . ': ' . $payment->amount . ' ' . $payment->currency_charcode . '</strong></p>
        <p><strong id="notice_mess"></strong></p>
        <form method="post" action= "' . $payUrl . '" id="paypal_form">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="business" value="' . $this->email . '">
        <input type="hidden" name="charset" value="utf-8">
        <input type="hidden" name="item_name" value="' . CHtml::encode($payment->paidservice->name) . '">
        <input type="hidden" name="custom" value="' . $payment->id . '">
        <input type="hidden" name="amount" value="' . $amount . '">
        <input type="hidden" name="currency_code" value="' . $currency . '">
        <input type="hidden" name="no_shipping" value="1">
        <input type="hidden" name="notify_url" value="' . self::getUrlResult() . '">
        <input type="hidden" name="return" value="' . self::getUrlSuccess() . '">
        <input type="hidden" name="cancel_return" value="' . self::getUrlFail() . '">
        <input type="submit" id="submit_paypal_form" value="' . tt('Pay Now', 'payment') . '">
        </form>

        <script type="text/javascript">
        $(document).ready(function(){
            $("#notice_mess").html("' . tt('Please_wait_payment', 'payment') . '");
            $("#submit_paypal_form").attr("disabled", "disabled");
            $("#paypal_form").submit();
        });
        </script>
        ';
        //return $form;
        return array('status' => Paysystem::RESULT_HTML, 'message' => $form);
    }