Spade

Mini Shell

Directory:~$ /proc/self/root/home/lmsyaran/public_html/css/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/home/lmsyaran/public_html/css/hikamarket.tar

duplicateproducts/duplicateproducts.php000064400000007200151166037470014562
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikamarketDuplicateproducts extends JPlugin {
	public function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	public function onAfterVendorCreate(&$vendor) {
		$pluginsClass = hikamarket::get('shop.class.plugins');
		$plugin = $pluginsClass->getByName('hikamarket',
'duplicateproducts');
		if(empty($plugin->params['category_id']))
			return;
		$category_id = (int)$plugin->params['category_id'];

		$db = JFactory::getDBO();
		$config = hikamarket::config();
		$productClass = hikamarket::get('shop.class.product');
		$importHelper = hikamarket::get('shop.helper.import');
		$vendorClass = hikamarket::get('class.vendor');

		$query = 'SELECT c.* FROM
'.hikamarket::table('shop.category').' AS c '.
			' INNER JOIN
'.hikamarket::table('shop.category').' AS d ON
c.category_left >= d.category_left AND c.category_right <=
d.category_right '.
			' where d.category_id = ' . (int)$category_id;
		$db->setQuery($query);
		$categories = $db->loadObjectList('category_id');

		if(empty($categories))
			return;

		$categories_id = array_keys($categories);
		$category_translated = array();


		$vendor_category_id = $vendorClass->getRootCategory($vendor, 1);
		if(empty($vendor_category_id)) {
			$vendor_category_id = 2;
		}

		if(version_compare(PHP_VERSION, '5.2.0', '>')) {
			$category_translated = array_fill_keys($categories_id,
$vendor_category_id);
		} else {
			$tmp = array_fill(0, count($categories_id), $vendor_category_id);
			$category_translated = array_combine($categories_id, $tmp);
			unset($tmp);
		}
		unset($categories);

		$query = 'SELECT pc.product_id FROM ' .
hikamarket::table('shop.product_category') . ' AS pc
'.
			' INNER JOIN ' . hikamarket::table('shop.product') .
' AS p ON pc.product_id = p.product_id '.
			' WHERE p.product_vendor_id = 0 AND pc.category_id IN ('.
implode(',', $categories_id).')';
		$db->setQuery($query);
		$product_ids = $db->loadColumn();

		foreach($product_ids as $product_id) {
			$importHelper->addTemplate($product_id);

			if(empty($importHelper->template))
				continue;

			$newProduct = new stdClass();
			$newProduct->product_code =
$importHelper->template->product_code.'_vendor'.(int)$vendor->vendor_id;

			$importHelper->_checkData($newProduct);

			$newProduct->categories = array();
			if(!empty($importHelper->template->categories)) {
				foreach($importHelper->template->categories as $cat_id) {
					if(isset($category_translated[$cat_id]))
						$newProduct->categories[] = $category_translated[$cat_id];
					else
						$newProduct->categories[] = $cat_id;
				}
			}
			if(empty($newProduct->categories))
				$newProduct->categories[] = $vendor_category_id;

			$newProduct->product_vendor_id = (int)$vendor->vendor_id;

			$products = array($newProduct);
			if(!empty($importHelper->template->variants)) {
				foreach($importHelper->template->variants as $variant) {
					$copy = clone($variant);
					$copy->product_parent_id = $newProduct->product_code;
					$copy->product_code =
$copy->product_code.'_vendor'.(int)$vendor->vendor_id;

					$copy->product_vendor_id = (int)$vendor->vendor_id;

					unset($copy->product_id);
					$products[] = $copy;
				}
			}
			$importHelper->_insertProducts($products);


			unset($newProduct);
			unset($products);
			unset($importHelper->template);
		}
	}
}
duplicateproducts/duplicateproducts.xml000064400000002511151166037470014573
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5"
method="upgrade" group="hikamarket">
	<name>HikaMarket - Duplicate products</name>
	<hikainstall ordering="1" enable="0"
report="0" />
	<creationDate>20 juillet 2020</creationDate>
	<version>3.1.1</version>
	<author>Obsidev</author>
	<authorEmail>dev@obsidev.com</authorEmail>
	<authorUrl>http://www.obsidev.com</authorUrl>
	<copyright>Copyright (C) 2012-2020 OBSIDEV SARL - All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>This plugin duplicated products from a category each
time a vendor is created</description>
	<files>
		<filename
plugin="duplicateproducts">duplicateproducts.php</filename>
	</files>
	<params addpath="/components/com_hikamarket/params">
		<param name="category_id" type="text"
size="50" default="" label="Category id"
description="The category id which contains the products to
duplicate" />
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikamarket/fields">
			<fieldset name="basic">
				<field
					name="category_id"
					type="text"
					label="Category id"
					size="50"
					default=""
					description="The category id which contains the products to
duplicate" />
			</fieldset>
		</fields>
	</config>
</extension>
duplicateproducts/index.html000064400000000054151166037470012310
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>index.html000064400000000054151166037470006552
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/index.html000064400000000054151166037470010365
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/language/en-GB/en-GB.plg_hikamarket_mangopay.ini000064400000004535151166037470017320
0ustar00; MangoPay
HIKAM_MANGOPAY="MangoPay"
HIKAM_MANGOPAY_TITLE="MangoPay"
HIKAM_MANGO_WALLET="Wallet"
HIKAM_MANGO_BANK="Bank account"
HIKAM_MANGO_PROFILE="Profile"
HIKAM_MANGO_DOCUMENTS="Documents"
MANGOPAY_BALANCE="Balance"
MANGOPAY_PAYOUT="Payout"
MANGOPAY_DO_PAYOUT="make a payout"
MANGOPAY_NO_PAYOUT="-"
MANGOPAY_ADD_BANKACCOUNT="Add a bank account"
MANGOPAY_NO_BANKACOUNT="You don't have registered a bank
account"

MANGOPAY_EMAIL="Email"
MANGOPAY_HEADQUARTERSADDRESS="Headquarter Address"
MANGOPAY_LEGALPERSONTYPE="Vendor type"
MANGOPAY_PERSONTYPE_BUSINESS="Business"
MANGOPAY_PERSONTYPE_ORGANIZATION="Organization"
MANGOPAY_PERSONTYPE_SOLETRADER="Sole Trader"

MANGOPAY_STATUTE="Statute"
MANGOPAY_PROOF_REGISTRATION="Proof of registration"
MANGOPAY_SHAREHOLDER_DECLARATION="Shareholder declaration"
MANGOPAY_ADD_DOCUMENT="Add document"

MANGOPAY_LEGALREPRESENTATIVE="Legal Representative"
MANGOPAY_LEGALREPRESENTATIVEFIRSTNAME="Firstname"
MANGOPAY_LEGALREPRESENTATIVELASTNAME="Lastname"
MANGOPAY_LEGALREPRESENTATIVEADDRESS="Address"
MANGOPAY_LEGALREPRESENTATIVEEMAIL="Email"
MANGOPAY_LEGALREPRESENTATIVEBIRTHDAY="Birthday"
MANGOPAY_LEGALREPRESENTATIVENATIONALITY="Nationality"
MANGOPAY_LEGALREPRESENTATIVECOUNTRYOFRESIDENCE="Country of
residence"

MANGOPAY_SAVE_BANKACCOUNT="Save bank account"
MANGOPAY_BANK_TYPE="Bank type"
MANGOPAY_BANK_TYPE_IBAN="IBAN"
MANGOPAY_BANK_TYPE_GB="GB"
MANGOPAY_BANK_TYPE_US="US"
MANGOPAY_BANK_TYPE_CA="CA"
MANGOPAY_BANK_TYPE_OTHER="Other"
MANGOPAY_BANK_OWNER_NAME="Owner name"
MANGOPAY_BANK_OWNER_ADDRESS="Owner address"
MANGOPAY_BANK_IBAN="IBAN"
MANGOPAY_BANK_BIC="BIC"
MANGOPAY_BANK_ACCOUNTNUMBER="Account number"
MANGOPAY_BANK_SORTCODE="Sort code"
MANGOPAY_BANK_ABA="ABA"
MANGOPAY_BANK_BANKNAME="Bank name"
MANGOPAY_BANK_INSTITUTIONNUMBER="Institution number"
MANGOPAY_BANK_BRANCHCODE="Branch code"
MANGOPAY_BANK_COUNTRY="Country"

MANGOPAY_DOCUMENT_TYPE="Document type"
MANGOPAY_DOCUMENT_FILE="Document file"
MANGOPAY_DOC_IDENTITY_PROOF="Proof of identity"
MANGOPAY_DOC_REGISTRATION_PROOF="Proof of registration"
MANGOPAY_DOC_ARTICLES_OF_ASSOCIATION="Articles of association"
MANGOPAY_DOC_SHAREHOLDER_DECLARATION="Shareholder declaration"

MANGOPAY_CURRENT_BALANCE="Wallet balance"
MANGOPAY_AUTHORIZED_PAYOUT="Authorized value"
MANGOPAY_PAYOUT_VALUE="Transfer"
MANGOPAY_PAYOUT_BANK="Bank
account"mangopay/language/en-GB/index.html000064400000000054151166037470013040
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/language/en-GB/nl-BE.plg_hikamarket_mangopay.ini000064400000004443151166037470017323
0ustar00; MangoPay

