本文整理汇总了PHP中Currency::getIdByIsoCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::getIdByIsoCode方法的具体用法?PHP Currency::getIdByIsoCode怎么用?PHP Currency::getIdByIsoCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::getIdByIsoCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false)
{
if (!($xml = simplexml_load_string($file))) {
return false;
}
$mainAttributes = $xml->attributes();
$this->name = strval($mainAttributes['name']);
$this->version = strval($mainAttributes['version']);
if (empty($selection)) {
$res = true;
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->_installUnits($xml);
if (!defined('_PS_MODE_DEV_') or !_PS_MODE_DEV_) {
$res &= $this->_installLanguages($xml, $install_mode);
}
if ($res and isset($this->iso_code_lang)) {
Configuration::updateValue('PS_LANG_DEFAULT', (int) Language::getIdByIso($this->iso_code_lang));
}
if ($install_mode and $res and isset($this->iso_currency)) {
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
return $res;
}
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected) or !$this->{'_install' . ucfirst($selected)}($xml)) {
return false;
}
}
return true;
}
示例2: startup
/**
* Callback function for initialization by plugin implementations.
*
* This method gets called on instantiation of a ShopgatePlugin child class and serves as __construct() replacement.
*
* Important: Initialize $this->config here if you have your own config class.
*
* @see http://wiki.shopgate.com/Shopgate_Library#startup.28.29
*/
public function startup()
{
include_once dirname(__FILE__) . '/../backward_compatibility/backward.php';
$this->config = new ShopgateConfigPrestashop();
// Without this explicit setting of the currency, the system could choose the wrong one e.g. EUR instead of PLN
$this->getContext()->currency = new Currency(Currency::getIdByIsoCode($this->config->getCurrency()));
}
示例3: postProcess
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'swipp') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array('{swipp_phone}' => Configuration::get('SWIPP_PHONE'), '{swipp_owner}' => Configuration::get('SWIPP_OWNER'), '{swipp_payment_dkk}' => Tools::displayPrice($this->module->__getPriceDkk($cart), (int) Currency::getIdByIsoCode('DKK')));
$this->module->validateOrder($cart->id, Configuration::get('SWIPP_PAYMENT_STATE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
}
示例4: refreshCurrencies
public static function refreshCurrencies()
{
parent::refreshCurrencies();
if (!($feed = Tools::simplexml_load_file(_GOINTERPAY_RATES_URL_ . Configuration::get('GOINTERPAY_MERCHANT_ID')))) {
return Tools::displayError('Cannot parse Interpay feed.');
}
foreach ($feed->rateOffer as $currency) {
if ($currency->buyCurrency != 'USD') {
continue;
}
$currency_to_update_id = Currency::getIdByIsoCode($currency->sellCurrency);
if ($currency_to_update_id) {
$currency_to_update = new Currency((int) $currency_to_update_id);
if (Validate::isLoadedObject($currency_to_update)) {
$currency_to_update->conversion_rate = (double) $currency->rate;
$currency_to_update->update();
Db::getInstance()->Execute('
UPDATE ' . _DB_PREFIX_ . 'currency
SET rateoffer_id = \'' . pSQL($currency->id) . '\', expiry = \'' . pSQL($currency->expiry) . '\'
WHERE id_currency = ' . (int) $currency_to_update_id);
}
}
}
Configuration::updateValue('GOINTERPAY_CURRENCY_UPDATE', time());
}
示例5: initContent
public function initContent()
{
if ($id_cart = Tools::getValue('id_cart')) {
$myCart = new Cart($id_cart);
if (!Validate::isLoadedObject($myCart)) {
$myCart = $this->context->cart;
}
} else {
$myCart = $this->context->cart;
}
$total_to_pay = $myCart->getOrderTotal(true, Cart::BOTH);
$currency_rub = new Currency(Currency::getIdByIsoCode('RUB'));
if ($myCart->id_currency != $currency_rub->id) {
$currency = new Currency($myCart->id_currency);
$total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate;
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
if ($postvalidate = Configuration::get('robokassa_postvalidate')) {
$order_number = $myCart->id;
} else {
if (!($order_number = Order::getOrderByCartId($myCart->id))) {
$this->module->validateOrder((int) $myCart->id, Configuration::get('PL_OS_WAITPAYMENT'), $myCart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $myCart->secure_key);
$order_number = $this->module->currentOrder;
}
}
$customer = new Customer($myCart->id_customer);
$signature = md5(Configuration::get('robokassa_login') . ':' . $total_to_pay . ':' . $order_number . ':' . Configuration::get('robokassa_password1'));
$this->context->smarty->assign(array('robokassa_login' => Configuration::get('robokassa_login'), 'robokassa_demo' => Configuration::get('robokassa_demo'), 'signature' => strtoupper($signature), 'email' => $customer->email, 'postvalidate' => $postvalidate, 'order_number' => $order_number, 'total_to_pay' => $total_to_pay, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $this->setTemplate('redirect.tpl');
}
示例6: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false, $iso_localization_pack = null)
{
if (!($xml = @simplexml_load_string($file))) {
return false;
}
libxml_clear_errors();
$main_attributes = $xml->attributes();
$this->name = (string) $main_attributes['name'];
$this->version = (string) $main_attributes['version'];
if ($iso_localization_pack) {
$id_country = (int) Country::getByIso($iso_localization_pack);
if ($id_country) {
$country = new Country($id_country);
}
if (!$id_country || !Validate::isLoadedObject($country)) {
$this->_errors[] = Tools::displayError(sprintf('Cannot load country : %1d', $id_country));
return false;
}
if (!$country->active) {
$country->active = 1;
if (!$country->update()) {
$this->_errors[] = Tools::displayError(sprintf('Cannot enable the associated country: %1s', $country->name));
}
}
}
$res = true;
if (empty($selection)) {
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml);
$res &= $this->updateDefaultGroupDisplayMethod($xml);
if (($res || $install_mode) && isset($this->iso_code_lang)) {
if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang, true))) {
$id_lang = 1;
}
if (!$install_mode) {
Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
}
} elseif (!isset($this->iso_code_lang) && $install_mode) {
$id_lang = 1;
}
if (!Language::isInstalled(Language::getIsoById($id_lang))) {
$res &= $this->_installLanguages($xml, $install_mode);
$res &= $this->_installUnits($xml);
}
if ($install_mode && $res && isset($this->iso_currency)) {
Cache::clean('Currency::getIdByIsoCode_*');
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
} else {
foreach ($selection as $selected) {
// No need to specify the install_mode because if the selection mode is used, then it's not the install
$res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false;
}
}
return $res;
}
示例7: initContent
public function initContent()
{
$cart = $this->context->cart;
$payments = array();
$payments['message'] = $this->module->l('The order status is not paid! Go to my account and then reorder');
if ($cart) {
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_curre1ncy);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$display = '';
if (Configuration::get('YA_P2P_ACTIVE')) {
$vars_p2p = Configuration::getMultiple(array('YA_P2P_NUMBER', 'YA_P2P_ACTIVE'));
$this->context->smarty->assign(array('DATA_P2P' => $vars_p2p, 'price' => number_format($total_to_pay, 2, '.', ''), 'cart' => $this->context->cart));
$display .= $this->display(__FILE__, 'payment.tpl');
}
if (Configuration::get('YA_ORG_ACTIVE')) {
$vars_org = Configuration::getMultiple(array('YA_ORG_SHOPID', 'YA_ORG_SCID', 'YA_ORG_ACTIVE', 'YA_ORG_TYPE'));
$this->context->smarty->assign(array('DATA_ORG' => $vars_org, 'id_cart' => $cart->id, 'customer' => new Customer($cart->id_customer), 'address' => new Address($this->context->cart->id_address_delivery), 'total_to_pay' => number_format($total_to_pay, 2, '.', ''), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'shop_name' => Configuration::get('PS_SHOP_NAME')));
$payments = Configuration::getMultiple(array('YA_ORG_PAYMENT_YANDEX', 'YA_ORG_PAYMENT_CARD', 'YA_ORG_PAYMENT_MOBILE', 'YA_ORG_PAYMENT_WEBMONEY', 'YA_ORG_PAYMENT_TERMINAL', 'YA_ORG_PAYMENT_SBER', 'YA_ORG_PAYMENT_PB', 'YA_ORG_PAYMENT_MA', 'YA_ORG_PAYMENT_ALFA'));
if (Configuration::get('YA_ORG_INSIDE')) {
$payments['pt'] = Tools::getValue('type');
} else {
$payments['pt'] = '';
}
}
}
$this->context->smarty->assign($payments);
return $this->setTemplate('redirectk.tpl');
}
示例8: exportCsv
public function exportCsv()
{
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"export-" . date("Ymd-His") . ".csv\"");
$db = Db::getInstance();
$is_cods = is_array(Tools::getValue('packetery_order_is_cod')) ? Tools::getValue('packetery_order_is_cod') : array();
foreach ($is_cods as $id => $is_cod) {
$db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set is_cod=' . (int) $is_cod . ' where id_order=' . (int) $id);
}
$ids = array_map('floor', is_array(Tools::getValue('packetery_order_id')) && count(Tools::getValue('packetery_order_id')) > 0 ? Tools::getValue('packetery_order_id') : array(0));
$data = $db->executeS('select
o.id_order, a.firstname, a.lastname, a.phone, a.phone_mobile, c.email,
o.total_paid total, po.id_branch, po.is_cod, o.id_currency, po.currency_branch,
a.company, a.address1, a.address2, a.postcode, a.city
from
`' . _DB_PREFIX_ . 'orders` o
join `' . _DB_PREFIX_ . 'packetery_order` po on(po.id_order=o.id_order)
join `' . _DB_PREFIX_ . 'customer` c on(c.id_customer=o.id_customer)
join `' . _DB_PREFIX_ . 'address` a on(a.id_address=o.id_address_delivery)
where o.id_order in (' . implode(',', $ids) . ')');
$cnb_rates = null;
foreach ($data as $order) {
$phone = "";
foreach (array('phone', 'phone_mobile') as $field) {
if (preg_match('/^(((?:\\+|00)?420)?[67][0-9]{8}|((?:\\+|00)?421|0)?9[0-9]{8})$/', preg_replace('/\\s+/', '', $order[$field]))) {
$phone = trim($order[$field]);
}
}
$currency = new Currency($order['id_currency']);
$total = $order['total'];
if ($currency->iso_code != $order['currency_branch']) {
$target_currency = Currency::getIdByIsoCode($order['currency_branch']);
if ($target_currency) {
$target_currency = new Currency($target_currency);
$total = round($total * $target_currency->conversion_rate / $currency->conversion_rate, 2);
} else {
if (!$cnb_rates) {
if ($data = @Tools::file_get_contents('http://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.txt')) {
$cnb_rates = array();
foreach (array_slice(explode("\n", $data), 2) as $rate) {
$rate = explode('|', $rate);
$cnb_rates[$rate[3]] = (double) preg_replace('/[^0-9.]*/', '', str_replace(',', '.', $rate[4]));
}
$cnb_rates['CZK'] = 1;
}
}
if ($cnb_rates) {
$total = round($total * $cnb_rates[$currency->iso_code] / $cnb_rates[$order['currency_branch']], 2);
}
}
}
$cod_total = $total;
if ($order['currency_branch'] == 'CZK') {
$cod_total = round($total);
}
echo ';"' . $this->csvEscape($order['id_order']) . '";"' . $this->csvEscape($order['firstname']) . '";"' . $this->csvEscape($order['lastname']) . '";"' . $this->csvEscape($order['company']) . '";"' . $this->csvEscape($order['email']) . '";"' . $this->csvEscape($phone) . '";"' . ($order['is_cod'] == 1 ? $this->csvEscape($cod_total) : "0") . '";"' . $this->csvEscape($total) . '";"' . $this->csvEscape($order['id_branch']) . '";"' . Configuration::get('PACKETERY_ESHOP_DOMAIN') . '";"' . $this->csvEscape($order['address1'] . ($order['address2'] ? ", " . $order['address2'] : "")) . '";;"' . $this->csvEscape($order['city']) . '";"' . $this->csvEscape($order['postcode']) . '"' . "\r\n";
}
$db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set exported=1 where id_order in(' . implode(',', $ids) . ')');
exit;
}
示例9: initContent
public function initContent()
{
$cart = $this->context->cart;
$payments = array();
$payments['message'] = $this->module->l('Заказ в статусе не оплачен! Перейдите в личный кабинет и нажмите перезаказ');
if ($cart) {
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_curre1ncy);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$display = '';
if (Configuration::get('YA_P2P_ACTIVE')) {
$vars_p2p = Configuration::getMultiple(array('YA_P2P_NUMBER', 'YA_P2P_ACTIVE'));
$this->context->smarty->assign(array('DATA_P2P' => $vars_p2p, 'price' => number_format($total_to_pay, 2, '.', ''), 'cart' => $this->context->cart));
$display .= $this->display(__FILE__, 'payment.tpl');
}
if (Configuration::get('YA_ORG_ACTIVE')) {
$vars_org = Configuration::getMultiple(array('YA_ORG_SHOPID', 'YA_ORG_SCID', 'YA_ORG_ACTIVE', 'YA_ORG_TYPE'));
$this->context->smarty->assign(array('DATA_ORG' => $vars_org, 'id_cart' => $cart->id, 'customer' => new Customer($cart->id_customer), 'address' => new Address($this->context->cart->id_address_delivery), 'total_to_pay' => number_format($total_to_pay, 2, '.', ''), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'shop_name' => Configuration::get('PS_SHOP_NAME')));
$payments = Configuration::getMultiple(array('YA_ORG_PAYMENT_YANDEX', 'YA_ORG_PAYMENT_CARD', 'YA_ORG_PAYMENT_MOBILE', 'YA_ORG_PAYMENT_WEBMONEY', 'YA_ORG_PAYMENT_TERMINAL', 'YA_ORG_PAYMENT_SBER', 'YA_ORG_PAYMENT_PB', 'YA_ORG_PAYMENT_MA', 'YA_ORG_PAYMENT_ALFA'));
$payments['pt'] = Tools::getValue('type');
}
//$this->module->validateOrder((int)$cart->id, _PS_OS_PREPARATION_, $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $cart->secure_key);
}
$this->context->smarty->assign($payments);
return $this->setTemplate('redirectk.tpl');
}
示例10: addData
public function addData($data, $add, $type)
{
$delivery = array();
$cart = new Cart();
if ($data->{$type}->currency == 'RUR') {
$currency_id = Currency::getIdByIsoCode('RUB');
} else {
$currency_id = Currency::getIdByIsoCode($data->cart->currency);
}
$def_currency = Configuration::get('PS_CURRENCY_DEFAULT');
$this->context->cookie->id_currency = $def_currency != $currency_id ? $currency_id : $def_currency;
$this->context->cookie->write();
$this->context->currency = new Currency($this->context->cookie->id_currency);
$cart->id_lang = (int) $this->context->cookie->id_lang;
$cart->id_currency = (int) $this->context->cookie->id_currency;
$cart->id_guest = (int) $this->context->cookie->id_guest;
$cart->add();
$this->context->cookie->id_cart = (int) $cart->id;
$this->context->cookie->write();
$buyer = isset($data->{$type}->buyer) ? $data->{$type}->buyer : '';
$b = array();
if ($add) {
$delivery = isset($data->{$type}->delivery->address) ? $data->{$type}->delivery->address : new stdClass();
$street = isset($delivery->street) ? ' Улица: ' . $delivery->street : 'Самовывоз';
$subway = isset($delivery->subway) ? ' Метро: ' . $delivery->subway : '';
$block = isset($delivery->block) ? ' Корпус/Строение: ' . $delivery->block : '';
$floor = isset($delivery->floor) ? ' Этаж: ' . $delivery->floor : '';
$house = isset($delivery->house) ? ' Дом: ' . $delivery->house : '';
$address1 = $street . $subway . $block . $floor . $house;
$customer = new Customer(Configuration::get('YA_POKUPKI_CUSTOMER'));
$address = new Address();
$address->firstname = $customer->firstname;
$address->lastname = $customer->lastname;
$address->phone_mobile = isset($buyer->phone) ? $buyer->phone : 999999;
$address->postcode = isset($delivery->postcode) ? $delivery->postcode : 00;
$address->address1 = $address1;
$address->city = isset($delivery->city) ? $delivery->city : 'Город';
$address->alias = 'pokupki_' . substr(md5(time() . _COOKIE_KEY_), 0, 7);
$address->id_customer = $customer->id;
$address->id_country = Configuration::get('PS_COUNTRY_DEFAULT');
$address->save();
$cart->id_address_invoice = (int) $address->id;
$cart->id_address_delivery = (int) $address->id;
$id_address = (int) $address->id;
$cart->update();
$cart->id_customer = (int) $customer->id;
$this->context->cookie->id_customer = (int) $customer->id;
$this->context->cookie->write();
$b = array('address' => $address, 'customer' => $customer);
}
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
$a = array('cart' => $cart);
$dd = array_merge($a, $b);
return $dd;
}
示例11: postProcess
public function postProcess()
{
parent::postProcess();
//ИД заказа
$ordernumber = Tools::getValue('InvId');
//Сумма заказа
$amount = Tools::getValue('OutSum');
$signature = md5($amount . ':' . $ordernumber . ':' . Configuration::get('robokassa_password2'));
//Проверка подписи
if (strtoupper($signature) != Tools::getValue('SignatureValue')) {
robokassa::validateAnsver($this->module->l('Invalid signature'));
}
if (Configuration::get('robokassa_postvalidate')) {
$cart = new Cart((int) $ordernumber);
//Проверка существования заказа
if (!Validate::isLoadedObject($cart)) {
robokassa::validateAnsver($this->module->l('Cart does not exist'));
}
$total_to_pay = $cart->getOrderTotal(true, Cart::BOTH);
$currency_rub = new Currency(Currency::getIdByIsoCode('RUB'));
if ($cart->id_currency != $currency_rub->id) {
$currency = new Currency($cart->id_currency);
$total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate;
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
//Проверка суммы заказа
if ($amount != $total_to_pay) {
robokassa::validateAnsver($this->module->l('Incorrect payment summ'));
}
$this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_PAYMENT'), $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $cart->secure_key);
} else {
$order = new Order((int) $ordernumber);
//Проверка существования заказа
if (!Validate::isLoadedObject($order)) {
robokassa::validateAnsver($this->module->l('Order does not exist'));
}
$total_to_pay = $order->total_paid;
$currency_rub = new Currency(Currency::getIdByIsoCode('RUB'));
if ($order->id_currency != $currency_rub->id) {
$currency = new Currency($order->id_currency);
$total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate;
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
//Проверка суммы заказа
if ($amount != $total_to_pay) {
robokassa::validateAnsver($this->module->l('Incorrect payment summ'));
}
//Меняем статус заказа
$history = new OrderHistory();
$history->id_order = $ordernumber;
$history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), $ordernumber);
$history->addWithemail(true);
}
die('OK' . $ordernumber);
}
示例12: initContent
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}
$dkkC = new Currency(Currency::getIdByIsoCode('DKK'));
$this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'cust_currency' => $cart->id_currency, 'name_currency' => $dkkC->name, 'id_currency_accepted' => $dkkC->id, 'id_currency' => $cart->id_currency, 'currencies' => $this->module->getCurrency((int) $cart->id_currency), 'total' => $this->module->__getPriceDkk($cart), 'this_path' => $this->module->getPathUri(), 'this_path_bw' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/'));
$this->setTemplate('payment_execution.tpl');
}
示例13: postProcess
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
// Log requests from Privat API side in Debug mode.
if (Configuration::get('PRIVAT24_DEBUG_MODE')) {
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_ . '/log/' . $this->module->name . '_' . date('Ymd_His') . '_response.log');
$logger->logError($_POST);
}
$payment = array();
parse_str(Tools::getValue('payment'), $payment);
$hash = sha1(md5(Tools::getValue('payment') . $this->module->merchant_password));
if ($payment && $hash === Tools::getValue('signature')) {
if ($payment['state'] == 'ok') {
$state = Configuration::get('PRIVAT24_WAITINGPAYMENT_OS');
$cart_id = (int) $payment['order'];
$order = new Order(Order::getOrderByCartId($cart_id));
if (!Validate::isLoadedObject($order)) {
PrestaShopLogger::addLog('Privat24: cannot get order by cart id ' . $cart_id, 3);
die;
}
if ($order->getCurrentState() != $state) {
PrestaShopLogger::addLog(sprintf('Privat24: order id %s current state %s !== expected state %s', $order->id, $order->getCurrentState(), $state), 3);
die;
}
// Check paid currency and paid amount.
$id_currency = Currency::getIdByIsoCode($payment['ccy']);
if (!$id_currency) {
PrestaShopLogger::addLog(sprintf('Privat24: order id %s cannot get currency id by iso code: %s', $order->id, $payment['ccy']), 3);
die;
}
if ($order->id_currency != $id_currency) {
PrestaShopLogger::addLog(sprintf('Privat 24: order id %s, order currency id %s does not match with %s', $order->id, $order->id_currency, $id_currency), 3);
die;
}
if ((double) $order->total_paid != (double) $payment['amt']) {
PrestaShopLogger::addLog(sprintf('Privat 24: order id %s order total paid %s does not match %s', $order->id, $order->total_paid, $payment['amt']), 3);
die;
}
$order_history = new OrderHistory();
$order_history->id_order = $order->id;
$order_history->changeIdOrderState(_PS_OS_PAYMENT_, $order->id);
$order_history->addWithemail();
$this->setPaymentTransaction($order, $payment);
$this->module->paymentNotify($order, $payment);
PrestaShopLogger::addLog(sprintf('Privat24 payment accepted: order id: %s, amount: %s, ref: %s', $order->id, $payment['amt'], $payment['ref']), 1);
} else {
PrestaShopLogger::addLog(sprintf('Privat24 payment failed: state: %s, order: %s, ref: %s', $payment['state'], $payment['order'], $payment['ref']), 3, null, null, null, true);
}
} else {
PrestaShopLogger::addLog('Privat24: Payment callback bad signature.', 3, null, null, null, true);
}
die;
}
示例14: exists
/**
* Check if a curency already exists.
*
* @param int|string $iso_code int for iso code number string for iso code
* @return boolean
*/
public static function exists($iso_code)
{
if (is_int($iso_code)) {
$id_currency_exists = Currency::getIdByIsoCodeNum($iso_code);
} else {
$id_currency_exists = Currency::getIdByIsoCode($iso_code);
}
if ($id_currency_exists) {
return true;
} else {
return false;
}
}
示例15: postProcess
public function postProcess()
{
parent::postProcess();
$log_on = Configuration::get('YA_P2P_LOGGING_ON');
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$this->myCart = $this->context->cart;
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_currency);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
if ($total_to_pay > 0 && $total_to_pay < 1) {
$total_to_pay_limit = '1.00';
} else {
$total_to_pay_limit = number_format($total_to_pay, 2, '.', '');
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
$this->module->payment_status = '';
$code = Tools::getValue('code');
$type = Tools::getValue('type');
if (empty($code)) {
$scope = array("payment.to-account(\"" . Configuration::get('YA_P2P_NUMBER') . "\",\"account\").limit(," . $total_to_pay_limit . ")", "money-source(\"wallet\",\"card\")");
if ($type == 'wallet') {
if ($log_on) {
$this->module->log_save('p2p_redirect: ' . $this->module->l('Type wallet'));
}
$auth_url = API::buildObtainTokenUrl(Configuration::get('YA_P2P_IDENTIFICATOR'), $this->context->link->getModuleLink('yamodule', 'redirect_wallet', array(), true), $scope);
} elseif ($type == 'card') {
if ($log_on) {
$this->module->log_save('redirect: ' . $this->module->l('Type card'));
}
Tools::redirect($this->context->link->getModuleLink('yamodule', 'redirect_card', array('code' => true, 'cnf' => true), true), '');
}
if ($log_on) {
$this->module->log_save('p2p_redirect: url = ' . $auth_url);
}
Tools::redirect($auth_url, '');
}
}