本文整理汇总了PHP中Currency::getCurrencyInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::getCurrencyInstance方法的具体用法?PHP Currency::getCurrencyInstance怎么用?PHP Currency::getCurrencyInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::getCurrencyInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookPayment
public function hookPayment($params)
{
$cart = $params['cart'];
$customer = new Customer((int) $cart->id_customer);
$deliveryAddress = new Address((int) $cart->id_address_delivery);
$country = new Country((int) $deliveryAddress->id_country);
$currency = Currency::getCurrencyInstance($this->context->cookie->id_currency);
if (!Validate::isLoadedObject($currency)) {
return false;
}
$phone = Tools::safeOutput($deliveryAddress->phone_mobile);
if (empty($phone)) {
$phone = Tools::safeOutput($deliveryAddress->phone);
}
$public_key = Configuration::get('SIMPLEPAY_LIVE_PUBLIC_KEY');
if ((int) Configuration::get('SIMPLEPAY_TEST_MODE')) {
$public_key = Configuration::get('SIMPLEPAY_TEST_PUBLIC_KEY');
}
$this->context->smarty->assign('email', $customer->email);
$this->context->smarty->assign('phone', $phone);
$this->context->smarty->assign('description', Configuration::get('SIMPLEPAY_PAYMENT_DESCRIPTION') . ' #' . $cart->id);
$this->context->smarty->assign('address', Tools::safeOutput($deliveryAddress->address1 . ' ' . $deliveryAddress->address2));
$this->context->smarty->assign('postal_code', Tools::safeOutput($deliveryAddress->postcode));
$this->context->smarty->assign('city', Tools::safeOutput($deliveryAddress->city));
$this->context->smarty->assign('country', $country->iso_code);
$this->context->smarty->assign('amount', $cart->getOrderTotal());
$this->context->smarty->assign('currency', $currency);
$this->context->smarty->assign('public_key', $public_key);
$this->context->smarty->assign('module_dir', $this->_path);
$this->context->smarty->assign('cart_id', $cart->id);
$this->context->smarty->assign('cart_id', $cart->id);
$this->context->smarty->assign('image', Configuration::get('SIMPLEPAY_IMAGE'));
return $this->display(__FILE__, 'views/templates/hook/payment.tpl');
}
示例2: hookPayment
public function hookPayment($params)
{
$currency = Currency::getCurrencyInstance($this->context->cookie->id_currency);
if (!Validate::isLoadedObject($currency)) {
return false;
}
$isFailed = Tools::getValue('paynetzerror');
$this->context->smarty->assign('x_invoice_num', (int) $params['cart']->id);
$this->context->smarty->assign('isFailed', $isFailed);
return $this->display(__FILE__, 'views/templates/hook/paynetz.tpl');
}
示例3: getContent
public function getContent()
{
if (Tools::isSubmit('btnSubmit')) {
$this->postProcess();
}
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
$id_lang = Configuration::get('PS_LANG_DEFAULT');
$carriers = Carrier::getCarriers($id_lang, false, false, false, null, 0);
$config = Configuration::getMultiple(array('COD_ENABLED', 'COD_SHOW_ZERO', 'COD_TITLE', 'COD_ORDER_STATUS', 'COD_SPECIFIC_COUNTRY', 'COD_COUNTRY', 'COD_MINIMUM_ORDER', 'COD_MAXIMUM_ORDER', 'COD_COST_CALCULATION', 'COD_COST_INLAND', 'COD_COST_FOREIGN', 'COD_FREE_FROM', 'COD_CUSTOM_TEXT', 'COD_DISALLOW_METHODS', 'COD_DISALLOWED_METHODS', 'COD_ORDER_TIME'));
$this->context->smarty->assign(array('module_name' => $this->name, 'displayName' => $this->displayName, 'order_time' => $config['COD_ORDER_TIME'], 'request_uri' => $_SERVER['REQUEST_URI'], 'enabled' => $config['COD_ENABLED'], 'show_zero' => $config['COD_SHOW_ZERO'], 'title' => $config['COD_TITLE'], 'orders_status' => OrderStateCore::getOrderStates((int) $this->context->language->id), 'order_status' => $config['COD_ORDER_STATUS'], 'specific_country' => $config['COD_SPECIFIC_COUNTRY'], 'country' => ($a = unserialize($config['COD_COUNTRY'])) ? $a : array(), 'all_countrys' => Country::getCountries((int) $this->context->language->id, true), 'minimum_order' => $config['COD_MINIMUM_ORDER'], 'maximum_order' => $config['COD_MAXIMUM_ORDER'], 'cost_calculation' => $config['COD_COST_CALCULATION'], 'cost_inland' => $config['COD_COST_INLAND'], 'cost_foreign' => $config['COD_COST_FOREIGN'], 'free_from' => $config['COD_FREE_FROM'], 'custom_text' => $config['COD_CUSTOM_TEXT'], 'disallow_methods' => $config['COD_DISALLOW_METHODS'], 'carriers' => $carriers, 'disallowed_methods' => ($a = unserialize($config['COD_DISALLOWED_METHODS'])) ? $a : array(), 'currency_sign' => $currency->sign));
$this->context->controller->addJS($this->local_path . '/views/js/script.js', 'all');
$output = $this->context->smarty->fetch($this->local_path . '/views/templates/admin/configure.tpl');
return $output;
}
示例4: setCurrency
/**
* Set cookie currency from POST or default currency
*
* @param $cookie
* @return JeproshopCurrencyModelCurrency object
*/
public static function setCurrency($cookie)
{
$app = JFactory::getApplication();
if ($app->input->get('SubmitCurrency')) {
if (isset($_POST['currency_id']) && is_numeric($_POST['currency_id'])) {
$currency = JeproshopCurrencyModelCurrency::getCurrencyInstance($_POST['currency_id']);
if (is_object($currency, 'currency_id') && $currency->currency_id && !$currency->deleted && $currency->isAssociatedToShop()) {
$cookie->currency_id = (int) $currency->currency_id;
}
}
}
$currency = null;
if ((int) $cookie->currency_id) {
$currency = JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $cookie->currency_id);
}
if (!JeproshopTools::isLoadedObject($currency, 'currency_id') || (bool) $currency->deleted || !(bool) $currency->published) {
$currency = JeproshopCurrencyModelCurrency::getCurrencyInstance(JeproshopSettingModelSetting::getValue('default_currency'));
}
$cookie->currency_id = (int) $currency->currency_id;
if ($currency->isAssociatedToShop()) {
return $currency;
} else {
// get currency from context
$currency = JeproshopShopModelShop::getEntityIds('currency', JeproshopContext::getContext()->shop->shop_id, true, true);
if (isset($currency[0]) && $currency[0]['id_currency']) {
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int) $cookie->id_currency);
}
}
return $currency;
}
示例5: geolocationManagement
protected function geolocationManagement($default_country)
{
if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
/* Check if Maxmind Database exists */
if (file_exists(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat')) {
if (!isset($this->context->cookie->iso_code_country) || isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))) {
include_once _PS_GEOIP_DIR_ . 'geoipcity.inc';
$gi = geoip_open(realpath(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat'), GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
if (is_object($record)) {
if (!in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && !FrontController::isInWhitelistForGeolocation()) {
if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_) {
$this->restrictedCountry = true;
} elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_) {
$this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => $record->country_name));
}
} else {
$has_been_set = !isset($this->context->cookie->iso_code_country);
$this->context->cookie->iso_code_country = strtoupper($record->country_code);
}
}
}
if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country)) {
$this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country)))) {
/* Update defaultCountry */
if ($default_country->iso_code != $this->context->cookie->iso_code_country) {
$default_country = new Country($id_country);
}
if (isset($has_been_set) && $has_been_set) {
$this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($default_country->id_currency ? (int) $default_country->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id;
}
return $default_country;
} elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ && !FrontController::isInWhitelistForGeolocation()) {
$this->restrictedCountry = true;
} elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ && !FrontController::isInWhitelistForGeolocation()) {
$this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => 'Undefined'));
}
} else {
Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0);
}
}
return false;
}
示例6: displayListContent
public function displayListContent($token = NULL)
{
/* Display results in a table
*
* align : determine value alignment
* prefix : displayed before value
* suffix : displayed after value
* image : object image
* icon : icon determined by values
* active : allow to toggle status
*/
global $currentIndex, $cookie;
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$id_category = 1;
// default categ
$irow = 0;
if ($this->_list and isset($this->fieldsDisplay['position'])) {
$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
sort($positions);
}
if ($this->_list) {
$isCms = false;
if (preg_match('/cms/Ui', $this->identifier)) {
$isCms = true;
}
$keyToGet = 'id_' . ($isCms ? 'cms_' : '') . 'category' . (in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
foreach ($this->_list as $tr) {
$id = $tr[$this->identifier];
echo '<tr' . (array_key_exists($this->identifier, $this->identifiersDnd) ? ' id="tr_' . (($id_category = (int) Tools::getValue('id_' . ($isCms ? 'cms_' : '') . 'category', '1')) ? $id_category : '') . '_' . $id . '_' . $tr['position'] . '"' : '') . ($irow++ % 2 ? ' class="alt_row"' : '') . ' ' . ((isset($tr['color']) and $this->colorOnBackground) ? 'style="background-color: ' . $tr['color'] . '"' : '') . '>
<td class="center">';
if ($this->delete and (!isset($this->_listSkipDelete) or !in_array($id, $this->_listSkipDelete))) {
echo '<input type="checkbox" name="' . $this->table . 'Box[]" value="' . $id . '" class="noborder" />';
}
echo '</td>';
foreach ($this->fieldsDisplay as $key => $params) {
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
echo '
<td ' . (isset($params['position']) ? ' id="td_' . (isset($id_category) and $id_category ? $id_category : 0) . '_' . $id . '"' : '') . ' class="' . ((!isset($this->noLink) or !$this->noLink) ? 'pointer' : '') . ((isset($params['position']) and $this->_orderBy == 'position') ? ' dragHandle' : '') . (isset($params['align']) ? ' ' . $params['align'] : '') . '" ';
if (!isset($params['position']) and (!isset($this->noLink) or !$this->noLink)) {
echo ' onclick="document.location = \'' . $currentIndex . '&' . $this->identifier . '=' . $id . ($this->view ? '&view' : '&update') . $this->table . '&token=' . ($token != NULL ? $token : $this->token) . '\'">' . (isset($params['prefix']) ? $params['prefix'] : '');
} else {
echo '>';
}
if (isset($params['active']) and isset($tr[$key])) {
$this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product'));
} elseif (isset($params['activeVisu']) and isset($tr[$key])) {
echo '<img src="../img/admin/' . ($tr[$key] ? 'enabled.gif' : 'disabled.gif') . '"
alt="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" title="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" />';
} elseif (isset($params['position'])) {
if ($this->_orderBy == 'position' and $this->_orderWay != 'DESC') {
echo '<a' . (!($tr[$key] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . '
&way=1&position=' . (int) ($tr['position'] + 1) . '&token=' . ($token != NULL ? $token : $this->token) . '">
<img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'down' : 'up') . '.gif"
alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a>';
echo '<a' . (!($tr[$key] != $positions[0]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . '
&way=0&position=' . (int) ($tr['position'] - 1) . '&token=' . ($token != NULL ? $token : $this->token) . '">
<img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'up' : 'down') . '.gif"
alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a>';
} else {
echo (int) ($tr[$key] + 1);
}
} elseif (isset($params['image'])) {
// item_id is the product id in a product image context, else it is the image id.
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
// If it's a product image
if (isset($tr['id_image'])) {
$image = new Image((int) $tr['id_image']);
$path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . $image->getExistingImgPath() . '.' . $this->imageType;
} else {
$path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . $item_id . (isset($tr['id_image']) ? '-' . (int) $tr['id_image'] : '') . '.' . $this->imageType;
}
echo cacheImage($path_to_image, $this->table . '_mini_' . $item_id . '.' . $this->imageType, 45, $this->imageType);
} elseif (isset($params['icon']) and (isset($params['icon'][$tr[$key]]) or isset($params['icon']['default']))) {
echo '<img src="../img/admin/' . (isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'] . '" alt="' . $tr[$key]) . '" title="' . $tr[$key] . '" />';
} elseif (isset($params['price'])) {
echo Tools::displayPrice($tr[$key], isset($params['currency']) ? Currency::getCurrencyInstance((int) $tr['id_currency']) : $currency, false);
} elseif (isset($params['float'])) {
echo rtrim(rtrim($tr[$key], '0'), '.');
} elseif (isset($params['type']) and $params['type'] == 'date') {
echo Tools::displayDate($tr[$key], (int) $cookie->id_lang);
} elseif (isset($params['type']) and $params['type'] == 'datetime') {
echo Tools::displayDate($tr[$key], (int) $cookie->id_lang, true);
} elseif (isset($tr[$key])) {
$echo = $key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']) . '...' : $tr[$key];
echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo;
} else {
echo '--';
}
echo (isset($params['suffix']) ? $params['suffix'] : '') . '</td>';
}
if ($this->edit or $this->delete or $this->view and $this->view !== 'noActionColumn') {
echo '<td class="center" style="white-space: nowrap;">';
if ($this->view) {
$this->_displayViewLink($token, $id);
}
if ($this->edit) {
$this->_displayEditLink($token, $id);
}
if ($this->delete and (!isset($this->_listSkipDelete) or !in_array($id, $this->_listSkipDelete))) {
//.........这里部分代码省略.........
示例7: convertPrice
/**
* Return price converted
*
* @param float $price Product price
* @param object|array $currency Current currency object
* @param boolean $to_currency convert to currency or from currency to default currency
* @param Context $context
*
* @return float Price
*/
public static function convertPrice($price, $currency = null, $to_currency = true, Context $context = null)
{
static $default_currency = null;
if ($default_currency === null) {
$default_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
}
if (!$context) {
$context = Context::getContext();
}
if ($currency === null) {
$currency = $context->currency;
} elseif (is_numeric($currency)) {
$currency = Currency::getCurrencyInstance($currency);
}
$c_id = is_array($currency) ? $currency['id_currency'] : $currency->id;
$c_rate = is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate;
if ($c_id != $default_currency) {
if ($to_currency) {
$price *= $c_rate;
} else {
$price /= $c_rate;
}
}
return $price;
}
示例8: setCurrency
public function setCurrency()
{
$cookie = $this->context->cookie;
if (Tools::getValue('id_currency') && is_numeric(Tools::getValue('id_currency'))) {
$currency = Currency::getCurrencyInstance(Tools::getValue('id_currency'));
if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop()) {
$cookie->id_currency = (int) $currency->id;
}
}
$currency = null;
if ((int) $cookie->id_currency) {
$currency = Currency::getCurrencyInstance((int) $cookie->id_currency);
}
if (!Validate::isLoadedObject($currency) || (bool) $currency->deleted || !(bool) $currency->active) {
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
}
$cookie->id_currency = (int) $currency->id;
$this->context->currency->id = $cookie->id_currency;
if ($currency->isAssociatedToShop()) {
return $currency;
} else {
// get currency from context
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id, true, true);
if (isset($currency[0]) && $currency[0]['id_currency']) {
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int) $cookie->id_currency);
}
}
$this->context->currency->id = $cookie->id_currency;
return $currency;
}
示例9: getAjaxProduct
public static function getAjaxProduct($id_referrer, $id_product, $employee = null)
{
$context = Context::getContext();
$product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'));
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
$referrer = new Referrer($id_referrer);
$stats_visits = $referrer->getStatsVisits($id_product, $employee);
$registrations = $referrer->getRegistrations($id_product, $employee);
$stats_sales = $referrer->getStatsSales($id_product, $employee);
// If it's a product and it has no visits nor orders
if ((int) $id_product && !$stats_visits['visits'] && !$stats_sales['orders']) {
exit;
}
$json_array = array('id_product' => (int) $product->id, 'product_name' => addslashes($product->name), 'uniqs' => (int) $stats_visits['uniqs'], 'visitors' => (int) $stats_visits['visitors'], 'visits' => (int) $stats_visits['visits'], 'pages' => (int) $stats_visits['pages'], 'registrations' => (int) $registrations, 'orders' => (int) $stats_sales['orders'], 'sales' => Tools::displayPrice($stats_sales['sales'], $currency), 'cart' => Tools::displayPrice((int) $stats_sales['orders'] ? $stats_sales['sales'] / (int) $stats_sales['orders'] : 0, $currency), 'reg_rate' => number_format((int) $stats_visits['uniqs'] ? (int) $registrations / (int) $stats_visits['uniqs'] : 0, 4, '.', ''), 'order_rate' => number_format((int) $stats_visits['uniqs'] ? (int) $stats_sales['orders'] / (int) $stats_visits['uniqs'] : 0, 4, '.', ''), 'click_fee' => Tools::displayPrice((int) $stats_visits['visits'] * $referrer->click_fee, $currency), 'base_fee' => Tools::displayPrice($stats_sales['orders'] * $referrer->base_fee, $currency), 'percent_fee' => Tools::displayPrice($stats_sales['sales'] * $referrer->percent_fee / 100, $currency));
die('[' . Tools::jsonEncode($json_array) . ']');
}
示例10: hookPayment
public function hookPayment($params)
{
$currency = Currency::getCurrencyInstance($this->context->cookie->id_currency);
if (!Validate::isLoadedObject($currency) || $currency->iso_code != 'USD') {
return false;
}
if (Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
$isFailed = Tools::getValue('aimerror');
$cards = array();
$cards['visa'] = Configuration::get('AUTHORIZE_AIM_CARD_VISA') == 'on';
$cards['mastercard'] = Configuration::get('AUTHORIZE_AIM_CARD_MASTERCARD') == 'on';
$cards['discover'] = Configuration::get('AUTHORIZE_AIM_CARD_DISCOVER') == 'on';
$cards['ax'] = Configuration::get('AUTHORIZE_AIM_CARD_AX') == 'on';
if (method_exists('Tools', 'getShopDomainSsl')) {
$url = 'https://' . Tools::getShopDomainSsl() . __PS_BASE_URI__ . '/modules/' . $this->name . '/';
} else {
$url = 'https://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . '/';
}
$this->context->smarty->assign('x_invoice_num', (int) $params['cart']->id);
$this->context->smarty->assign('cards', $cards);
$this->context->smarty->assign('isFailed', $isFailed);
$this->context->smarty->assign('new_base_dir', $url);
return $this->display(__FILE__, 'authorizeaim.tpl');
}
}
示例11: execPayment
public function execPayment($cart)
{
// Create invoice
$currency = Currency::getCurrencyInstance((int) $cart->id_currency);
$options = $_POST;
$options['transactionSpeed'] = Configuration::get('bitpay_TXSPEED');
$options['currency'] = $currency->iso_code;
$total = $cart->getOrderTotal(true);
$options['notificationURL'] = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/ipn.php';
if (_PS_VERSION_ <= '1.5') {
$options['redirectURL'] = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $cart->id . '&id_module=' . $this->id . '&id_order=' . $this->currentOrder;
} else {
$options['redirectURL'] = Context::getContext()->link->getModuleLink('bitpay', 'validation');
}
$options['posData'] = '{"cart_id": "' . $cart->id . '"';
$options['posData'] .= ', "hash": "' . crypt($cart->id, Configuration::get('bitpay_APIKEY')) . '"';
$this->key = $this->context->customer->secure_key;
$options['posData'] .= ', "key": "' . $this->key . '"}';
$options['orderID'] = $cart->id;
$options['price'] = $total;
$options['fullNotifications'] = true;
$postOptions = array('orderID', 'itemDesc', 'itemCode', 'notificationEmail', 'notificationURL', 'redirectURL', 'posData', 'price', 'currency', 'physical', 'fullNotifications', 'transactionSpeed', 'buyerName', 'buyerAddress1', 'buyerAddress2', 'buyerCity', 'buyerState', 'buyerZip', 'buyerEmail', 'buyerPhone');
foreach ($postOptions as $o) {
if (array_key_exists($o, $options)) {
$post[$o] = $options[$o];
}
}
if (function_exists('json_encode')) {
$post = json_encode($post);
} else {
$post = rmJSONencode($post);
}
// Call BitPay
$curl = curl_init($this->apiurl . '/api/invoice/');
$length = 0;
if ($post) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$length = strlen($post);
}
$uname = base64_encode(Configuration::get('bitpay_APIKEY'));
$header = array('Content-Type: application/json', 'Content-Length: ' . $length, 'Authorization: Basic ' . $uname, 'X-BitPay-Plugin-Info: prestashop0.4');
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_PORT, $this->sslport);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
// verify certificate (1)
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);
// check existence of CN and verify that it matches hostname (2)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
$responseString = curl_exec($curl);
if (!$responseString) {
$response = curl_error($curl);
die(Tools::displayError("Error: no data returned from API server!"));
} else {
if (function_exists('json_decode')) {
$response = json_decode($responseString, true);
} else {
$response = rmJSONdecode($responseString);
}
}
curl_close($curl);
if (isset($response['error'])) {
bplog($response['error']);
die(Tools::displayError("Error occurred! (" . $response['error']['type'] . " - " . $response['error']['message'] . ")"));
} else {
if (!$response['url']) {
die(Tools::displayError("Error: Response did not include invoice url!"));
} else {
header('Location: ' . $response['url']);
}
}
}
示例12: displayPrice
private function displayPrice($data, $id_currency, $resume = false)
{
$currency = $id_currency;
if ($resume !== false) {
if ($id_currency == self::CURRENCY_NOT_SET) {
$currency = $this->def_currency;
}
} elseif ($this->currency_code != self::CURRENCY_NOT_SET) {
$currency = $this->currency_code;
}
return Tools::displayPrice($data, Currency::getCurrencyInstance($currency));
}
示例13: invoice
/**
* Main
*
* @param object $order Order
* @param string $mode Download or display (optional)
*/
public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
{
global $cookie, $ecotax;
if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
die('Invalid order or invalid order state');
}
self::$order = $order;
self::$orderSlip = $slip;
self::$delivery = $delivery;
self::$_iso = strtoupper(Language::getIsoById(intval(self::$order->id_lang)));
if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
die(self::l('No price display method defined for the customer group'));
}
if (!$multiple) {
$pdf = new PDF('P', 'mm', 'A4');
}
$pdf->SetAutoPageBreak(true, 35);
$pdf->StartPageGroup();
self::$currency = Currency::getCurrencyInstance(intval(self::$order->id_currency));
$pdf->AliasNbPages();
$pdf->AddPage();
/* Display address information */
$invoice_address = new Address(intval($order->id_address_invoice));
$invoiceState = $invoice_address->id_state ? new State($invoice_address->id_state) : false;
$delivery_address = new Address(intval($order->id_address_delivery));
$deliveryState = $delivery_address->id_state ? new State($delivery_address->id_state) : false;
$shop_country = Configuration::get('PS_SHOP_COUNTRY');
$invoice_customer = new Customer(intval($invoice_address->id_customer));
$width = 100;
$pdf->SetX(10);
$pdf->SetY(25);
$pdf->SetFont(self::fontname(), '', 12);
$pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
$pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), '', 9);
if (!empty($delivery_address->company) or !empty($invoice_address->company)) {
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->company), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->company), 0, 'L');
$pdf->Ln(5);
}
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->lastname), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->lastname), 0, 'L');
$pdf->Ln(5);
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address1), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address1), 0, 'L');
$pdf->Ln(5);
if (!empty($invoice_address->address2) or !empty($delivery_address->address2)) {
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address2), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address2), 0, 'L');
$pdf->Ln(5);
}
$pdf->Cell($width, 10, $delivery_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->city), 0, 'L');
$pdf->Cell($width, 10, $invoice_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->city), 0, 'L');
$pdf->Ln(5);
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->country . ($deliveryState ? ' - ' . $deliveryState->name : '')), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->country . ($invoiceState ? ' - ' . $invoiceState->name : '')), 0, 'L');
$pdf->Ln(5);
$pdf->Cell($width, 10, $delivery_address->phone, 0, 'L');
if ($invoice_customer->dni != NULL) {
$pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_customer->dni), 0, 'L');
}
if (!empty($delivery_address->phone_mobile)) {
$pdf->Ln(5);
$pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L');
}
/*
* display order information
*/
$carrier = new Carrier(self::$order->id_carrier);
if ($carrier->name == '0') {
$carrier->name = Configuration::get('PS_SHOP_NAME');
}
$history = self::$order->getHistory(self::$order->id_lang);
foreach ($history as $h) {
if ($h['id_order_state'] == _PS_OS_SHIPPING_) {
$shipping_date = $h['date_add'];
}
}
$pdf->Ln(12);
$pdf->SetFillColor(240, 240, 240);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont(self::fontname(), '', 9);
if (self::$orderSlip) {
$pdf->Cell(0, 6, self::l('SLIP #') . sprintf('%06d', self::$orderSlip->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
} elseif (self::$delivery) {
$pdf->Cell(0, 6, self::l('DELIVERY SLIP #') . Configuration::get('PS_DELIVERY_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$delivery) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
} else {
$pdf->Cell(0, 6, self::l('INVOICE #') . Configuration::get('PS_INVOICE_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$order->invoice_number) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
}
$pdf->Cell(55, 6, self::l('Order #') . sprintf('%06d', self::$order->id), 'L', 0);
$pdf->Cell(70, 6, self::l('Carrier:') . ($order->gift ? ' ' . Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
$pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
$pdf->Ln(5);
//.........这里部分代码省略.........
示例14: hookPayment
/**
* @brief to display the payment option, so the customer will pay by merchant ware
*/
public function hookPayment($params)
{
$currency = Currency::getCurrencyInstance($this->context->cookie->id_currency);
if (!Validate::isLoadedObject($currency) || $currency->iso_code != 'USD') {
return false;
}
$demo = 1;
if ($demo == 1 || Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && Tools::strtolower($_SERVER['HTTPS']) != 'off') {
$isFailed = Tools::getValue('aimerror');
$cards = array();
$achsetting = array();
$midtype = array();
$cards['visa'] = Configuration::get('ALLIANCE_CARD_VISA') == 'on';
$cards['mastercard'] = Configuration::get('ALLIANCE_CARD_MASTERCARD') == 'on';
$cards['discover'] = Configuration::get('ALLIANCE_CARD_DISCOVER') == 'on';
$cards['ax'] = Configuration::get('ALLIANCE_CARD_AX') == 'on';
$achsetting['identity'] = Configuration::get('ALLIANCEACH_IDENTITY');
$achsetting['driver'] = Configuration::get('ALLIANCEACH_DRIVER');
$midtype['authnet'] = Configuration::get('ALLIANCE_ENABLE');
$midtype['achmod'] = Configuration::get('ALLIANCEACH_ENABLE');
if (method_exists('Tools', 'getShopDomainSsl')) {
$url = 'https://' . Tools::getShopDomainSsl() . __PS_BASE_URI__ . '/modules/' . $this->name . '/';
} else {
$url = 'https://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . '/';
}
$this->context->smarty->assign('x_invoice_num', (int) $params['cart']->id);
$this->context->smarty->assign('cards', $cards);
$this->context->smarty->assign('achsetting', $achsetting);
$this->context->smarty->assign('midtype', $midtype);
$this->context->smarty->assign('isFailed', $isFailed);
$this->context->smarty->assign('new_base_dir', $url);
return $this->display(__FILE__, 'views/templates/front/allianceaim.tpl');
}
}
示例15: hookPayment
public function hookPayment($params)
{
$currency = Currency::getCurrencyInstance($this->context->cookie->id_currency);
$isFailed = Tools::getValue('payfortstarterror');
if (method_exists('Tools', 'getShopDomainSsl')) {
$url = 'https://' . Tools::getShopDomainSsl() . __PS_BASE_URI__ . '/modules/' . $this->name . '/';
} else {
$url = 'https://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . '/';
}
if (Tools::safeOutput(Configuration::get('PAYFORT_START_TEST_MODE'))) {
$configuration_open_key = Tools::safeOutput(Configuration::get('PAYFORT_START_TEST_OPEN_KEY'));
} else {
$configuration_open_key = Tools::safeOutput(Configuration::get('PAYFORT_START_LIVE_OPEN_KEY'));
}
$this->context->smarty->assign('configuration_open_key', $configuration_open_key);
$cart = Context::getContext()->cart;
$customer = new Customer((int) $cart->id_customer);
$invoiceAddress = new Address((int) $cart->id_address_invoice);
$currency = new Currency((int) $cart->id_currency);
$amount = number_format((double) $cart->getOrderTotal(true, 3), 2, '.', '');
$amount_in_cents = $amount * 100;
$this->context->smarty->assign('email', $customer->email);
$this->context->smarty->assign('currency', $currency->iso_code);
$this->context->smarty->assign('amount', $amount);
$this->context->smarty->assign('amount_in_cents', $amount_in_cents);
$this->context->smarty->assign('isFailed', $isFailed);
$this->context->smarty->assign('x_invoice_num', (int) $params['cart']->id);
return $this->display(__FILE__, 'views/templates/hook/payfortstart.tpl');
}