HIKAM_MANGOPAY="MangoPay"
HIKAM_MANGOPAY_TITLE="MangoPay"
HIKAM_MANGO_WALLET="Portemonnee"
HIKAM_MANGO_BANK="Bankrekening"
HIKAM_MANGO_PROFILE="Profiel"
HIKAM_MANGO_DOCUMENTS="Documenten"
MANGOPAY_BALANCE="Saldo"
MANGOPAY_PAYOUT="Uitbetaling"
MANGOPAY_DO_PAYOUT="maak een uitbetaling"
MANGOPAY_NO_PAYOUT="-"
MANGOPAY_ADD_BANKACCOUNT="Voeg een bankrekening toe"
MANGOPAY_NO_BANKACOUNT="U heeft geen bankrekening geregistreerd"
MANGOPAY_EMAIL="E-mail"
MANGOPAY_HEADQUARTERSADDRESS="Hoofdkwartier Adres"
MANGOPAY_LEGALPERSONTYPE="Verkoper type"
MANGOPAY_PERSONTYPE_BUSINESS="Bedrijf"
MANGOPAY_PERSONTYPE_ORGANIZATION="Organisatie"
MANGOPAY_STATUTE="Statuut"
MANGOPAY_PROOF_REGISTRATION="Bewijs van inschrijving"
MANGOPAY_SHAREHOLDER_DECLARATION="Aandeelhouder verklaring"
MANGOPAY_ADD_DOCUMENT="Document toevoegen"
MANGOPAY_LEGALREPRESENTATIVE="Wettelijke vertegenwoordiger"
MANGOPAY_LEGALREPRESENTATIVEFIRSTNAME="Voornaam"
MANGOPAY_LEGALREPRESENTATIVELASTNAME="Achternaam"
MANGOPAY_LEGALREPRESENTATIVEADDRESS="Adres"
MANGOPAY_LEGALREPRESENTATIVEEMAIL="E-mail"
MANGOPAY_LEGALREPRESENTATIVEBIRTHDAY="Verjaardag"
MANGOPAY_LEGALREPRESENTATIVENATIONALITY="Nationaliteit"
MANGOPAY_LEGALREPRESENTATIVECOUNTRYOFRESIDENCE="Land van
Verblijf"
MANGOPAY_SAVE_BANKACCOUNT="Opslaan bankrekening"
MANGOPAY_BANK_TYPE="Bank soort"
MANGOPAY_BANK_TYPE_IBAN="IBAN"
MANGOPAY_BANK_TYPE_GB="GB"
MANGOPAY_BANK_TYPE_US="ONS"
MANGOPAY_BANK_TYPE_CA="CA"
MANGOPAY_BANK_TYPE_OTHER="Ander"
MANGOPAY_BANK_OWNER_NAME="Naam van de eigenaar"
MANGOPAY_BANK_OWNER_ADDRESS="Eigenaar adres"
MANGOPAY_BANK_IBAN="IBAN"
MANGOPAY_BANK_BIC="BIC"
MANGOPAY_BANK_ACCOUNTNUMBER="Rekeningnummer"
MANGOPAY_BANK_SORTCODE="Sorteercode"
MANGOPAY_BANK_ABA="ABA"
MANGOPAY_BANK_BANKNAME="Banknaam"
MANGOPAY_BANK_INSTITUTIONNUMBER="Instelling aantal"
MANGOPAY_BANK_BRANCHCODE="Filiaalcode"
MANGOPAY_BANK_COUNTRY="Land"
MANGOPAY_DOCUMENT_TYPE="Documenttype"
MANGOPAY_DOCUMENT_FILE="Document bestand"
MANGOPAY_DOC_IDENTITY_PROOF="Identiteitsbewijs"
MANGOPAY_DOC_REGISTRATION_PROOF="Bewijs van inschrijving"
MANGOPAY_DOC_ARTICLES_OF_ASSOCIATION="Statuten"
MANGOPAY_DOC_SHAREHOLDER_DECLARATION="Aandeelhouder verklaring"
MANGOPAY_CURRENT_BALANCE="Portemonnee balans"
MANGOPAY_AUTHORIZED_PAYOUT="Geautoriseerde waarde"
MANGOPAY_PAYOUT_VALUE="Overdracht"
MANGOPAY_PAYOUT_BANK="Bankrekening"
mangopay/language/index.html000064400000000054151166037470012150
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/mangopay.php000064400000003536151166037470010724
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikamarketMangopay extends JPlugin {
	public function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	public function onHikamarketPluginController($ctrl) {
		if($ctrl != 'mangopay')
			return;

		$app = JFactory::getApplication();
		$this->loadLanguage('plg_hikamarket_mangopay',
JPATH_ADMINISTRATOR);

		return array(
			'type' => 'hikamarket',
			'name' => 'mangopay',
			'prefix' => ($app->isAdmin() ? 'backend' :
'ctrl')
		);
	}

	public function onMarketAclPluginListing(&$categories) {
		if(empty($categories['root']['plugins']))
			$categories['root']['plugins'] = array();
		$categories['root']['plugins'][] =
'mangopay';
	}

	public function onVendorPanelDisplay(&$buttons, &$statistics) {
		global $Itemid;
		$url_itemid = '';
		if(!empty($Itemid))
			$url_itemid = '&Itemid=' . $Itemid;

		$this->loadLanguage('plg_hikamarket_mangopay',
JPATH_ADMINISTRATOR);
		$doc = JFactory::getDocument();

		jimport('joomla.filesystem.file');
		if(JFile::exists(HIKASHOP_MEDIA . 'css' . DS .
'mangopay.css'))
			$doc->addStyleSheet(HIKASHOP_CSS .
'mangopay.css?v='.HIKAMARKET_RESSOURCE_VERSION);
		else
			$doc->addStyleSheet(JURI::base(true).'/plugins/hikamarket/mangopay/media/mangopay.css?v='.HIKAMARKET_RESSOURCE_VERSION);

		$buttons['mangopay'] = array(
			'url' =>
hikamarket::completeLink('mangopay'.$url_itemid),
			'level' => 1,
			'icon' => 'iconM-48-mangopay',
			'name' => JText::_('HIKAM_MANGOPAY'),
			'description' => '',
			'display' => hikamarket::acl('plugins/mangopay')
		);
	}
}
mangopay/mangopay.xml000064400000002354151166037470010732 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5"
method="upgrade" group="hikamarket">
	<name>HikaMarket - MangoPay integration</name>
	<hikainstall ordering="1" enable="0"
report="0" />
	<creationDate>20 juillet 2020</creationDate>
	<version>3.1.1</version>
	<author>Obsidev</author>
	<authorEmail>dev@obsidev.com</authorEmail>
	<authorUrl>http://www.obsidev.com</authorUrl>
	<copyright>Copyright (C) 2012-2020 OBSIDEV SARL - All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>This plugin allow the front-end interface for
MangoPay</description>
	<files>
		<filename
plugin="mangopay">mangopay.php</filename>
		<filename>mangopay_ctrl.php</filename>
		<filename>mangopay_class.php</filename>
		<filename>mangopay_backend.php</filename>
		<folder>views</folder>
		<folder>media</folder>
	</files>
	<languages>
		<language
tag="en-GB">language/en-GB/en-GB.plg_hikamarket_mangopay.ini</language>
	</languages>
	<params addpath="/components/com_hikamarket/params">
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikamarket/fields">
			<fieldset name="basic">
			</fieldset>
		</fields>
	</config>
</extension>
mangopay/mangopay_backend.php000064400000001236151166037470012366
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

include_once dirname(__FILE__) . DS . 'mangopay_class.php';

