Ejemplo n.º 1
0
 /** @return bool */
 public function isSameCurrency(Money $other)
 {
     return $this->currency->equals($other->currency);
 }
Ejemplo n.º 2
0
 public function refillAction($currencyId = 0)
 {
     $currency = null;
     if (!empty($_POST['currency_id'])) {
         $currency = Money\Currency::get((int) $_POST['currency_id']);
     }
     if ($currency && !empty($_POST['amount'])) {
         $pay = new Money\Pay(['data' => '', 'user_id' => \Users\User::$cur->id, 'currency_id' => $currency->id, 'sum' => (double) str_replace(',', '.', $_POST['amount']), 'type' => 'refill', 'description' => 'Пополнение баланса ' . $currency->name(), 'callback_module' => 'Money', 'callback_method' => 'refillPayRecive']);
         $pay->save();
         Tools::redirect('/money/merchants/pay/' . $pay->id);
     } else {
         $currencies = Money\Currency::getList(['where' => ['refill', 1], 'forSelect' => true]);
         $this->view->setTitle('Пополнение счета');
         $this->view->page(['data' => compact('currencies')]);
     }
 }
Ejemplo n.º 3
0
<?php

return function ($step = NULL, $params = []) {
    $currencies = [['name' => 'Доллары', 'code' => '$'], ['name' => 'Евро', 'code' => '€'], ['name' => 'Рубли', 'code' => 'Р']];
    foreach ($currencies as $currency) {
        $currencyObject = new \Money\Currency($currency);
        $currencyObject->save();
    }
    $statuses = [['name' => 'Создан', 'code' => 'new'], ['name' => 'Оплачен', 'code' => 'success'], ['name' => 'Отменен', 'code' => 'cancel'], ['name' => 'Ошибка', 'code' => 'error']];
    foreach ($statuses as $status) {
        $statusObj = new \Money\Pay\Status($status);
        $statusObj->save();
    }
    $merchants = [['name' => 'Wallet One', 'object_name' => 'WalletOne', 'image_file_id' => App::$cur->Files->uploadFromUrl(__DIR__ . '/static/images/WalletOne.png')], ['name' => 'Robokassa', 'object_name' => 'Robokassa', 'image_file_id' => App::$cur->Files->uploadFromUrl(__DIR__ . '/static/images/Robokassa.png')], ['name' => 'Payeer', 'object_name' => 'Payeer', 'image_file_id' => App::$cur->Files->uploadFromUrl(__DIR__ . '/static/images/Payeer.png')], ['name' => 'PerfectMoney', 'object_name' => 'PerfectMoney', 'image_file_id' => App::$cur->Files->uploadFromUrl(__DIR__ . '/static/images/PerfectMoney.png')]];
    $merchantsConfig = [[['name' => 'shopId', 'value' => ''], ['name' => 'secret', 'value' => '']], [['name' => 'login', 'value' => ''], ['name' => 'pass1', 'value' => ''], ['name' => 'pass2', 'value' => '']], [['name' => 'shopId', 'value' => ''], ['name' => 'secret', 'value' => '']], [[]]];
    $merchantsCurrencies = [[['currency_id' => 3, 'code' => '643']], [['currency_id' => 3, 'code' => 'RUB']], [], [['currency_id' => 1, 'code' => 'USD']]];
    foreach ($merchants as $key => $merchant) {
        $merchantObj = new \Money\Merchant($merchant);
        $merchantObj->save();
        foreach ($merchantsConfig[$key] as $config) {
            $merchantConfigObj = new Money\Merchant\Config($config);
            $merchantConfigObj->merchant_id = $merchantObj->id;
            $merchantConfigObj->save();
        }
        foreach ($merchantsCurrencies[$key] as $currency) {
            $currencyObj = new Money\Merchant\Currency($currency);
            $currencyObj->merchant_id = $merchantObj->id;
            $currencyObj->save();
        }
    }
    Inji::$inst->listen('ecommerceCartClosed', 'Money-rewardTrigger', ['module' => 'Money', 'method' => 'rewardTrigger'], true);
Ejemplo n.º 4
0
 public function getUserWallets($userId = null, $walletIdasKey = false, $forSelect = false, $transferOnly = false)
 {
     $userId = $userId ? $userId : \Users\User::$cur->id;
     if (!$userId) {
         return [];
     }
     $this->getUserBlocks($userId);
     $where = [['wallet', 1]];
     if ($transferOnly) {
         $where[] = ['transfer', 1];
     }
     $currencies = Money\Currency::getList(['where' => $where]);
     $wallets = Money\Wallet::getList(['where' => ['user_id', $userId], 'key' => 'currency_id']);
     $result = [];
     foreach ($currencies as $currency) {
         if (empty($wallets[$currency->id])) {
             $wallet = new Money\Wallet();
             $wallet->user_id = $userId;
             $wallet->currency_id = $currency->id;
             $wallet->save();
             $result[$walletIdasKey ? $wallet->id : $currency->id] = $forSelect ? $wallet->name() : $wallet;
         } else {
             $result[$walletIdasKey ? $wallets[$currency->id]->id : $currency->id] = $forSelect ? $wallets[$currency->id]->name() : $wallets[$currency->id];
         }
     }
     return $result;
 }
Ejemplo n.º 5
0
<?php

$currencies = Money\Currency::getList(['where' => ['wallet', 1]]);
if (!$currencies) {
    return false;
}
return ['name' => 'Мои кошельки', 'fullWidget' => 'Money\\cabinet/wallets', 'smallWidget' => 'Money\\cabinet/walletsWidget'];
Ejemplo n.º 6
0
echo $delCurrency ? $delCurrency->acronym() : '&nbsp;руб.';
?>
</td>
        <td></td>
      </tr>
      <tr>
        <td colspan="2"></td>
        <td class="text-right"><b>Итого</b></td>
        <td class="text-right"><?php 
foreach ($sums as $currency_id => $sum) {
    if (!$sum) {
        continue;
    }
    echo number_format($sum, 2, '.', ' ');
    if (App::$cur->money) {
        $currency = Money\Currency::get($currency_id);
        if ($currency) {
            echo '&nbsp;' . $currency->acronym();
        } else {
            echo '&nbsp;руб.';
        }
    } else {
        echo '&nbsp;руб.';
    }
    echo '<br />';
}
?>
</td>
        <td></td>
      </tr>
    </tfoot>
Ejemplo n.º 7
0
                    <thead>
                      <tr>
                        <td colspan="2">Название товара</td>
                        <td style="width:1%;min-width:150px;">Количество</td>
                        <td>Цена</td>
                        <?php 
    echo $cart->hasDiscount() ? '<td>Скидка</td>' : '';
    ?>
                        <td>Итого</td>
                        <td style="width:1%"></td>
                      </tr>
                    </thead>
                    <tbody>
                      <?php 
    if (class_exists('Money\\Currency')) {
        $defaultCurrency = Money\Currency::get(\App::$cur->ecommerce->config['defaultCurrency']);
    } else {
        $defaultCurrency = '';
    }
    foreach ($cart->cartItems as $cartItem) {
        $path = $cartItem->item->image ? $cartItem->item->image->path : '/static/system/images/no-image.png';
        ?>
                          <tr class="cart_item_id<?php 
        echo $cartItem->id;
        ?>
 item" data-cart_item_id = '<?php 
        echo $cartItem->id;
        ?>
' data-priceam = '<?php 
        echo $cartItem->price->price;
        ?>