class mangopayMarketController extends hikamarketController {
	protected $rights = array(
		'display' => array(),
		'add' => array(),
		'edit' => array(),
		'modify' => array(),
		'delete' => array()
	);
	protected $pluginCtrl = array('hikamarket',
'mangopay');
	protected $type = 'plg_mangopay';
}
mangopay/mangopay_class.php000064400000027272151166037470012114
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class hikamarketPlg_mangopayClass extends JObject {

	protected static $currentMangoVendor = null;
	protected static $mangopayPlugin = null;
	protected static $mangopayAPI = null;

	public function getMangoPlugin() {
		if(empty(self::$mangopayPlugin))
			self::$mangopayPlugin = hikamarket::import('hikashoppayment',
'mangopay');
		return self::$mangopayPlugin;
	}

	public function getMangoVendor() {
		if(!empty(self::$currentMangoVendor))
			return self::$currentMangoVendor;

		$mangopayPlugin = $this->getMangoPlugin();
		$vendor = hikamarket::loadVendor(true, false);
		self::$currentMangoVendor = $mangopayPlugin->getVendor($vendor);
		return self::$currentMangoVendor;
	}

	public function getMangoAPI() {
		if(!empty(self::$mangopayAPI))
			return self::$mangopayAPI;

		$mangopayPlugin = $this->getMangoPlugin();
		self::$mangopayAPI = $mangopayPlugin->getAPI();
		return self::$mangopayAPI;
	}

	public function debug($e, $r = false) {
		$mangopayPlugin = $this->getMangoPlugin();
		$mangopayPlugin->mangoDebug($e, $r);
	}
	public function mangoDebug($e, $r = false) { return $this->debug($e,
$r); }

	public function saveForm() {
		$formData = hikaInput::get()->get('mango', array(),
'array');
		if(empty($formData))
			return false;

		$api = $this->getMangoAPI();
		$mango_vendor = $this->getMangoVendor();

		if(empty($mango_vendor) || empty($mango_vendor->Id))
			return false;

		$user = new MangoPay\UserLegal();
		$user->Id = $mango_vendor->Id;

		if(!empty($formData['name']))
			$user->Name = substr($formData['name'], 0, 254);

		if(!empty($formData['legalpersontype']) &&
in_array($formData['legalpersontype'],
array('BUSINESS', 'ORGANIZATION',
'SOLETRADER')))
			$user->LegalPersonType = $formData['legalpersontype'];

		if(!empty($formData['email']))
			$user->Email = substr($formData['email'], 0, 254);

		if(!empty($formData['headquartersaddress']))
			$user->HeadquartersAddress =
substr($formData['headquartersaddress'], 0, 254);

		if(!empty($formData['legalrepresentativefirstname']))
			$user->LegalRepresentativeFirstName =
substr($formData['legalrepresentativefirstname'], 0, 99);

		if(!empty($formData['legalrepresentativelastname']))
			$user->LegalRepresentativeLastName =
substr($formData['legalrepresentativelastname'], 0, 99);

		if(!empty($formData['legalrepresentativeaddress']))
			$user->LegalRepresentativeAddress =
substr($formData['legalrepresentativeaddress'], 0, 254);

		if(!empty($formData['legalrepresentativeemail']))
			$user->LegalRepresentativeEmail =
substr($formData['legalrepresentativeemail'], 0, 254);

		if(!empty($formData['legalrepresentativebirthday']))
			$user->LegalRepresentativeBirthday =
hikamarket::getTime($formData['legalrepresentativebirthday']);

		if(!empty($formData['legalrepresentativenationality']))
			$user->LegalRepresentativeNationality =
strtoupper(substr(trim($formData['legalrepresentativenationality']),
0, 2));
		if(!empty($formData['legalrepresentativecountryofresidence']))
			$user->LegalRepresentativeCountryOfResidence =
strtoupper(substr(trim($formData['legalrepresentativecountryofresidence']),
0, 2));

		$result = false;
		try {

			$result = $api->Users->Update($user);

		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($result) || empty($result->Id))
			return false;
		return $result->Id;
	}

	public function addBank() {
		$formData = hikaInput::get()->get('mangobank', array(),
'array');
		if(empty($formData))
			return false;

		if(empty($formData['type']) ||
!in_array($formData['type'],
array('IBAN','GB','US','CA','OTHER')))
			return false;

		$api = $this->getMangoAPI();
		$mango_vendor = $this->getMangoVendor();

		$bank = new MangoPay\BankAccount();
		$bank->Type = $formData['type'];
		$bank->OwnerName = $formData['ownername'];
		$bank->OwnerAddress =  $formData['owneraddress'];

		switch($bank->Type) {
			case 'IBAN':
				$bank->Details = new MangoPay\BankAccountDetailsIBAN();
				$bank->Details->IBAN =
$formData['iban']['iban'];
				$bank->Details->BIC =
$formData['iban']['bic'];
				break;
			case 'GB':
				$bank->Details = new MangoPay\BankAccountDetailsGB();
				$bank->Details->AccountNumber =
$formData['gb']['accountnumber'];
				$bank->Details->SortCode =
$formData['gb']['sortcode'];
				break;
			case 'US':
				$bank->Details = new MangoPay\BankAccountDetailsUS();
				$bank->Details->AccountNumber =
$formData['us']['accountnumber'];
				$bank->Details->ABA =
$formData['us']['aba'];
				break;
			case 'CA':
				$bank->Details = new MangoPay\BankAccountDetailsCA();
				$bank->Details->BankName =
$formData['ca']['bankname'];
				$bank->Details->InstitutionNumber =
$formData['ca']['institutionnumber'];
				$bank->Details->BranchCode =
$formData['ca']['branchcode'];
				$bank->Details->AccountNumber =
$formData['ca']['accountnumber'];
				break;
			case 'OTHER':
				$bank->Details = new MangoPay\BankAccountDetailsOTHER();
				$bank->Details->Country =
$formData['other']['country'];
				$bank->Details->BIC =
$formData['other']['bic'];
				$bank->Details->AccountNumber =
$formData['other']['accountnumber'];
				break;
		}

		$result = false;
		try {

			$result = $api->Users->CreateBankAccount($mango_vendor->Id,
$bank);

		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($result) || empty($result->Id))
			return false;
		return $result->Id;
	}

	public function addDocument() {
		$formData = hikaInput::get()->get('mangodoc', array(),
'array');
		if(empty($formData))
			return false;

		$api = $this->getMangoAPI();
		$mango_vendor = $this->getMangoVendor();

		$document_type = strtoupper(trim($formData['type']));
		if(!in_array($document_type, array('IDENTITY_PROOF',
'REGISTRATION_PROOF', 'ARTICLES_OF_ASSOCIATION',
'SHAREHOLDER_DECLARATION', 'IDENTITY_PROOF',
'ADDRESS_PROOF')))
			return false;

		if(empty($_FILES) || empty($_FILES['mangodoc_page']))
			return false;

		$file = $_FILES['mangodoc_page'];

		$kyc_document = new MangoPay\KycDocument();
		$kyc_document->Type = $document_type;

		$createdDocument = false;
		try {
			$createdDocument =
$api->Users->CreateKycDocument($mango_vendor->Id, $kyc_document);
		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($createdDocument) || empty($createdDocument->Id))
			return false;

		$createdPage = false;
		try {
			$api->Users->CreateKycPageFromFile($mango_vendor->Id,
$createdDocument->Id, $file);
			$createdPage = true;
		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($createdPage))
			return false;

		$kyc_document = new MangoPay\KycDocument();
		$kyc_document->Id = $createdDocument->Id;
		$kyc_document->Status = 'VALIDATION_ASKED';

		$updatedDocument = false;
		try {
			$updatedDocument =
$api->Users->UpdateKycDocument($mango_vendor->Id, $kyc_document);
		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($updatedDocument))
			return false;
		return true;
	}

	public function doPayout() {
		$formData = hikaInput::get()->get('payout', array(),
'array');
		if(empty($formData))
			return false;

		$walletId = (int)trim(@$formaData['wallet']);
		if(empty($walletId))
			return false;

		$value = (float)hikashop_toFloat(@$formData['value']);
		if($value <= 0.0)
			return false;

		$api = $this->getMangoAPI();
		$vendor = hikamarket::loadVendor(true, false);
		$mango_vendor = $this->getMangoVendor();
		$mangopayPlugin = $this->getMangoPlugin();

		$mango_wallets = $mangopayPlugin->getVendorWallets($vendor);
		$mango_wallet = null;
		foreach($mango_wallets as $mango_wallet) {
			if((int)$mango_wallet->Id == $walletId) {
				$mango_wallet = $mango_wallet;
				break;
			}
		}


		$duration = 31;
		if(isset($mangopayPlugin->params))
			$duration =
(int)$mangopayPlugin->params->get('payout_waiting_duration',
31);
		if($duration <= 0)
			$duration = 31;

		$transactions = $this->getTransactions($mango_wallet->Id,
$duration);
		$transactions_total = 0.0;
		foreach($transactions as $transaction) {
			if($transaction->Nature == 'REGULAR')
				$transactions_total += ($transaction->CreditedFunds->Amount /
100);

			if($transaction->Nature == 'REFUND')
				$transactions_total -= ($transaction->CreditedFunds->Amount /
100);
		}
		if($transactions_total < 0)
			$transactions_total = 0.0;

		$maximum_authorized = ($mango_wallet->Balance->Amount / 100) -
$transactions_total;
		if($maximum_authorized < 0)
			$maximum_authorized = 0.0;

		if($value > $maximum_authorized)
			return false;

		$bank_account = (int)@$formData['bank'];
		if(empty($bank_account))
			return false;
		try {

			$mango_bank_account =
$api->Users->GetBankAccount($mango_vendor->Id, $bank_account);

		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($mango_bank_account))
			return false;

		$payout = new MangoPay\PayOut();
		$payout->AuthorId = $mango_vendor->Id;
		$payout->DebitedWalletId = $mango_wallet->Id;
		$payout->PaymentType = 'BANK_WIRE';

		$payout->DebitedFunds = new MangoPay\Money();
		$payout->DebitedFunds->Currency = $mango_wallet->Currency;
		$payout->DebitedFunds->Amount = $value * 100;

		$payout->Fees = new MangoPay\Money();
		$payout->Fees->Currency = $mango_wallet->Currency;
		$payout->Fees->Amount = 0;

		$payout->MeanOfPaymentDetails = new
MangoPay\PayOutPaymentDetailsBankWire();
		$payout->MeanOfPaymentDetails->BankAccountId =
$mango_bank_account->Id;

		$payoutResult = null;
		try {

			$payoutResult = $api->PayOuts->Create($payout);

		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		if(empty($payoutResult) || empty($payoutResult->Id))
			return false;

		if(isset($payoutResult->Status) && $payoutResult->Status ==
'FAILED') {
			switch(@$payoutResult->ResultCode) {
				case '002998':
					$this->errors[] = 'The bank account needs to be KYC verified.
Please contact the side owner for more details.';
					break;
				case '002999':
					$this->errors[] = 'The account needs to be KYC verified.
Please contact the side owner for more details.';
					break;
			}
			return false;
		}

		return $payoutResult;
	}

	public function getTransactions($wallet_id, $duration = 31) {
		$api = $this->getMangoAPI();

		$transactions = false;
		try {
			$pagination = null;
			$filter = new MangoPay\FilterTransactions();
			if($duration > 1)
				$filter->AfterDate = time() - ($duration * 86400);
			$filter->Status = 'SUCCEEDED';
			$filter->Type = 'TRANSFER';

			$transactions = $api->Wallets->GetTransactions($wallet_id,
$pagination, $filter);
		}
		catch (MangoPay\ResponseException $e) { $this->debug($e, true); }
		catch (MangoPay\Exception $e) { $this->debug($e, false); }
		catch (Exception $e) {}

		return $transactions;
	}

}
mangopay/mangopay_ctrl.php000064400000012610151166037470011741
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

include_once dirname(__FILE__) . DS . 'mangopay_class.php';

class mangopayMarketController extends hikamarketController {
	protected $rights = array(
		'display' => array('show'),
		'add' =>
array('bank','document','payout'),
		'edit' =>
array('save','addbank','adddocument','dopayout'),
		'modify' => array(),
		'delete' => array()
	);
	protected $pluginCtrl = array('hikamarket',
'mangopay');
	protected $type = 'plg_mangopay';

	public function __construct($config = array(), $skip = false) {
		parent::__construct($config, $skip);
		if(!$skip)
			$this->registerDefaultTask('show');
		$this->config = hikamarket::config();
	}

	public function show() {
		if(!hikamarket::loginVendor())
			return false;
		if(!$this->config->get('frontend_edition',0))
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		hikaInput::get()->set('layout', 'show');
		return parent::display();
	}

	public function bank() {
		if(!hikamarket::loginVendor())
			return false;
		if(!$this->config->get('frontend_edition',0))
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		hikaInput::get()->set('layout', 'bank');
		return parent::display();
	}

	public function document() {
		if(!hikamarket::loginVendor())
			return false;
		if(!$this->config->get('frontend_edition',0))
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		hikaInput::get()->set('layout', 'document');
		return parent::display();
	}

	public function payout() {
		if(!hikamarket::loginVendor())
			return false;
		if(!$this->config->get('frontend_edition',0))
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		hikaInput::get()->set('layout', 'payout');
		return parent::display();
	}

	public function addbank() {
		if(!hikamarket::loginVendor())
			return false;
		if( !$this->config->get('frontend_edition', 0) )
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		$app = JFactory::getApplication();
		JSession::checkToken() || die('Invalid Token');

		$mangoClass = hikamarket::get('class.plg_mangopay');

		$status = $mangoClass->addBank();
		if($status) {
			$app->enqueueMessage(JText::_('HIKAM_SUCC_SAVED'),
'message');
			hikaInput::get()->set('cid', $status);
			hikaInput::get()->set('fail', null);
			return $this->show();
		}

		$app->enqueueMessage(JText::_('ERROR_SAVING'),
'error');
		if(!empty($mangoClass->errors)) {
			foreach($mangoClass->errors as $err) {
				$app->enqueueMessage($err, 'error');
			}
		}
		return $this->bank();
	}

	public function adddocument() {
		if(!hikamarket::loginVendor())
			return false;
		if( !$this->config->get('frontend_edition', 0) )
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		$app = JFactory::getApplication();
		JSession::checkToken() || die('Invalid Token');

		$mangoClass = hikamarket::get('class.plg_mangopay');

		$status = $mangoClass->adddocument();
		if($status) {
			$app->enqueueMessage(JText::_('HIKAM_SUCC_SAVED'),
'message');
			hikaInput::get()->set('cid', $status);
			hikaInput::get()->set('fail', null);
			return $this->show();
		}

		$app->enqueueMessage(JText::_('ERROR_SAVING'),
'error');
		if(!empty($mangoClass->errors)) {
			foreach($mangoClass->errors as $err) {
				$app->enqueueMessage($err, 'error');
			}
		}
		return $this->document();
	}

	public function dopayout() {
		if(!hikamarket::loginVendor())
			return false;
		if( !$this->config->get('frontend_edition', 0) )
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		$app = JFactory::getApplication();
		JSession::checkToken() || die('Invalid Token');

		$mangoClass = hikamarket::get('class.plg_mangopay');

		$status = $mangoClass->doPayout();
		if($status) {
			$app->enqueueMessage(JText::_('MANGO_PAYOUT_DONE'),
'message');
			hikaInput::get()->set('cid', $status);
			hikaInput::get()->set('fail', null);
			return $this->show();
		}

		$app->enqueueMessage(JText::_('MANGO_ERROR_PAYOU'),
'error');
		if(!empty($mangoClass->errors)) {
			foreach($mangoClass->errors as $err) {
				$app->enqueueMessage($err, 'error');
			}
		}
		return $this->payout();
	}

	public function save() {
		$this->store();
		return $this->show();
	}

	public function store() {
		if(!hikamarket::loginVendor())
			return false;
		if( !$this->config->get('frontend_edition',0) )
			return false;
		if(!hikamarket::acl('plugins/mangopay'))
			return hikamarket::deny('vendor',
JText::sprintf('HIKAM_ACTION_DENY', 'MangoPay'));

		return $this->adminStore(true);
	}
}
mangopay/media/index.html000064400000000054151166037470011444
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/media/mangopay.css000064400000000116151166037470011773
0ustar00/* MangoPay CSS */
.iconM-48-mangopay
{background-image:url(./mangopay.png);}mangopay/media/mangopay.png000064400000007111151166037470011771
0ustar00�PNG


IHDR00W��	pHYs��~�
�IDATh���yt�E�ǿ��~oM^��
�-�:4:c�veuilT��`�hT�eZ��vEqA�-
�p����n�B��dO^�K�U՝?~/!���s�sRU��U�nU������3C���N���a�Tef�5���b�@w�5B��,�%�x�9������q��l�w<������9kl�+(�G���KS��:�b��BD�t�_�W�_���L
XC'}�j[�Ÿ�{S�p*�w��c���_5����|!
����U��ն���-���W�)��:��5�j����ixP��sr��٥����n��.G�[�lk�Q|�]/��+=xs0<�i]E�m���e��VC'$��E]c�$�V��W�~��*�:߉Y�(���O~�z��	?pl���%����v,�g�."�G�!�+(����u��5@��Z:|�vd<xp�
���
�+zz����nc�
2��I��ʘsƽ��n)=��IkmS
���~2<q��S_?��Sc`�U���]q��d�JY�;���ʸ:��q��[?W�����/�;��9���#�D�4�'+m��y˹��H�0�3hĶ��E��MƼH�CD����+cΰYc�)S��N�]M*E죏&��v��t$�HD^@3�[mS�\ƍ�&C���hN7�;��0ty�8��Xz�����awLPC?��
"��BE�Ɇm�~S�۩+8��
겈��66���i�
Pa
6�A�RH
k�3�쭡���nS�=�~��	j��L%�Aø�RѨ۰u�ҩ�y"����x�֦���7�	2�;H�Bj��!�~���H&b0Zq�<��~�����Z��F��`����>���i/��v)��[eS;\��?����|'&��!�m	]=<`v���~�v�_`�I
�'	۲�Ʋ�i/��$Й�6�
����J'?�l�u��){�@F�J�;xO�f�[��8�mkc��Q�m�pzIa�,6^MՑ�C"��Օ������'?���7�*�#֍���ج�����_9k�M�s����X��R�a�eZ_�&��1�65}r¢E�k?���o�LY��pGөE�
I�jS�g����?oT�D� �*CN�ؤ7
5j��Ɣ~�;�ʽay
�)�:��ṛ�׾܇�2l�D{E3|c�',ZtId�j'k6m���iӞfk-���`�
�6նd����_O�2Z�&}D�}�FC�>�iJ�h�`<x]�e���ٚ�P���>���d��b��6տ��)e��H
k�ml���'��$��mC��Ɛ����ߞ��idk
j-Bx�B�S��E��Jf��]�@�����
�o4T�S�&?H
�NJ�}�+�z�F=��O��7w�*��d
��צغWzCHZ{�E��~�H|v�…�"��TPʂ������OUo�0�d��%`�Z"!BjSkJ�\�0Ѵc��9�Y+j�YiG3�J��|�.&�+����6e;NH���]}2�>8�z"h��5���9ců�&�0��M$>��K"��T��J���]W:=z����o�O_��-�����Jo|,��;����Z��tAҀ��+��E�A�{H8���`|���B��@�4�m{̞�����y�7կ_�%|~a��v�z|�Ȭ�c�YkIJ�-��]W9yy�jݺ�%3f,`A���+_H4~9G����<�1$�'��:8�lUuI|嬿q���y�"#����P�W��tw�痍�;��|����VN~��Z�~�7S�>�Z����h��CR'i�0�8!ʗv�Q�1�൛B�S׺F��٦;"�D���Ks��������[�j�T�}�"
fi�
_�n�/�^}
�^�Q��y$�a��O��͕�nE����Ԁg�)$�H(��N��P�ߞԦV�E��IJ�D����m�����)=�6��}�b(�K蔂�ms��e�w�������8��"�UP^4sS��=H��8�939�v++Ut„%�/�^&�`X�d����Y���OiS����fW��)��u�����M�/����GT��&>z1ds$Zov�td�����q��2�]YƩ�׿�Pư���|�asq>9��A,@�c��r7��K��
"/RD,�k�̑���x{��bmj}D��V@m|wt��ok�x������҃קz�!4�Q�j'��tb�e��v�=62s�5e��!�^����":���6m�`��3ǁ[Q��;��~K�L�����
fX�d��W�rf�?h�1�
(+�?��Tپs�ۮI�!�_sK�I���H���EB�v�J�L}ݿ�02r��R�ZBR�X�
��`p�{
�Ilۜ+�.I�nErG�^���ߒ-�o��/��̕����🴌�ો�fn�j��]7~��"B�9�,t�C�
h'�|����<22rٵ�l�$)�O��*�E
x������\�����#_�ti!	!�l[�$�3���*�G�V���3�~������T�c��Dh�~6�,|ݓ#��l�1�Q�˯��ڕ$���<k���Q>�p{�9×x��HJ���E���f
�̰P2���Y�@88�ccA]��H�w��}D_G9����R�')a���y�OO\�t!)��5S��]*�`f�~'W<{rf��S:������V+��zo�z���a�'�\qas���y@9ZWW��9,��~C��vߡ
�D|Yb���S2Bǿ��#�;��+mv�s^��;ד/#Bi��J����/^)ӵR�}�����
q��=�&R��h�tI@kA_�8k�]7g�[�n$8
�gӹ�g�'�3������]�.�vկZ�@��9���N��W�\��d����Z���ř��������<Pl_���|���bR��C^b��"�N��b]|��
���z��SU��y�K=<7���y:<|���犳��uC8�c�k!�S��n>��v{1d
ӫX��q
Xk)���x}��D�+��R���@p�9+{>�l��]����b[�r��!sn���)�
�o�`w��&����m-�J���	'ּP�\��3F�{���'��;������;�
��%"���*���?:��m��H�,�.�
�"U���79
砫RK�#L����T�CK�pS��k�#>	�E�Cq��d��e�Iem]
|Æ�%��?z�l��G�BC�2[���o䊫)�s
R
��k��*gЩ�Gfͻ�����GnG����QFo�]��Z�{�ݠ
��i�:�<umd���X��h�I��32Qf_�p�D{��&@:�ICފ̞5C&�HxL�@w�7����_�P����^$�A*=m~>d}�·��@Hw�盭{^�[D��˯�@�:N����*5`pqd�CWQ(�M��Ժ���3��)�%ן�z��_p�}���x������X��_�?��U_d�WLy�T�F*xf�K����0�IEND�B`�mangopay/views/index.html000064400000000054151166037470011522
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/views/mangopaymarket/index.html000064400000000054151166037470014541
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/views/mangopaymarket/tmpl/bank.php000064400000011656151166037470015156
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><h1><?php echo JText::_('HIKAM_MANGOPAY_TITLE');
?></h1>
<form action="<?php echo
hikamarket::completeLink('mangopay');?>"
method="post" name="hikamarket_form"
id="hikamarket_mangopay_bank_form">
	<dl class="mangopay_bank_addition dl-horizontal">
		<dt><?php echo JText::_('MANGOPAY_BANK_TYPE');
?></dt>
		<dd><?php
			$values = array(
				'IBAN' => JHTML::_('select.option',
'IBAN', JText::_('MANGOPAY_BANK_TYPE_IBAN')),
				'GB' => JHTML::_('select.option',
'GB', JText::_('MANGOPAY_BANK_TYPE_GB')),
				'US' => JHTML::_('select.option',
'US', JText::_('MANGOPAY_BANK_TYPE_US')),
				'CA' => JHTML::_('select.option',
'CA', JText::_('MANGOPAY_BANK_TYPE_CA')),
				'OTHER' => JHTML::_('select.option',
'OTHER', JText::_('MANGOPAY_BANK_TYPE_OTHER')),
			);
			echo JHTML::_('select.genericlist', $values,
'mangobank[type]', '
onchange="window.localPage.setBankType(this);"',
'value', 'text', 'IBAN');
		?></dd>

		<dt><?php echo JText::_('MANGOPAY_BANK_OWNER_NAME');
?></dt>
		<dd>
			<input type="text" name="mangobank[ownername]"
value=""/>
		</dd>

		<dt><?php echo
JText::_('MANGOPAY_BANK_OWNER_ADDRESS'); ?></dt>
		<dd>
			<input type="text" name="mangobank[owneraddress]"
value=""/>
		</dd>

	</dl>

	<dl id="mangopay_bank_iban"
class="mangopay_bank_addition dl-horizontal">
		<dt><?php echo JText::_('MANGOPAY_BANK_IBAN');
?></dt>
		<dd>
			<input type="text" name="mangobank[iban][iban]"
value=""/>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_BANK_BIC');
?></dt>
		<dd>
			<input type="text" name="mangobank[iban][bic]"
value=""/>
		</dd>
	</dl>

	<dl id="mangopay_bank_gb" class="mangopay_bank_addition
dl-horizontal" style="display:none;">
		<dt><?php echo
JText::_('MANGOPAY_BANK_ACCOUNTNUMBER'); ?></dt>
		<dd>
			<input type="text"
name="mangobank[gb][accountnumber]" value=""/>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_BANK_SORTCODE');
?></dt>
		<dd>
			<input type="text" name="mangobank[gb][sortcode]"
value=""/>
		</dd>
	</dl>

	<dl id="mangopay_bank_us" class="mangopay_bank_addition
dl-horizontal" style="display:none;">
		<dt><?php echo
JText::_('MANGOPAY_BANK_ACCOUNTNUMBER'); ?></dt>
		<dd>
			<input type="text"
name="mangobank[us][accountnumber]" value=""/>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_BANK_ABA');
?></dt>
		<dd>
			<input type="text" name="mangobank[us][aba]"
value=""/>
		</dd>
	</dl>

	<dl id="mangopay_bank_ca" class="mangopay_bank_addition
dl-horizontal" style="display:none;">
		<dt><?php echo JText::_('MANGOPAY_BANK_BANKNAME');
?></dt>
		<dd>
			<input type="text" name="mangobank[ca][bankname]"
value=""/>
		</dd>
		<dt><?php echo
JText::_('MANGOPAY_BANK_INSTITUTIONNUMBER'); ?></dt>
		<dd>
			<input type="text"
name="mangobank[ca][institutionnumber]" value=""/>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_BANK_BRANCHCODE');
?></dt>
		<dd>
			<input type="text"
name="mangobank[ca][branchcode]" value=""/>
		</dd>
		<dt><?php echo
JText::_('MANGOPAY_BANK_ACCOUNTNUMBER'); ?></dt>
		<dd>
			<input type="text"
name="mangobank[ca][accountnumber]" value=""/>
		</dd>
	</dl>

	<dl id="mangopay_bank_other"
class="mangopay_bank_addition dl-horizontal"
style="display:none;">
		<dt><?php echo JText::_('MANGOPAY_BANK_COUNTRY');
?></dt>
		<dd>
			<input type="text"
name="mangobank[other][country]" value=""/>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_BANK_BIC');
?></dt>
		<dd>
			<input type="text" name="mangobank[other][bic]"
value=""/>
		</dd>
		<dt><?php echo
JText::_('MANGOPAY_BANK_ACCOUNTNUMBER'); ?></dt>
		<dd>
			<input type="text"
name="mangobank[other][accountnumber]" value=""/>
		</dd>
	</dl>

	<div>
		<input class="btn btn-primary" value="<?php echo
JText::_('MANGOPAY_SAVE_BANKACCOUNT'); ?>"
type="submit" onclick="return
window.hikamarket.submitform('addbank','hikamarket_mangopay_bank_form');"/>
		<div style="float:right">
			<a class="btn btn-info" href="<?php echo
hikamarket::completeLink('mangopay'); ?>"><?php
echo JText::_('HIKA_CANCEL'); ?></a>
		</div>
	</div>

	<input type="hidden" name="option"
value="<?php echo HIKAMARKET_COMPONENT; ?>"/>
	<input type="hidden" name="task"
value="bank"/>
	<input type="hidden" name="ctrl"
value="mangopay"/>
	<?php echo JHTML::_('form.token'); ?>
</form>
<script type="text/javascript">
if(!window.localPage)
	window.localPage = {};
window.localPage.bankType = 'iban';
window.localPage.setBankType = function(el) {
	var d = document, e = null;
	e = d.getElementById('mangopay_bank_' +
window.localPage.bankType);
	if(e) e.style.display = 'none';

	window.localPage.bankType = el.value.toLowerCase();

	e = d.getElementById('mangopay_bank_' +
window.localPage.bankType);
	if(e) e.style.display = '';
};
</script>
mangopay/views/mangopaymarket/tmpl/document.php000064400000004062151166037470016052
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><h1><?php echo JText::_('HIKAM_MANGOPAY_TITLE');
?></h1>
<form action="<?php echo
hikamarket::completeLink('mangopay');?>"
method="post" name="hikamarket_form"
id="hikamarket_mangopay_document_form"
enctype="multipart/form-data">
	<dl class="mangopay_documents dl-horizontal">
		<dt><?php
			echo JText::_('MANGOPAY_DOCUMENT_TYPE');
		?></dt>
		<dd><?php
			$values = array(
				'IDENTITY_PROOF' => JHTML::_('select.option',
'IDENTITY_PROOF',
JText::_('MANGOPAY_DOC_IDENTITY_PROOF')),
				'REGISTRATION_PROOF' =>
JHTML::_('select.option', 'REGISTRATION_PROOF',
JText::_('MANGOPAY_DOC_REGISTRATION_PROOF')),
				'ARTICLES_OF_ASSOCIATION' =>
JHTML::_('select.option', 'ARTICLES_OF_ASSOCIATION',
JText::_('MANGOPAY_DOC_ARTICLES_OF_ASSOCIATION')),
				'SHAREHOLDER_DECLARATION' =>
JHTML::_('select.option', 'SHAREHOLDER_DECLARATION',
JText::_('MANGOPAY_DOC_SHAREHOLDER_DECLARATION')),
			);
			echo JHTML::_('select.genericlist', $values,
'mangodoc[type]', '', 'value',
'text', '');
		?></dd>

		<dt><?php
			echo JText::_('MANGOPAY_DOCUMENT_FILE');
		?></dt>
		<dd>
			<input type="file" name="mangodoc_page"/>
		</dd>
	</dl>

	<div>
		<input class="btn btn-primary" value="<?php echo
JText::_('MANGOPAY_ADD_DOCUMENT'); ?>"
type="submit" onclick="return
window.hikamarket.submitform('adddocument','hikamarket_mangopay_document_form');"/>
		<div style="float:right">
			<a class="btn btn-info" href="<?php echo
hikamarket::completeLink('mangopay'); ?>"><?php
echo JText::_('HIKA_CANCEL'); ?></a>
		</div>
	</div>
	<div style="clear:both"></div>

	<input type="hidden" name="option"
value="<?php echo HIKAMARKET_COMPONENT; ?>"/>
	<input type="hidden" name="task"
value="bank"/>
	<input type="hidden" name="ctrl"
value="mangopay"/>
	<?php echo JHTML::_('form.token'); ?>
</form>
mangopay/views/mangopaymarket/tmpl/index.html000064400000000054151166037470015515
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay/views/mangopaymarket/tmpl/payout.php000064400000005077151166037470015564
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><h1><?php echo JText::_('HIKAM_MANGOPAY_TITLE');
?></h1>
<form action="<?php echo
hikamarket::completeLink('mangopay');?>"
method="post" name="hikamarket_form"
id="hikamarket_mangopay_payout_form">
	<dl class="mangopay_payout dl-horizontal">
		<dt><?php echo JText::_('MANGOPAY_CURRENT_BALANCE');
?></dt>
		<dd><?php echo
$this->currencyClass->format($this->mango_wallet->Balance->Amount
/ 100, $this->currency_id); ?></dd>
		<dt><?php echo JText::_('MANGOPAY_AUTHORIZED_PAYOUT');
?></dt>
		<dd><?php echo
$this->currencyClass->format($this->maximum_authorized,
$this->currency_id); ?></dd>
	</dl>
	<dl class="mangopay_payout dl-horizontal">
		<dt><?php echo JText::_('MANGOPAY_PAYOUT_VALUE');
?></dt>
		<dd>
			<input type="text" value="<?php echo
number_format($this->maximum_authorized, 2, '.',
''); ?>" placeholder="<?php echo
number_format($this->maximum_authorized, 2, '.',
''); ?>" name="payout[value]"/>
			<?php echo $this->mango_wallet->Balance->Currency;?>
		</dd>
		<dt><?php echo JText::_('MANGOPAY_PAYOUT_BANK');
?></dt>
		<dd><?php
			if(empty($this->mango_bank_accounts)) {
				echo '<em>' .
JText::_('MANGOPAY_NO_BANK_ACCOUNT') . '</em>';
			} else {
				$bank_accounts = array();
				foreach($this->mango_bank_accounts as $bank_account) {
					$bank_accounts[] = JHTML::_('select.option',
$bank_account->Id, $bank_account->OwnerName . ' ' .
$bank_account->OwnerAddress . ' (' . $bank_account->Type .
')');
				}
				echo JHTML::_('select.genericlist', $bank_accounts,
'payout[bank]', ' style="width:100%"',
'value', 'text', '');
			}
		?></dd>
	</dl>
	<div>
		<input class="btn btn-primary" value="<?php echo
JText::_('MANGOPAY_PAYOUT'); ?>" type="submit"
onclick="return
window.hikamarket.submitform('dopayout','hikamarket_mangopay_payout_form');"/>
		<div style="float:right">
			<a class="btn btn-info" href="<?php echo
hikamarket::completeLink('mangopay'); ?>"><?php
echo JText::_('HIKA_CANCEL'); ?></a>
		</div>
	</div>
	<div style="clear:both"></div>
	<input type="hidden" name="payout[wallet]"
value="<?php echo $this->walletId; ?>"/>

	<input type="hidden" name="option"
value="<?php echo HIKAMARKET_COMPONENT; ?>"/>
	<input type="hidden" name="task"
value="payout"/>
	<input type="hidden" name="ctrl"
value="mangopay"/>
	<?php echo JHTML::_('form.token'); ?>
</form>
mangopay/views/mangopaymarket/tmpl/show.php000064400000022460151166037470015216
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><h1><?php echo JText::_('HIKAM_MANGOPAY_TITLE');
?></h1>
<form action="<?php echo
hikamarket::completeLink('mangopay');?>"
method="post" name="hikamarket_form"
id="hikamarket_mangopay_form">
	<ul class="hikam_tabs"
rel="tabs:hikamarket_mangopay_tab_">
		<li class="active"><a href="#wallet"
rel="tab:1" onclick="return
window.hikamarket.switchTab(this);"><?php echo
JText::_('HIKAM_MANGO_WALLET'); ?></a></li>
		<li><a href="#bank" rel="tab:2"
onclick="return window.hikamarket.switchTab(this);"><?php
echo JText::_('HIKAM_MANGO_BANK'); ?></a></li>
		<li><a href="#profile" rel="tab:3"
onclick="return window.hikamarket.switchTab(this);"><?php
echo JText::_('HIKAM_MANGO_PROFILE'); ?></a></li>
		<li><a href="#document" rel="tab:4"
onclick="return window.hikamarket.switchTab(this);"><?php
echo JText::_('HIKAM_MANGO_DOCUMENTS');
?></a></li>
	</ul>
	<div style="clear:both"></div>

<div id="hikamarket_mangopay_tab_1">
<?php
	if(count($this->mango_wallets) == 1) {
		$wallet = reset($this->mango_wallets);
?>
	<dl class="mangopay_wallet_details dl-horizontal">
		<dt><?php echo JText::_('CURRENCY'); ?></dt>
		<dd><?php echo $wallet->Currency; ?></dd>
		<dt><?php echo JText::_('MANGOPAY_BALANCE');
?></dt>
		<dd><?php
			$currency_id =
$this->convertCurrency($wallet->Balance->Currency);
			$amount = (float)hikamarket::toFloat($wallet->Balance->Amount) /
100;
			echo $this->currencyClass->format($amount, $currency_id);
		?></dd>
		<dt><?php echo JText::_('MANGOPAY_PAYOUT');
?></dt>
		<dd><?php
			if($amount > 0)
				echo '<a
href="'.hikamarket::completeLink('mangopay&task=payout&wallet='.(int)$wallet->Id).'">'.JText::_('MANGOPAY_DO_PAYOUT').'</a>';
			else
				echo
'<em>'.JText::_('MANGOPAY_NO_PAYOUT').'</em>';
		?></dd>
	</dl>
<?php
	} else {
?>
	<table class="hikam_listing <?php echo
(HIKASHOP_RESPONSIVE)?'table table-striped
table-hover':'hikam_table'; ?>"
style="width:100%">
		<thead>
			<tr>
				<th><?php echo JText::_('CURRENCY');
?></th>
				<th><?php echo JText::_('MANGOPAY_BALANCE');
?></th>
				<th><?php echo JText::_('MANGOPAY_PAYOUT');
?></th>
			</tr>
		</thead>
		<tbody>
<?php
		foreach($this->mango_wallets as $wallet) {
?>
			<tr>
				<td><?php echo $wallet->Currency; ?></td>
				<td><?php
					$currency_id =
$this->convertCurrency($wallet->Balance->Currency);
					$amount = (float)hikamarket::toFloat($wallet->Balance->Amount) /
100;
					echo $this->currencyClass->format($amount, $currency_id);
				?></td>
				<td><?php
					if($amount > 0)
						echo '<a class="btn btn-success"
href="'.hikamarket::completeLink('mangopay&task=payout&wallet='.(int)$wallet->Id).'">'.JText::_('MANGOPAY_DO_PAYOUT').'</a>';
					else
						echo
'<em>'.JText::_('MANGOPAY_NO_PAYOUT').'</em>';
				?></td>
			</tr>
<?php
		}
?>
		</tbody>
	</table>
<?php
	}
?>
</div>

<div id="hikamarket_mangopay_tab_2"
style="display:none;">
<?php
	if(!empty($this->mango_bank_accounts)) {
?>
	<table class="hikam_listing <?php echo
(HIKASHOP_RESPONSIVE)?'table table-striped
table-bordered':'hikam_table'; ?>"
style="width:100%">
		<thead>
			<tr>
				<th><?php echo JText::_('MANGOPAY_BANK_TYPE');
?></th>
				<th><?php echo JText::_('MANGOPAY_BANK_OWNER_NAME');
?></th>
				<th><?php echo
JText::_('MANGOPAY_BANK_OWNER_ADDRESS'); ?></th>
			</tr>
		</thead>
		<tbody>
<?php
			foreach($this->mango_bank_accounts as $bank) {
?>
			<tr>
				<td><?php echo $this->escape($bank->Type);
?></td>
				<td><?php echo $this->escape($bank->OwnerName);
?></td>
				<td><?php echo $this->escape($bank->OwnerAddress);
?></td>
			</tr>
			<tr><td colspan="3">
				<dl class="mangopay_bank_details
dl-horizontal"><?php
					foreach($bank->Details as $k => $v) {
						echo
'<dt>'.JText::_('MANGOPAY_BANK_'.$k).'</dt>'.
							'<dd>'.$this->escape($v).'</dd>';
					}
				?></dl>
			</td></tr>
<?php
		}
?>
		</tbody>
	</table>
<?php
	} else {
		echo
'<p><em>'.JText::_('MANGOPAY_NO_BANKACOUNT').'</em></p>';
	}
?>
	<a class="btn btn-info" href="<?php echo
hikamarket::completeLink('mangopay&task=bank');
?>"><?php echo
JText::_('MANGOPAY_ADD_BANKACCOUNT'); ?></a>
</div>

<div id="hikamarket_mangopay_tab_3"
style="display:none;">
	<dl class="mangopay_profile_main dl-horizontal">
		<dt><?php
			echo JText::_('HIKA_NAME');
		?></dt>
		<dd><input type="text" name="mango[name]"
value="<?php echo
$this->escape($this->mango_vendor->Name);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_EMAIL');
		?></dt>
		<dd><input type="text" name="mango[email]"
value="<?php echo
$this->escape($this->mango_vendor->Email);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALPERSONTYPE');
		?></dt>
		<dd><?php
			$values = array(
				'BUSINESS' => JHTML::_('select.option',
'BUSINESS', JText::_('MANGOPAY_PERSONTYPE_BUSINESS')),
				'ORGANIZATION' => JHTML::_('select.option',
'ORGANIZATION',
JText::_('MANGOPAY_PERSONTYPE_ORGANIZATION')),
				'SOLETRADER' => JHTML::_('select.option',
'SOLETRADER',
JText::_('MANGOPAY_PERSONTYPE_SOLETRADER')),
			);
			echo JHTML::_('select.genericlist', $values,
'mango[legalpersontype]', '', 'value',
'text', $this->mango_vendor->LegalPersonType);
		?></dd>
		<dt><?php
			echo JText::_('MANGOPAY_HEADQUARTERSADDRESS');
		?></dt>
		<dd><input type="text"
name="mango[headquartersaddress]" value="<?php echo
$this->escape($this->mango_vendor->HeadquartersAddress);
?>"/></dd>
	</dl>

	<h3><?php echo
JText::_('MANGOPAY_LEGALREPRESENTATIVE'); ?></h3>
	<dl class="mangopay_profile_legal dl-horizontal">
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVEFIRSTNAME');
		?></dt>
		<dd><input type="text"
name="mango[legalrepresentativefirstname]" value="<?php
echo
$this->escape($this->mango_vendor->LegalRepresentativeFirstName);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVELASTNAME');
		?></dt>
		<dd><input type="text"
name="mango[legalrepresentativelastname]" value="<?php
echo
$this->escape($this->mango_vendor->LegalRepresentativeLastName);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVEADDRESS');
		?></dt>
		<dd><input type="text"
name="mango[legalrepresentativeaddress]" value="<?php
echo
$this->escape($this->mango_vendor->LegalRepresentativeAddress);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVEEMAIL');
		?></dt>
		<dd><input type="text"
name="mango[legalrepresentativeemail]" value="<?php echo
$this->escape($this->mango_vendor->LegalRepresentativeEmail);
?>"/></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVEBIRTHDAY');
		?></dt>
		<dd><?php
			$birthday =
(int)$this->mango_vendor->LegalRepresentativeBirthday;
			if(empty($birthday))
				$birthday = time();
			echo JHTML::_('calendar',
hikamarket::getDate($birthday,'%Y-%m-%d'),
'mango[legalrepresentativebirthday]','mango_legalrepresentativebirthday','%Y-%m-%d',array('size'
=> '20'));
		?></dd>
		<dt><?php
			echo JText::_('MANGOPAY_LEGALREPRESENTATIVENATIONALITY');
		?></dt>
		<dd><?php
			$countries = $this->getCountryList();
			echo JHTML::_('select.genericlist', $countries,
'mango[legalrepresentativenationality]', '',
'value', 'text',
$this->mango_vendor->LegalRepresentativeNationality);
		?></dd>
		<dt><?php
			echo
JText::_('MANGOPAY_LEGALREPRESENTATIVECOUNTRYOFRESIDENCE');
		?></dt>
		<dd><?php
			echo JHTML::_('select.genericlist', $countries,
'mango[legalrepresentativecountryofresidence]', '',
'value', 'text',
$this->mango_vendor->LegalRepresentativeCountryOfResidence);
		?></dd>
	</dl>

	<input class="btn btn-primary" value="<?php echo
JText::_('HIKA_SAVE'); ?>" type="submit"
onclick="return
window.hikamarket.submitform('save','hikamarket_mangopay_form');"/>
</div>

<div id="hikamarket_mangopay_tab_4"
style="display:none;">
	<dl class="mangopay_profile_documents dl-horizontal">
		<dt><?php
			echo JText::_('MANGOPAY_STATUTE');
		?></dt>
		<dd><?php
			if($this->mango_vendor->Statute == null) {
				echo '<em>' . JText::_('HIKA_NONE') .
'</em>';
			} else {
				echo $this->escape($this->mango_vendor->Statute);
			}
		?></dd>
		<dt><?php
			echo JText::_('MANGOPAY_PROOF_REGISTRATION');
		?></dt>
		<dd><?php
			if($this->mango_vendor->ProofOfRegistration == null) {
				echo '<em>' . JText::_('HIKA_NONE') .
'</em>';
			} else {
				echo $this->escape($this->mango_vendor->ProofOfRegistration);
			}
		?></dd>
<?php
		if($this->mango_vendor->LegalPersonType == 'BUSINESS') {
?>
		<dt><?php
			echo JText::_('MANGOPAY_SHAREHOLDER_DECLARATION');
		?></dt>
		<dd><?php
			if($this->mango_vendor->ShareholderDeclaration == null) {
				echo '<em>' . JText::_('HIKA_NONE') .
'</em>';
			} else {
				echo
$this->escape($this->mango_vendor->ShareholderDeclaration);
			}
		?></dd>
<?php
		}
?>
	</dl>
	<a class="btn btn-info" href="<?php echo
hikamarket::completeLink('mangopay&task=document');
?>"><?php echo JText::_('MANGOPAY_ADD_DOCUMENT');
?></a>
</div>

	<input type="hidden" name="option"
value="<?php echo HIKAMARKET_COMPONENT; ?>"/>
	<input type="hidden" name="task"
value="show"/>
	<input type="hidden" name="ctrl"
value="mangopay"/>
	<?php echo JHTML::_('form.token'); ?>
</form>
mangopay/views/mangopaymarket/view.html.php000064400000013655151166037500015177
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class mangopaymarketViewmangopaymarket extends HikamarketView {
	public function display($tpl = null, $params = array()) {
		$this->params =& $params;
		$fct = $this->getLayout();
		if(method_exists($this, $fct)) {
			if($this->$fct() === false)
				return;
		}
		parent::display($tpl);
	}

	protected function loadCSS() {
		$doc = JFactory::getDocument();
		$doc->addStyleSheet(JURI::base(true).'/plugins/hikamarket/mangopay/media/mangopay.css?v='.HIKAMARKET_RESSOURCE_VERSION);
	}

	public function show() {
		$this->loadCSS();

		$config = hikamarket::config();
		$shopConfig = hikamarket::config(false);

		$this->vendor = hikamarket::loadVendor(true);
		if(is_string($this->vendor->vendor_params) &&
!empty($this->vendor->vendor_params))
			$this->vendor->vendor_params =
hikamarket::unserialize($this->vendor->vendor_params);

		$this->currencyClass =
hikamarket::get('shop.class.currency');
		$this->mangoClass = hikamarket::get('class.plg_mangopay');

		$this->mangopayPlugin = $this->mangoClass->getMangoPlugin();
		$this->api = $this->mangoClass->getMangoAPI();
		$this->mango_vendor = null;
		$this->mango_wallets = null;
		$this->mango_bank_accounts = null;

		$this->mango_vendor =
$this->mangopayPlugin->getVendor($this->vendor);

		if(!empty($this->mango_vendor->Id)) {

			$this->mango_wallets =
$this->mangopayPlugin->getVendorWallets($this->vendor);

			if(empty($this->mango_wallets)) {
				$wallet =
$this->mangopayPlugin->getVendorWallet($this->vendor, null,
true);
				$this->mango_wallets[ strtolower($wallet->Currency) ] = $wallet;
			}

			try {

				$this->mango_bank_accounts =
$this->api->Users->GetBankAccounts($this->mango_vendor->Id);

			}
			catch (MangoPay\ResponseException $e) {
$this->mangoClass->mangoDebug($e, true); }
			catch (MangoPay\Exception $e) { $this->mangoClass->mangoDebug($e,
false); }
			catch (Exception $e) {}
		}

		$this->toolbar = array(
			array(
				'icon' => 'back',
				'name' => JText::_('HIKA_BACK'),
				'url' => hikamarket::completeLink('vendor')
			)
		);
	}

	public function payout() {
		$this->loadCSS();

		$config = hikamarket::config();
		$shopConfig = hikamarket::config(false);
		$app = JFactory::getApplication();

		$this->vendor = hikamarket::loadVendor(true);
		if(is_string($this->vendor->vendor_params) &&
!empty($this->vendor->vendor_params))
			$this->vendor->vendor_params =
hikamarket::unserialize($this->vendor->vendor_params);

		$walletId = hikaInput::get()->getInt('wallet', 0);
		if(empty($walletId)) {
			$app->enqueueMessage(JText::_('MANGO_INVALID_REQUEST'));
			$app->redirect( hikamarket::completeLink('mangopay', false,
true, false) );
		}

		$this->currencyClass =
hikamarket::get('shop.class.currency');
		$this->mangoClass = hikamarket::get('class.plg_mangopay');

		$this->mangopayPlugin = $this->mangoClass->getMangoPlugin();

		$this->mango_vendor =
$this->mangopayPlugin->getVendor($this->vendor);
		if(empty($this->mango_vendor->Id)) {
			$app->enqueueMessage(JText::_('MANGO_INVALID_REQUEST'));
			$app->redirect( hikamarket::completeLink('mangopay', false,
true, false) );
		}

		$this->api = $this->mangoClass->getMangoAPI();
		$this->mango_wallets = null;
		$this->mango_bank_accounts = null;

		$mango_wallets =
$this->mangopayPlugin->getVendorWallets($this->vendor);
		$this->mango_wallet = null;
		foreach($mango_wallets as $mango_wallet) {
			if((int)$mango_wallet->Id == $walletId) {
				$this->mango_wallet = $mango_wallet;
				break;
			}
		}
		if(empty($this->mango_wallet)) {
			$app->enqueueMessage(JText::_('MANGO_INVALID_WALLET'));
			$app->redirect( hikamarket::completeLink('mangopay', false,
true, false) );
		}
		$this->assignRef('walletId', $walletId);

		$duration = 31;
		if(isset($this->mangopayPlugin->params))
			$duration =
(int)$this->mangopayPlugin->params->get('payout_waiting_duration',
31);
		if($duration <= 0)
			$duration = 31;

		$this->currency_id =
$this->convertCurrency($this->mango_wallet->Balance->Currency);
		$this->transactions =
$this->mangoClass->getTransactions($this->mango_wallet->Id,
$duration);

		$this->transactions_total = 0.0;
		foreach($this->transactions as $transaction) {
			if($transaction->Nature == 'REGULAR')
				$this->transactions_total +=
($transaction->CreditedFunds->Amount / 100);

			if($transaction->Nature == 'REFUND')
				$this->transactions_total -=
($transaction->CreditedFunds->Amount / 100);
		}
		if($this->transactions_total < 0)
			$this->transactions_total = 0.0;

		$this->maximum_authorized =
($this->mango_wallet->Balance->Amount / 100) -
$this->transactions_total;
		if($this->maximum_authorized < 0)
			$this->maximum_authorized = 0.0;

		try {

			$this->mango_bank_accounts =
$this->api->Users->GetBankAccounts($this->mango_vendor->Id);

		}
		catch (MangoPay\ResponseException $e) {
$this->mangoClass->mangoDebug($e, true); }
		catch (MangoPay\Exception $e) { $this->mangoClass->mangoDebug($e,
false); }
		catch (Exception $e) {}
	}

	public function document() {
	}

	public function getCountryList() {
		if(empty($this->mangopayPlugin))
			$this->mangopayPlugin = $this->mangoClass->getMangoPlugin();
		$countries = $this->mangopayPlugin->getCountryList();
		$ret = array();
		foreach($countries as $country) {
			$ret[] = JHTML::_('select.option', $country, $country);
		}
		return $ret;
	}

	protected function convertCurrency($currency_code) {
		$db = JFactory::getDBO();
		$query = 'SELECT currency_id FROM ' .
hikamarket::table('shop.currency') . ' WHERE currency_code =
' . $db->Quote(strtoupper(trim($currency_code)));
		$db->setQuery($query);
		$ret = (int)$db->loadResult();
		return $ret;
	}
}
vendorlocationfilter/index.html000064400000000054151166037500013000
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>vendorlocationfilter/vendorlocationfilter.php000064400000013224151166037500015753
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikamarketVendorlocationfilter extends JPlugin {

	protected $db = null;

	public function __construct(&$subject, $config) {
		parent::__construct($subject, $config);

		if(!isset($this->params)) {
			$plugin = JPluginHelper::getPlugin('hikamarket',
'vendorlocationfilter');
			$this->params = new JRegistry($plugin->params);
		}
	}

	public function init() {
		static $init = null;
		if($init !== null)
			return $init;
		$use_search_module =
(int)$this->params->get('use_search_module', 1);
		if(!$use_search_module) {
			$init = false;
			return false;
		}
		$this->db = JFactory::getDBO();
		$init = true;
		return true;
	}

	private function dbEscape($data) {
		if(empty($this->db))
			$this->db = JFactory::getDBO();
		if(HIKASHOP_J30)
			return $this->db->escape($data, true);
		return $this->db->getEscaped($data, true);
	}

	public function onBeforeVendorListingDisplay(&$view, &$params) {
		$app = JFactory::getApplication();
		if($app->isAdmin() || !$this->init())
			return;

		$use_search_module =
(int)$this->params->get('use_search_module', 1);
		$empty_is_all = (int)$this->params->get('empty_is_all',
1);
		$hide_for_guest =
(int)$this->params->get('hide_for_guest', 0);


		$location_search = null;
		if($use_search_module) {
			$location_search =
hikaInput::get()->getVar('location_search', null);
			if($location_search !== null) {
				$app->setUserState(HIKAMARKET_COMPONENT.'.vendor_location_filter.search',
$location_search);
			} else {
				$location_search =
$app->getUserState(HIKAMARKET_COMPONENT.'.vendor_location_filter.search',
null);
			}
			if(empty($location_search))
				$location_search = null;
		}

		$filter_mode = $this->params->get('filter_mode',
'zip;city');
		if(empty($filter_mode)) $filter_mode = 'zip;city';
		$filter_mode = explode(';', trim($filter_mode));
		$vendorZipColumn =
$this->params->get('vendor_zip_column',
'accepted_zip');
		if(empty($vendorZipColumn)) $vendorZipColumn = 'accepted_zip';
		$vendorZipColumn = $this->db->quoteName($vendorZipColumn);
		$vendorCitiesColumn =
$this->params->get('vendor_city_column',
'accepted_cities');
		if(empty($vendorCitiesColumn)) $vendorCitiesColumn =
'accepted_cities';
		$vendorCitiesColumn = $this->db->quoteName($vendorCitiesColumn);

		$user_id = hikashop_loadUser();
		if(empty($user_id) && !$use_search_module) {
			if(!empty($hide_for_guest)) {
				$this->pushEmptyFilter($params, $filter_mode, $vendorZipColumn,
$vendorCitiesColumn);
				$this->mergeFilters($params);
			}
			return;
		}

		$addressClass = hikashop_get('class.address');
		if(!empty($user_id))
			$addresses = $addressClass->loadUserAddresses($user_id);
		$userZip = 0;
		$userCity = '';
		if(!empty($addresses)) {
			$address = reset($addresses);
			if(!empty($address->address_post_code))
				$userZip = trim($address->address_post_code);
			if(!empty($address->address_city))
				$userCity = trim($address->address_city);
		}

		if((int)$this->params->get('zipcode_digits', 0))
			$userZip = '' . ((int)$userZip);

		$zipMode = in_array('zip', $filter_mode);
		$cityMode = in_array('city', $filter_mode);

		if($location_search === null && (!$zipMode || empty($userZip))
&& (!$cityMode || empty($userCity))) {
			$this->pushEmptyFilter($params, $filter_mode, $vendorZipColumn,
$vendorCitiesColumn);
			$this->mergeFilters($params);
			return;
		}

		if(in_array('zip', $filter_mode)) {
			$f = array();
			$stars = '*';
			if($location_search !== null || !empty($userZip)) {
				if($location_search !== null) {
					$f[] = 'vendor.'.$vendorZipColumn.' LIKE
\'%'.$this->dbEscape($location_search).'%\'';
				} else {
					$f[] = 'vendor.'.$vendorZipColumn.' LIKE
\'%'.$this->dbEscape($userZip).'%\'';
				}
				if(!empty($userZip)) {
					for($i = strlen($userZip) - 1; $i > 1; $i--) {
						$z = substr($userZip, 0, $i) . $stars;
						$f[] = 'vendor.'.$vendorZipColumn.' LIKE
\'%'.$this->dbEscape($z).'%\'';
						$stars .= '*';
					}
				}
			}
			unset($stars);

			if(!empty($f))
				$params['filter']['zip_filter'] =
'('.implode(') OR (', $f).')';
		}

		if(in_array('city', $filter_mode) && ($location_search
!== null || !empty($userCity))) {
			if($location_search !== null) {
				$params['filter']['city_filter'] =
'vendor.'.$vendorCitiesColumn.' LIKE
\'%'.$this->dbEscape($location_search).'%\'';
			} else {
				$params['filter']['city_filter'] =
'vendor.'.$vendorCitiesColumn.' LIKE
\'%'.$this->dbEscape($userCity).'%\'';
			}
		}

		$this->mergeFilters($params);
	}

	private function pushEmptyFilter(&$params, $filter_mode,
$vendorZipColumn, $vendorCitiesColumn) {
		if(in_array('zip', $filter_mode))
			$params['filter']['hide_zip_guest'] =
'(vendor.'. $vendorZipColumn.' IS NULL OR vendor.'.
$vendorZipColumn.' = \'\' OR vendor.'.
$vendorZipColumn.' = \'*\')';
		if(in_array('city', $filter_mode))
			$params['filter']['hide_city_guest'] =
'(vendor.'. $vendorCitiesColumn.' IS NULL OR vendor.'.
$vendorCitiesColumn.' = \'\' OR vendor.'.
$vendorCitiesColumn.' = \'*\')';
	}

	private function mergeFilters(&$params) {
		if(isset($params['filter']['zip_filter']) &&
isset($params['filter']['city_filter'])) {
			$params['filter']['location_filter'] = '('
. $params['filter']['zip_filter'] . ') OR ('
. $params['filter']['city_filter'] . ')';
			unset($params['filter']['zip_filter']);
			unset($params['filter']['city_filter']);
		}
	}
}
vendorlocationfilter/vendorlocationfilter.xml000064400000007300151166037500015762
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin"
group="hikamarket" method="upgrade">
	<name>HikaMarket Vendor User Location Filter</name>
	<hikainstall ordering="0" enable="0"
report="0" />
	<creationDate>20 juillet 2020</creationDate>
	<version>3.1.1</version>
	<author>Obsidev</author>
	<authorEmail>contact@obsidev.com</authorEmail>
	<authorUrl>http://www.hikashop.com</authorUrl>
	<copyright>(C) 2011-2020 OBSIDEV. All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>HikaMarket Vendor User Location
Filter</description>
	<files>
		<filename
plugin="vendorlocationfilter">vendorlocationfilter.php</filename>
	</files>
	<params addpath="/components/com_hikamarket/params">
		<param name="use_search_module" type="radio"
default="1" label="Use search module"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="filter_mode" type="list"
default="zip" label="Filter Mode"
description="">
			<option value="zip">Zip</option>
			<option value="city">City</option>
			<option value="zip;city">Both</option>
		</param>
		<param name="vendor_zip_column" type="text"
label="Vendor Zips field" size="30"
default="accepted_zip" description="The vendor custom field
column name for the list of zip" />
		<param name="vendor_city_column" type="text"
label="Vendor City field" size="30"
default="accepted_cities" description="The vendor custom
field column name for the list of cities" />
		<param name="empty_is_all" type="radio"
default="1" label="Empty field means *all*"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="hide_for_guest" type="radio"
default="0" label="Hide for guest"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="zipcode_digits" type="radio"
default="0" label="Zips are only digits"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikamarket/fields">
			<fieldset name="basic">
				<field name="use_search_module" type="radio"
default="1" label="Use search module"
description="" class="btn-group btn-group-yesno">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="filter_mode" type="list"
default="zip" label="Filter Mode"
description="">
					<option value="zip">Zip</option>
					<option value="city">City</option>
					<option value="zip;city">Both</option>
				</field>
				<field name="vendor_zip_column" type="text"
label="Vendor Zips field" size="30"
default="accepted_zip" description="The vendor custom field
column name for the list of zip" />
				<field name="vendor_city_column" type="text"
label="Vendor City field" size="30"
default="accepted_cities" description="The vendor custom
field column name for the list of cities" />
				<field name="empty_is_all" type="radio"
default="1" label="Empty field means *all*"
description="" class="btn-group btn-group-yesno">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="hide_for_guest" type="radio"
default="0" label="Hide for guest"
description="" class="btn-group btn-group-yesno">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="zipcode_digits" type="radio"
default="0" label="Zips are only digits"
description="" class="btn-group btn-group-yesno">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
vendorpaytaxes/index.html000064400000000054151166037500011620
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>vendorpaytaxes/vendorpaytaxes.php000064400000003727151166037500013422
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikamarketVendorpaytaxes extends JPlugin {
	public function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	private function init() {
		if(isset($this->params))
			return;
		$plugin = JPluginHelper::getPlugin('hikamarket',
'vendorpaytaxes');
		$this->params = new JRegistry(@$plugin->params);
	}

	public function onBeforeVendorPay(&$order, &$vendor, &$orders,
&$pay_orders, &$do) {
		$this->init();

		$config = hikamarket::config();
		$shopOrderClass = hikamarket::get('shop.class.order');
		$currencyClass = hikamarket::get('shop.class.currency');
		$addressClass = hikamarket::get('shop.class.address');
		$zoneClass = hikamarket::get('shop.class.zone');

		$tax_id = (int)$this->params->get('tax_id', 0);
		if(empty($tax_id))
			return;

		$config =& hikashop_config();
		$config->set('floating_tax_prices', 0);

		$address = $addressClass->get($order->order_billing_address_id);
		$field = 'address_country';
		if(!empty($address->address_state))
			$field = 'address_state';
		$zones[$address->$field] = $zoneClass->get($address->$field);
		$zone_id = $zones[$address->$field]->zone_id;

		$round = $currencyClass->getRounding($order->order_currency_id,
true);

		$feeMode = ($config->get('market_mode', 'fee') ==
'fee');

		foreach($order->cart->products as &$p) {
			if(!empty($p->order_product_tax))
				continue;
			$p->order_product_tax =
$currencyClass->getTaxedPrice($p->order_product_price, $zone_id,
$tax_id, $round) - $p->order_product_price;
			$p->order_product_tax_info = $currencyClass->taxRates;
		}
		unset($product);

		$shopOrderClass->recalculateFullPrice($order,
$order->cart->products);
	}
}
vendorpaytaxes/vendorpaytaxes.xml000064400000002277151166037500013432
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5"
method="upgrade" group="hikamarket">
	<name>HikaMarket - Taxes for vendor payment</name>
	<hikainstall ordering="1" enable="0"
report="0" />
	<creationDate>20 juillet 2020</creationDate>
	<version>3.1.1</version>
	<author>Obsidev</author>
	<authorEmail>dev@obsidev.com</authorEmail>
	<authorUrl>http://www.obsidev.com</authorUrl>
	<copyright>Copyright (C) 2012-2020 OBSIDEV SARL - All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>This plugin add a fixed tax when a vendor is
paid</description>
	<files>
		<filename
plugin="vendorpaytaxes">vendorpaytaxes.php</filename>
	</files>
	<params addpath="/components/com_hikashop/params">
		<param name="tax_id" type="hikanamebox"
namebox_type="tax_category" default="0" label="Tax
category" description=""/>
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikashop/fields">
			<fieldset name="basic">
				<field name="tax_id" type="hikanamebox"
namebox_type="tax_category" default="0" label="Tax
category" description=""/>
			</fieldset>
		</fields>
	</config>
</extension>
vendorusergroup/index.html000064400000000054151166037500012015
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>vendorusergroup/vendorusergroup.php000064400000004226151166037500014007
0ustar00<?php
/**
 * @package    HikaMarket for Joomla!
 * @version    3.1.1
 * @author     Obsidev S.A.R.L.
 * @copyright  (C) 2011-2020 OBSIDEV. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikamarketVendorUsergroup extends JPlugin {
	public function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	public function onAfterVendorCreate(&$vendor) {
		$vendorGroup = (int)$this->params->get('vendor_group',
0);
		if(empty($vendorGroup))
			return;

		$move_user = (int)$this->params->get('move_user', 0);
		$default_group = (int)$this->params->get('default_group',
0);

		if(!$move_user)
			$default_group = 0;

		$userClass = hikamarket::get('shop.class.user');
		$user = $userClass->get($vendor->vendor_admin_id);
		$user_updated = $this->updateGroup($user->user_cms_id,
$vendorGroup, $default_group);

		$logout_user = (int)$this->params->get('logout_user',
0);
		if(!empty($logout_user) && $user_updated) {
			$jconf = JFactory::getConfig();
			if($jconf->get('session_handler', 'none') ==
'database') {
				$db = JFactory::getDBO();
				$db->setQuery('DELETE FROM ' .
hikamarket::table('session', false).' WHERE client_id = 0
AND userid = ' . (int)$user->user_cms_id);
				$db->execute();
			}

			$app = JFactory::getApplication();
			if(!$app->isAdmin())
				$app->logout($user->user_cms_id);
		}
	}

	private function updateGroup($user_id, $new_group_id, $remove_group_id =
0) {
		$user = clone(JFactory::getUser($user_id));
		$user_update = false;

		jimport('joomla.access.access');
		$userGroups = $user->groups;
		if(empty($userGroups))
			$userGroups = JAccess::getGroupsByUser($user_id, true);
		if(!in_array($new_group_id, $userGroups)) {
			$userGroups[] = $new_group_id;
			$user_update = true;
		}
		if(!empty($remove_group_id)) {
			$key = array_search($remove_group_id, $userGroups);
			if(is_int($key)) {
				$user_update = true;
				unset($userGroups[$key]);
			}
		}
		$user->set('groups', $userGroups);

		if($user_update)
			$user->save();
		return $user_update;
	}
}
vendorusergroup/vendorusergroup.xml000064400000004110151166037500014010
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin"
group="hikamarket">
	<name>HikaMarket vendor user group</name>
	<hikainstall ordering="1" enable="0"
report="0" />
	<creationDate>20 juillet 2020</creationDate>
	<version>3.1.1</version>
	<author>Obsidev</author>
	<authorEmail>dev@obsidev.com</authorEmail>
	<authorUrl>http://www.obsidev.com</authorUrl>
	<copyright>Copyright (C) 2012-2020 OBSIDEV SARL - All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>HikaMarket vendor user group</description>
	<files>
		<filename
plugin="vendorusergroup">vendorusergroup.php</filename>
	</files>
	<params addpath="/components/com_hikamarket/params">
		<param name="vendor_group" type="usergroup"
label="Select a joomla user group for your vendors" />
		<param name="logout_user" type="radio"
default="0" label="Logout the user"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param type="spacer" />
		<param name="move_user" type="radio"
default="0" label="Move user group"
description="">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="default_group" type="usergroup"
label="Select the default user group for generic users" />
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikamarket/fields">
			<fieldset name="basic">
				<field name="vendor_group" type="usergroup"
label="Select a joomla user group for your vendors" />
				<field name="logout_user" type="radio"
default="0" label="Logout the user"
description="">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field type="spacer" />
				<field name="move_user" type="radio"
default="0" label="Move user group"
description="">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="default_group" type="usergroup"
label="Select the default user group for generic users" />
			</fieldset>
		</fields>
	</config>
</extension>