Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
index.html000064400000000054151161154440006542 0ustar00<html><body
bgcolor="#FFFFFF"></body></html>language/en-GB/en-GB.plg_hikamarket_mangopay.ini000064400000004535151161154440015475
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"language/en-GB/index.html000064400000000054151161154440011215
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>language/en-GB/nl-BE.plg_hikamarket_mangopay.ini000064400000004443151161154440015500
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"
language/index.html000064400000000054151161154440010325
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangopay.php000064400000116146151161154440007103
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 plgHikashoppaymentMangopay extends hikashopPaymentPlugin
{
public $accepted_currencies = array(
'EUR','USD','GBP','CHF',
'SEK','NOK','DKK','PLN',
);
public $multiple = true;
public $name = 'mangopay';
public $doc_form = 'mangopay';
public $market_support = true;
var $pluginConfig = array(
'client_id' => array('ClientId', 'html',
'Please configure credentials in the Joomla plugin manager
side'),
'payment_mode' => array('Payment Mode',
'list', array(
'web' => 'Web'
)),
'debug' => array('DEBUG',
'boolean','0'),
'cancel_url' => array('CANCEL_URL',
'input'),
'return_url' => array('RETURN_URL',
'input'),
'invalid_status' => array('INVALID_STATUS',
'orderstatus', 'cancelled'),
'pending_status' => array('PENDING_STATUS',
'orderstatus', 'created'),
'verified_status' => array('VERIFIED_STATUS',
'orderstatus', 'confirmed'),
);
protected $api = null;
private function initMarket() {
static $init = null;
if($init !== null)
return $init;
$init = defined('HIKAMARKET_COMPONENT');
if(!$init) {
$filename =
rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikamarket'.DS.'helpers'.DS.'helper.php';
if(file_exists($filename)) {
include_once($filename);
$init = defined('HIKAMARKET_COMPONENT');
}
}
return $init;
}
public function getAPI() {
if(!empty($this->api))
return $this->api;
if(version_compare(PHP_VERSION, '5.3', '<'))
return false;
require_once
dirname(__FILE__).DS.'mangolib'.DS.'mangoPayApi.inc';
$this->api = new MangoPay\MangoPayApi();
if(!isset($this->params)) {
$plugin = JPluginHelper::getPlugin('hikashoppayment',
'mangopay');
$this->params = new JRegistry(@$plugin->params);
}
if($this->params->get('clientid', false)) {
$this->api->Config->ClientId =
$this->params->get('clientid');
$this->api->Config->ClientPassword =
$this->params->get('clientpassword');
if((int)$this->params->get('sandbox', 0)) {
$this->api->Config->BaseUrl =
'https://api.sandbox.mangopay.com';
$this->api->Config->TemporaryFolder =
dirname(__FILE__).DS.'tmp'.DS.'debug'.DS;
} else {
$this->api->Config->BaseUrl =
'https://api.mangopay.com';
$this->api->Config->TemporaryFolder =
dirname(__FILE__).DS.'tmp'.DS.'prod'.DS;
}
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
if(!JFolder::exists($this->api->Config->TemporaryFolder))
JFolder::create($this->api->Config->TemporaryFolder);
$content = 'deny from all';
if(!JFile::exists($this->api->Config->TemporaryFolder.'.htaccess'))
JFile::write($this->api->Config->TemporaryFolder.'.htaccess',
$content);
}
return $this->api;
}
public function checkPaymentDisplay(&$method, &$order) {
if(version_compare(PHP_VERSION, '5.3', '<'))
return false;
return true;
}
public function onBeforeOrderCreate(&$order, &$do) {
if(parent::onBeforeOrderCreate($order, $do) === true)
return true;
$this->getAPI();
if(empty($order->user))
$order->user = $this->user;
$mangoUser = $this->getUser($order);
if(!empty($mangoUser->Id))
return true;
$do = false;
$this->app->enqueueMessage('Error during the creation of your
MangoPay customer profile', 'error');
return false;
}
public function onAfterOrderConfirm(&$order, &$methods,
$method_id) {
parent::onAfterOrderConfirm($order, $methods, $method_id);
$notify_url =
HIKASHOP_LIVE.'mangopay_'.$method_id.'.php?order_id='.$order->order_id
. $this->url_itemid;
$this->getAPI();
if(empty($order->user))
$order->user = $this->user;
$mangoUser = $this->getUser($order);
if(empty($this->payment_params->payment_mode) ||
!in_array($this->payment_params->payment_mode,
array('direct', 'web')))
$this->payment_params->payment_mode = 'web';
$update_order = new stdClass();
$update_order->order_id = $order->order_id;
$update_order->order_payment_params =
@$order->order_payment_params;
if(empty($update_order->order_payment_params))
$update_order->order_payment_params = new stdClass();
if(empty($order->order_payment_params->mangopay))
$update_order->order_payment_params->mangopay = new stdClass();
if($this->payment_params->payment_mode == 'direct') {
$cardRegister = new MangoPay\CardRegistration();
$cardRegister->UserId = $mangoUser->Id;
$cardRegister->Currency =
strtoupper($this->currency->currency_code);
try {
$createdCardRegister =
$this->api->CardRegistrations->Create($cardRegister);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
$update_order->order_payment_params->mangopay->cardRegisterId =
$createdCardRegister->Id;
$this->return_url = $notify_url;
$this->createdCardRegister = $createdCardRegister;
$db = JFactory::getDBO();
$query = 'UPDATE ' . hikashop_table('order') .
' SET order_payment_params = ' .
$db->Quote(serialize($update_order->order_payment_params)) .
' WHERE order_id = ' . (int)$update_order->order_id;
$db->setQuery($query);
$db->execute();
return $this->showPage('end');
}
if($this->payment_params->payment_mode == 'web') {
$wallet = new MangoPay\Wallet();
$wallet->Owners = array( $mangoUser->Id );
$wallet->Currency =
strtoupper($this->currency->currency_code);
$wallet->Description = $order->order_number;
$wallet->Tag = 'order#' . $order->order_id;
$createdWallet = false;
try {
$createdWallet = $this->api->Wallets->Create($wallet);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
$lang = JFactory::getLanguage();
$locale = strtoupper(substr($lang->get('tag'), 0, 2));
$PayIn = new MangoPay\PayIn();
$PayIn->CreditedWalletId = $createdWallet->Id;
$PayIn->AuthorId = $mangoUser->Id;
$PayIn->PaymentType = 'CARD';
$PayIn->PaymentDetails = new MangoPay\PayInPaymentDetailsCard();
$PayIn->PaymentDetails->CardType =
'CB_VISA_MASTERCARD';
$PayIn->DebitedFunds = new MangoPay\Money();
$PayIn->DebitedFunds->Currency =
strtoupper($this->currency->currency_code);
$PayIn->DebitedFunds->Amount = round($order->order_full_price *
100);
$PayIn->Fees = new MangoPay\Money();
$PayIn->Fees->Currency =
strtoupper($this->currency->currency_code);
$PayIn->Fees->Amount = 0;
$PayIn->ExecutionType = 'WEB';
$PayIn->ExecutionDetails = new MangoPay\PayInExecutionDetailsWeb();
$PayIn->ExecutionDetails->ReturnURL = $notify_url;
$PayIn->ExecutionDetails->Culture = $locale;
$PayIn->Tag = 'order#' . $order->order_id;
$createdPayIn = null;
try {
$createdPayIn = $this->api->PayIns->Create($PayIn);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
$update_order->order_payment_params->mangopay->payInId =
$createdPayIn->Id;
$update_order->order_payment_params->mangopay->walletId =
$createdWallet->Id;
$this->return_url =
$createdPayIn->ExecutionDetails->RedirectURL;
$this->createdPayIn = $createdPayIn;
$db = JFactory::getDBO();
$query = 'UPDATE ' . hikashop_table('order') .
' SET order_payment_params = ' .
$db->Quote(serialize($update_order->order_payment_params)) .
' WHERE order_id = ' . (int)$update_order->order_id;
$db->setQuery($query);
$db->execute();
$app = JFactory::getApplication();
$app->redirect( $createdPayIn->ExecutionDetails->RedirectURL
);
}
}
public function onAfterOrderUpdate(&$order) {
if(empty($order->order_status))
return;
$order_payment_method = !empty($order->order_payment_method) ?
$order->order_payment_method :
@$order->old->order_payment_method;
if($order_payment_method != 'mangopay')
return;
$order_type = !empty($order->order_type) ? $order->order_type :
@$order->old->order_type;
if($order_type != 'sale')
return;
$order_payment_params = !empty($order->order_payment_params) ?
$order->order_payment_params : $order->old->order_payment_params;
if(is_string($order_payment_params))
$order_payment_params = unserialize($order_payment_params);
if(!empty($order_payment_params->mangopay->paid))
return;
if(!isset($this->params)) {
$plugin = JPluginHelper::getPlugin('hikashoppayment',
'mangopay');
$this->params = new JRegistry(@$plugin->params);
}
$confirmed = explode(',',
trim($this->params->get('order_status', ''),
','));
if(count($confirmed) == 1 && empty($confirmed[0]))
$confirmed = array();
$shopConfig = hikashop_config();
if(empty($confirmed)) {
$confirmed = explode(',',
trim($shopConfig->get('invoice_order_statuses'),
','));
if(empty($confirmed))
$confirmed = array('confirmed','shipped');
}
$refund_statuses = explode(',',
trim($shopConfig->get('cancelled_order_status'),
','));
if(in_array($order->order_status, $confirmed)) {
$this->payVendors($order);
}
return;
}
public function checkOrderStatuses(&$messages) {
return;
}
public function onPaymentNotification(&$statuses) {
$order_id = (int)@$_GET['order_id'];
$transaction_id = (int)@$_GET['transactionId'];
if(!empty($order_id) && !empty($transaction_id))
return $this->paymentNotificationSecureReturn($transaction_id,
$order_id, $statuses);
if(!empty($order_id))
return $this->paymentNotificationCardReturn($order_id, $statuses);
return false;
}
protected function paymentNotificationCardReturn($order_id,
&$statuses) {
$dbOrder = $this->getOrder((int)$order_id);
$this->loadPaymentParams($dbOrder);
if(empty($this->payment_params))
return false;
$this->loadOrderData($dbOrder);
if(is_string($dbOrder->order_payment_params))
$dbOrder->order_payment_params =
unserialize($dbOrder->order_payment_params);
$cancel_url = HIKASHOP_LIVE .
'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id='
. $dbOrder->order_id . $this->url_itemid;
$confirm_url = HIKASHOP_LIVE .
'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='
. $dbOrder->order_id . $this->url_itemid;
if(empty($dbOrder->order_payment_params->mangopay->cardRegisterId)
&&
!empty($dbOrder->order_payment_params->mangopay->walletId)) {
if($dbOrder->order_status ==
$this->payment_params->invalid_status) {
$this->app->redirect($cancel_url);
exit;
}
$this->app->redirect($confirm_url);
exit;
}
if(empty($dbOrder->order_payment_params->mangopay->cardRegisterId))
die('Invalid order');
$payment_id = (int)$dbOrder->order_payment_id;
$this->getAPI();
try {
$cardRegister =
$this->api->CardRegistrations->Get($dbOrder->order_payment_params->mangopay->cardRegisterId);
$cardRegister->RegistrationData = isset($_GET['data']) ?
'data=' . $_GET['data'] : 'errorCode=' .
$_GET['errorCode'];
$updatedCardRegister =
$this->api->CardRegistrations->Update($cardRegister);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(!isset($updatedCardRegister) || $updatedCardRegister->Status !=
'VALIDATED' || !isset($updatedCardRegister->CardId))
die('Cannot create virtual card. Payment has not been
created.');
$card = false;
try {
$card =
$this->api->Cards->Get($updatedCardRegister->CardId);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($card))
die('An error occured, please contact the administrator in order to
have more details. (Card Get)');
$wallet = new MangoPay\Wallet();
$wallet->Owners = array( $updatedCardRegister->UserId );
$wallet->Currency = strtoupper($this->currency->currency_code);
$wallet->Description = $dbOrder->order_number;
$wallet->Tag = 'order#' . $dbOrder->order_id;
$createdWallet = false;
try {
$createdWallet = $this->api->Wallets->Create($wallet);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($createdWallet))
die('An error occured, please contact the administrator in order to
have more details. (Wallet Creation)');
$payIn = new MangoPay\PayIn();
$payIn->Tag = 'order#' . (int)$dbOrder->order_id;
$payIn->CreditedWalletId = $createdWallet->Id;
$payIn->AuthorId = $updatedCardRegister->UserId;
$payIn->DebitedFunds = new MangoPay\Money();
$payIn->DebitedFunds->Amount = round($dbOrder->order_full_price
* 100);
$payIn->DebitedFunds->Currency =
strtoupper($this->currency->currency_code);
$payIn->Fees = new MangoPay\Money();
$payIn->Fees->Amount = 0;
$payIn->Fees->Currency =
strtoupper($this->currency->currency_code);
$payIn->PaymentDetails = new MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardType = $card->CardType;
$payIn->ExecutionDetails = new
MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->CardId = $card->Id;
$payIn->ExecutionDetails->SecureModeReturnURL =
HIKASHOP_LIVE.'mangopay_'.$payment_id.'.php';
try {
$createdPayIn = $this->api->PayIns->Create($payIn);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
$update_order = new stdClass();
$update_order->order_id = (int)$dbOrder->order_id;
$update_order->order_number = $dbOrder->order_number;
$update_order->order_payment_params =
$dbOrder->order_payment_params;
$update_order->order_payment_params->mangopay->cardRegisterId =
null;
$update_order->order_payment_params->mangopay->payInId =
$createdPayIn->Id;
$update_order->order_payment_params->mangopay->walletId =
$createdWallet->Id;
$email = false;
$history = new stdClass();
$history->notified = 0;
$history->amount = $dbOrder->order_full_price;
$history->data = 'MangoPay Status:
'.$createdPayIn->Status;
if(isset($createdPayIn->SecureModeNeeded) &&
isset($createdPayIn->Status) &&
!empty($createdPayIn->ExecutionDetails->SecureModeNeeded) &&
$createdPayIn->Status != 'FAILED') {
$order_status = $this->payment_params->pending_status;
$redirect_url =
$createdPayIn->ExecutionDetails->SecureModeRedirectURL;
} if(isset($createdPayIn->Status) && $createdPayIn->Status
== 'SUCCEEDED') {
$history->notified = 1;
$email = true;
$order_status = $this->payment_params->verified_status;
$redirect_url = $confirm_url;
} else {
$order_status = $this->payment_params->invalid_status;
$email = true;
$redirect_url = $cancel_url;
}
if($this->payment_params->debug) {
$dbg = 'MangoPay - PayIn' . "\r\n".
'<pre>'.print_r($createdPayIn,
true).'</pre>';
$this->writeToLog($dbg);
}
$this->modifyOrder($update_order, $order_status, $history, true);
$orderClass = hikashop_get('class.order');
$orderClass->save($update_order);
$this->app->redirect($redirect_url);
}
protected function paymentNotificationSecureReturn($transaction_id,
$order_id, &$statuses) {
$notif_id = (int)$_GET['notif_id'];
if($this->pluginParams($notif_id))
$this->payment_params =& $this->plugin_params;
$this->getAPI();
$payIn = null;
try {
$payIn = $this->api->PayIns->Get($transaction_id);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if($payIn === null) {
$this->writeToLog('Invalid payIn: ' . $transaction_id);
return false;
}
$tag_order_id = (int)str_replace('order#', '',
$payIn->Tag);
if($tag_order_id > 0 && $tag_order_id != $order_id) {
$this->writeToLog('Wrong payIn (' . $transaction_id
.') : '. $payIn->Tag);
return false;
} else if($tag_order_id == 0) {
}
$redirect_url = HIKASHOP_LIVE .
'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id='
. (int)$order_id;
if(isset($payIn->Status) && $payIn->Status ==
'SUCCEEDED') {
$dbOrder = $this->getOrder((int)$order_id);
$order_status = $this->payment_params->verified_status;
$history = new stdClass();
$history->notified = 1;
$history->data = 'MangoPay Secure Return:
'.$payIn->Status;
$this->modifyOrder($order_id, $order_status, $history, true);
$redirect_url = HIKASHOP_LIVE .
'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='
. $dbOrder->order_id;
} elseif(isset($payIn->Status) && $payIn->Status ==
'FAILED') {
$order_status = $this->payment_params->invalid_status;
$history = new stdClass();
$history->notified = 0;
$history->data = 'MangoPay Secure Return:
'.$payIn->Status;
$this->modifyOrder($order_id, $order_status, $history, true);
}
if(empty($this->app))
$this->app = JFactory::getApplication();
$this->app->redirect($redirect_url);
}
protected function payVendors(&$order) {
$db = JFactory::getDBO();
$suborders = array();
$vendors = array();
$order_id = (int)$order->order_id;
if(empty($order_id))
return false;
$order_payment_params = !empty($order->order_payment_params) ?
$order->order_payment_params : $order->old->order_payment_params;
if(is_string($order_payment_params))
$order_payment_params = unserialize($order_payment_params);
if(empty($order_payment_params->mangopay->walletId))
return false;
if(!$this->initMarket() || !$this->getAPI())
return false;
$this->currency = 0;
$currency_id = (isset($order->order_currency_id) ?
(int)$order->order_currency_id :
(int)$order->old->order_currency_id);
if(!empty($currency_id)) {
$currencyClass = hikashop_get('class.currency');
$currencies = null;
$currencies = $currencyClass->getCurrencies($currency_id,
$currencies);
$this->currency = $currencies[$currency_id];
}
$currency_code = strtolower($this->currency->currency_code);
$query = 'SELECT v.*, o.* FROM ' .
hikamarket::table('shop.order') . ' AS o '.
' LEFT JOIN ' . hikamarket::table('vendor') . '
AS v ON o.order_vendor_id = v.vendor_id '.
' WHERE o.order_parent_id = ' . $order_id;
$db->setQuery($query);
$suborders = $db->loadObjectList();
$suborders_id = array();
$transaction_vendors = array();
$userClass = hikamarket::get('shop.class.user');
$order_user_id = isset($order->order_user_id) ?
(int)$order->order_user_id : (int)$order->old->order_user_id;
$order->user = $userClass->get($order_user_id);
$mangoCustomerId = $order->user->user_params->mangopay_id;
$full_price = isset($order->order_full_price) ?
$order->order_full_price : $order->old->order_full_price;
if(!empty($suborders)) {
$vendors = array();
$total = 0.0;
foreach($suborders as $k => $suborder) {
$price = round(hikamarket::toFloat($suborder->order_vendor_price),
(int)$this->currency->currency_locale['int_frac_digits']);
if($price < 0)
$price = round(hikamarket::toFloat($suborder->order_vendor_price) +
hikamarket::toFloat($full_price),
(int)$this->currency->currency_locale['int_frac_digits']);
if($price == 0)
continue;
$total += (float)hikamarket::toFloat($suborder->order_full_price);
$suborders_id[] = (int)$suborder->order_id;
$transaction_vendors[ (int)$suborder->order_vendor_id ] =
(int)$suborder->order_vendor_id;
$mango_id = null;
$wallets = null;
if(!empty($suborder->vendor_params))
$suborder->vendor_params =
unserialize($suborder->vendor_params);
if(!empty($suborder->vendor_params->mangopay_id))
$mango_id = (int)$suborder->vendor_params->mangopay_id;
if(!empty($suborder->vendor_params->mangopay_wallets))
$wallets = $suborder->vendor_params->mangopay_wallets;
if(empty($mango_id)) {
$mango_user = $this->createVendor($suborder);
$mango_id = $mango_user->Id;
$suborder->vendor_params->mangopay_id = (int)$mango_id;
}
if(empty($wallets) || empty($wallets[$currency_code])) {
if(empty($wallets))
$wallets = array();
$wallets[$currency_code] = $this->getVendorWallet($suborder,
$currency_code);
}
$vendors[ (int)$suborder->order_vendor_id ] = array(
'price' => $price,
'full_price' =>
(float)hikamarket::toFloat($suborder->order_full_price),
'mango_id' => (int)$mango_id,
'wallet' => (int)$wallets[$currency_code],
);
}
foreach($vendors as $k => $v) {
$this->transfert(
$mangoCustomerId, // $v['mango_id']
$order_payment_params->mangopay->walletId,
$v['wallet'],
$v['full_price'],
$v['full_price'] - $v['price'],
$currency_code
);
}
$order_full_price = (float)hikamarket::toFloat($full_price);
if($order_full_price - $total > 0) {
$vendorClass = hikamarket::get('class.vendor');
$mainVendor = $vendorClass->get(1);
$mainVendorWallet = $this->getVendorWallet($mainVendor);
$this->transfert(
$mangoCustomerId, // $mainVendor->vendor_params->mangopay_id,
$order_payment_params->mangopay->walletId,
$mainVendorWallet,
(float)($order_full_price - $total),
0,
$currency_code
);
}
} else {
$vendorClass = hikamarket::get('class.vendor');
$mainVendor = $vendorClass->get(1);
$mainVendorWallet = $this->getVendorWallet($mainVendor);
$this->transfert(
$mangoCustomerId, // $mainVendor->vendor_params->mangopay_id,
$order_payment_params->mangopay->walletId,
$mainVendorWallet,
(float)hikamarket::toFloat($full_price),
0,
$currency_code
);
}
$new_order_payment_params = hikamarket::cloning($order_payment_params);
unset($new_order_payment_params->mangopay->walletId);
$new_order_payment_params->mangopay->paid = true;
$query = 'UPDATE ' . hikashop_table('order') .
' SET order_payment_params = ' .
$db->Quote(serialize($new_order_payment_params)) .
' WHERE order_id = ' . (int)$order->order_id;
$db->setQuery($query);
$db->execute();
if(!empty($transaction_vendors)) {
$query = 'UPDATE
'.hikamarket::table('order_transaction').
' SET order_transaction_paid = order_id '.
' WHERE order_id = '.(int)$order->order_id.' AND
vendor_id IN ('.implode(',',
$transaction_vendors).')';
$db->setQuery($query);
$db->execute();
}
}
protected function getUser(&$order, $update = true) {
if(!$this->getAPI())
return false;
if(empty($order->user)) {
if(empty($this->user)) {
hikashop_loadUser(true, true);
$this->user = hikashop_loadUser(true);
}
$order->user = $this->user;
}
if(empty($order->user->user_params->mangopay_id))
return $this->createUser($order);
$mangoUser_id = (int)$order->user->user_params->mangopay_id;
$mangoUser = null;
try {
$mangoUser = $this->api->Users->Get($mangoUser_id);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($mangoUser))
return $this->createUser($order);
if($update) {
$billing_address = $order->cart->billing_address;
$mangoUser->FirstName =
substr($billing_address->address_firstname, 0, 99);
$mangoUser->LastName = substr($billing_address->address_lastname,
0, 99);
$mangoUser->Email = $order->user->user_email;
$mangoUser->Address = substr($billing_address->address_street .
' ' . $billing_address->address_city, 0, 254);
$mangoUser->CountryOfResidence =
$billing_address->address_country->zone_code_2;
try {
$this->api->Users->Update($mangoUser);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
}
return $mangoUser;
}
protected function createUser(&$order) {
if(!$this->getAPI())
return false;
$billing_address = $order->cart->billing_address;
$user = new MangoPay\UserNatural();
$user->FirstName = substr($billing_address->address_firstname, 0,
99);
$user->LastName = substr($billing_address->address_lastname, 0,
99);
$user->Email = $order->user->user_email;
$user->Address = substr($billing_address->address_street . '
' . $billing_address->address_city, 0, 254);
$user->CountryOfResidence =
$billing_address->address_country->zone_code_2;
$user->tag = 'hkId:' . (!empty($order->order_user_id) ?
$order->order_user_id : @$order->user->user_id);
$user->Nationality =
$billing_address->address_country->zone_code_2;
$user->Birthday = time();
$mangoUser = null;
try {
$mangoUser = $this->api->Users->Create($user);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(!empty($mangoUser->Id)) {
$hkUser = new stdClass();
$hkUser->user_params = new stdClass();
if(!empty($order->user->user_params) &&
is_object($order->user->user_params))
$hkUser->user_params = $order->user->user_params;
if(isset($order->user) &&
isset($order->user->user_params) &&
is_object($order->user->user_params))
$order->user->user_params->mangopay_id = $mangoUser->Id;
if(isset($this->user) &&
isset($this->user->user_params) &&
is_object($this->user->user_params))
$this->user->user_params->mangopay_id = $mangoUser->Id;
$hkUser->user_id = $order->user->user_id;
$hkUser->user_params->mangopay_id = $mangoUser->Id;
$userClass = hikashop_get('class.user');
$userClass->save($hkUser);
}
return $mangoUser;
}
public function getUserCards(&$user) {
if(!empty($user->user_params) &&
is_string($user->user_params))
$user->user_params = unserialize($user->user_params);
if(empty($user->user_params->mangopay_id))
return false;
if(empty($this->api))
$this->getAPI();
$cards = array();
try {
$cards =
$this->api->Users->getCards($user->user_params->mangopay_id);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
return $cards;
}
public function getVendor(&$vendor, $update = false) {
if(empty($vendor->vendor_params->mangopay_id))
return $this->createVendor($vendor);
if(empty($this->api))
$this->getAPI();
$mangoUser_id = (int)$vendor->vendor_params->mangopay_id;
$mangoUser = null;
try {
$mangoUser = $this->api->Users->Get($mangoUser_id);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($mangoUser))
return $this->createVendor($vendor);
return $mangoUser;
}
protected function createVendor(&$vendor) {
if(empty($this->api))
$this->getAPI();
$user = new MangoPay\UserLegal();
$user->Name = $vendor->vendor_name;
$user->LegalPersonType = 'BUSINESS';
$user->Email = $vendor->vendor_email;
$user->HeadquartersAddress = substr($vendor->vendor_address_street
. ' ' . $vendor->vendor_address_city, 0, 254);
$user->tag = 'hkVendorId:'.$vendor->vendor_id;
$billing_address = null;
$app = JFactory::getApplication();
if(!empty($vendor->vendor_admin_id) &&
(int)$vendor->vendor_admin_id > 0) {
$addressClass = hikamarket::get('shop.class.address');
$addresses =
$addressClass->loadUserAddresses((int)$vendor->vendor_admin_id);
$billing_address = reset($addresses);
} else if($app->isAdmin() && $vendor->vendor_id == 1) {
$addressClass = hikamarket::get('shop.class.address');
$current_user_id = hikashop_loadUser();
$addresses = $addressClass->loadUserAddresses($current_user_id);
$billing_address = reset($addresses);
}
$user->LegalRepresentativeFirstName =
substr(@$billing_address->address_firstname, 0, 99);
$user->LegalRepresentativeLastName =
substr(@$billing_address->address_lastname, 0, 99);
$user->LegalRepresentativeAdress =
substr(trim(@$billing_address->address_street . ' ' .
@$billing_address->address_city), 0, 254);
$user->LegalRepresentativeCountryOfResidence =
@$billing_address->address_country->zone_code_2;
$user->LegalRepresentativeNationality =
@$billing_address->address_country->zone_code_2;
$user->LegalRepresentativeBirthday = time();
if(empty($user->Email)) {
$shopConfig = hikamarket::config(false);
$user->Email = $shopConfig->get('from_email');
}
if(empty($user->LegalRepresentativeNationality))
$user->LegalRepresentativeNationality = 'US';
if(empty($user->LegalRepresentativeCountryOfResidence))
$user->LegalRepresentativeCountryOfResidence = 'US';
$mangoUser = null;
try {
$mangoUser = $this->api->Users->Create($user);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(!empty($mangoUser->Id)) {
$hkVendor = new stdClass();
$hkVendor->vendor_params = new stdClass();
if(!empty($vendor->vendor_params) &&
is_object($vendor->vendor_params))
$hkVendor->vendor_params = $vendor->vendor_params;
$hkVendor->vendor_id = (int)$vendor->vendor_id;
$hkVendor->vendor_params->mangopay_id = $mangoUser->Id;
$vendorClass = hikamarket::get('class.vendor');
$vendorClass->save($hkVendor);
}
return $mangoUser;
}
public function getVendorWallet(&$vendor, $currency = null, $full =
false) {
if(!empty($vendor->vendor_params) &&
is_string($vendor->vendor_params))
$vendor->vendor_params = unserialize($vendor->vendor_params);
if(empty($vendor->vendor_params->mangopay_id)) {
$mango_user = $this->createVendor($vendor);
$vendor->vendor_params->mangopay_id = (int)$mango_user->Id;
}
if(empty($currency)) {
$currencyClass = hikamarket::get('shop.class.currency');
if(!empty($vendor->vendor_params->vendor_currency_id)) {
$vendor_currency =
$currencyClass->get($vendor->vendor_params->vendor_currency_id);
if(!empty($vendor_currency))
$currency = strtolower($vendor_currency->currency_code);
}
if(empty($currency)) {
$shopConfig = hikamarket::config(false);
$main_currency_id = $shopConfig->get('main_currency', 1);
$main_currency = $currencyClass->get($main_currency_id);
$currency = strtolower($main_currency->currency_code);
}
}
if(!empty($vendor->vendor_params->mangopay_wallets[$currency]))
return $vendor->vendor_params->mangopay_wallets[$currency];
if(empty($this->api))
$this->getAPI();
$wallet_id = null;
$retWallet = null;
$userWallets = null;
try {
$userWallets = $this->api->Users->GetWallets(
(int)$vendor->vendor_params->mangopay_id );
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(!empty($userWallets)) {
foreach($userWallets as $userWallet) {
if(strtoupper($userWallet->Currency) == strtoupper($currency)) {
$wallet_id = $userWallet->Id;
$retWallet = $userWallet;
}
}
}
if(empty($wallet_id)) {
$wallet = new MangoPay\Wallet();
$wallet->Owners = array(
(int)$vendor->vendor_params->mangopay_id );
$wallet->Currency = strtoupper($currency);
$wallet->Description = $vendor->vendor_name;
$wallet->Tag = 'vendor#'.$vendor->vendor_id;
try {
$retWallet = $this->api->Wallets->Create($wallet);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($retWallet->Id))
return null;
$wallet_id = $retWallet->Id;
}
if(!empty($wallet_id)) {
$hkVendor = new stdClass();
$hkVendor->vendor_params = new stdClass();
if(!empty($vendor->vendor_params) &&
is_object($vendor->vendor_params))
$hkVendor->vendor_params = $vendor->vendor_params;
$hkVendor->vendor_id = (int)$vendor->vendor_id;
if(empty($hkVendor->vendor_params->mangopay_wallets))
$hkVendor->vendor_params->mangopay_wallets = array();
$hkVendor->vendor_params->mangopay_wallets[$currency] =
$wallet_id;
$vendorClass = hikamarket::get('class.vendor');
$vendorClass->save($hkVendor);
}
if($full)
return $retWallet;
return $wallet_id;
}
public function getVendorWallets(&$vendor) {
if(!empty($vendor->vendor_params) &&
is_string($vendor->vendor_params))
$vendor->vendor_params = unserialize($vendor->vendor_params);
if(empty($vendor->vendor_params->mangopay_id)) {
$mango_user = $this->createVendor($vendor);
$vendor->vendor_params->mangopay_id = (int)$mango_user->Id;
}
if(empty($vendor->vendor_params->mangopay_wallets))
return array();
if(empty($this->api))
$this->getAPI();
$wallets = array();
foreach($vendor->vendor_params->mangopay_wallets as $currency =>
$wallet_id) {
try {
$wallet = $this->api->Wallets->Get( (int)$wallet_id );
if(in_array($vendor->vendor_params->mangopay_id,
$wallet->Owners))
$wallets[$currency] = $wallet;
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
}
return $wallets;
}
public function transfert($author, $src_wallet, $dst_wallet, $full_price,
$fee, $currency_code) {
if(empty($author))
return false;
$currency_code = strtoupper($currency_code);
$transfer = new MangoPay\Transfer();
$transfer->AuthorId = $author;
$transfer->DebitedFunds = new MangoPay\Money();
$transfer->DebitedFunds->Currency = $currency_code;
$transfer->DebitedFunds->Amount = $full_price * 100;
$transfer->Fees = new MangoPay\Money();
$transfer->Fees->Currency = $currency_code;
$transfer->Fees->Amount = $fee * 100;
$transfer->DebitedWalletID = $src_wallet;
$transfer->CreditedWalletId = $dst_wallet;
try {
$result = $this->api->Transfers->Create($transfer);
}
catch (MangoPay\ResponseException $e) { $this->mangoDebug($e, true);
}
catch (MangoPay\Exception $e) { $this->mangoDebug($e, false); }
catch (Exception $e) {}
if(empty($result) || empty($result->Id))
return false;
return $result->Id;
}
public function getCountryList() {
return array(
'AD','AE','AF','AG','AI','AL','AM','AO','AQ','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO',
'BQ','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ',
'DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP',
'GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG',
'KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML',
'MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE',
'PF','PG','PH','PK','PL','PM','PN','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL',
'SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UM',
'US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','ZA','ZM','ZW'
);
}
public function mangoDebug($e, $r = false) {
ob_start();
if($r) {
MangoPay\Logs::Debug('MangoPay\ResponseException Code',
$e->GetCode());
MangoPay\Logs::Debug('Message', $e->GetMessage());
MangoPay\Logs::Debug('Details', $e->GetErrorDetails());
} else {
MangoPay\Logs::Debug('MangoPay\Exception Message',
$e->GetMessage());
}
$dbg = ob_get_clean();
$this->writeToLog($dbg);
return;
}
public function onHikashopCronTrigger(&$messages) {
if(!$this->cronCheck())
return;
$this->checkOrderStatuses($messages);
}
public function onPaymentConfiguration(&$element) {
parent::onPaymentConfiguration($element);
if(version_compare(PHP_VERSION, '5.3', '<')) {
$app = JFactory::getApplication();
$app->enqueueMessage('To work correctly, MangoPay API requires
PHP 5.3 or higher', 'error');
}
}
public function getPaymentDefaultValues(&$element) {
$element->payment_name = 'MangoPay';
$element->payment_description = '';
$element->payment_images = 'MasterCard,VISA,Credit_card';
$element->payment_params->clientid = '';
$element->payment_params->clientpassword = '';
$element->payment_params->invalid_status = 'cancelled';
$element->payment_params->pending_status = 'created';
$element->payment_params->verified_status = 'confirmed';
}
public function onPaymentConfigurationSave(&$element) {
$ret = parent::onPaymentConfigurationSave($element);
jimport('joomla.filesystem.file');
$lang = JFactory::getLanguage();
$locale = strtolower(substr($lang->get('tag'), 0, 2));
$opts = array(
'option' => 'com_hikashop',
'tmpl' => 'component',
'ctrl' => 'checkout',
'task' => 'notify',
'notif_payment' => $this->name,
'format' => 'html',
'local' => $locale,
'notif_id' => $element->payment_id,
);
$content = '<?php' . "\r\n";
foreach($opts as $k => $v) {
$v = str_replace(array('\'','\\'),
'', $v);
$content .=
'$_GET[\''.$k.'\']=\''.$v.'\';'."\r\n".
'$_REQUEST[\''.$k.'\']=\''.$v.'\';'."\r\n";
}
$content .=
'include(\'index.php\');'."\r\n";
JFile::write(JPATH_ROOT.DS.$this->name.'_'.$element->payment_id.'.php',
$content);
$app = JFactory::getApplication();
if(!$this->initMarket()) {
$app->enqueueMessage('HikaMarket is not present in your website
; you need HikaMarket to use the MangoPay plugin',
'error');
} else {
$api = $this->getAPI();
$vendorClass = hikamarket::get('class.vendor');
$vendor = $vendorClass->get(1);
$already_exist = !empty($vendor->vendor_params->mangopay_id);
$main_vendor = $this->GetVendor($vendor);
if(empty($main_vendor)) {
$app->enqueueMessage('Failed to get/create the legal user for
your main vendor.<br/>Please check that you right set your MangoPay
credentials in the plugin (Joomla site)<br/>Please also check that
your account have a valid published address', 'error');
} else if(!$already_exist) {
$app->enqueueMessage('We create a MangoPay legal user for your
main vendor ; you should finish the configuration of that user in the
HikaMarket front-end interface', 'message');
}
}
return $ret;
}
}
mangopay.xml000064400000004710151161154440007105 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5"
method="upgrade" group="hikashoppayment">
<name>Hikashop (market) MangoPay Payment Plugin</name>
<hikainstall ordering="0" 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 enables you to setup your MangoPay payment
system</description>
<files>
<filename
plugin="mangopay">mangopay.php</filename>
<filename>mangopay_checkout.php</filename>
<filename>mangopay_end.php</filename>
<folder>mangolib</folder>
</files>
<params addpath="/components/com_hikamarket/params">
<param name="clientid" type="text"
default="" label="Client Id"
description=""/>
<param name="clientpassword" type="text"
default="" label="Client Password"
description=""/>
<param name="sandbox" type="radio"
default="0" label="Sandbox"
description=""><option
value="0">No</option><option
value="1">Yes</option></param>
<param name="payout_waiting_duration" type="text"
default="31" label="Payout waiting duration"
description="Number of day to wait before payout a
transaction"/>
<param name="order_status" type="text"
default="" label="Order statuses for wallet transfer"
description="If the field is empty, it will use the value of the
HikaShop option: Invoice order statuses"/>
</params>
<config>
<fields name="params"
addfieldpath="/components/com_hikamarket/fields">
<fieldset name="basic">
<field name="clientid" type="text"
default="" label="Client Id"
description=""/>
<field name="clientpassword" type="text"
default="" label="Client Password"
description=""/>
<field name="sandbox" type="radio"
default="0" label="Sandbox"
description=""><option
value="0">No</option><option
value="1">Yes</option></field>
<field name="payout_waiting_duration"
type="text" default="31" label="Payout waiting
duration" description="Number of day to wait before payout a
transaction"/>
<field name="order_status" type="text"
default="" label="Order statuses for wallet transfer"
description="If the field is empty, it will use the value of the
HikaShop option: Invoice order statuses"/>
</fieldset>
</fields>
</config>
</extension>
mangopay_backend.php000064400000001236151161154440010543 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_class.php000064400000027272151161154440010271 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_ctrl.php000064400000012610151161154440010116 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);
}
}
media/index.html000064400000000054151161154440007621
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>media/mangopay.css000064400000000116151161154440010150
0ustar00/* MangoPay CSS */
.iconM-48-mangopay
{background-image:url(./mangopay.png);}media/mangopay.png000064400000007111151161154440010146
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�SF��٦;"�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`�views/index.html000064400000000054151161154440007677
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>views/mangopaymarket/index.html000064400000000054151161154440012716
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>views/mangopaymarket/tmpl/bank.php000064400000011656151161154440013333
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>
views/mangopaymarket/tmpl/document.php000064400000004062151161154440014227
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>
views/mangopaymarket/tmpl/index.html000064400000000054151161154440013672
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>views/mangopaymarket/tmpl/payout.php000064400000005077151161154440013741
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>
views/mangopaymarket/tmpl/show.php000064400000022460151161154440013373
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>
views/mangopaymarket/view.html.php000064400000013655151161154440013362
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;
}
}
js/index.html000064400000000054151162260700007154
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>js/mango-kit.min.js000064400000010460151162260700010167
0ustar00var
mangoPay={cardRegistration:{baseURL:"https://api.sandbox.mangopay.com",clientId:"",init:function(a){this._cardRegisterData=a},registerCard:function(a,b,c){if(!mangoPay.browser.corsSupport()){c({"ResultCode":"009999","ResultMessage":"Browser
does not support making cross-origin Ajax calls"});return}var
d=mangoPay.cardRegistration._validateCardData(a);if(d!==true){c(d);return};mangoPay.cardRegistration._tokenizeCard(a,mangoPay.cardRegistration._finishRegistration,b,c)},_validateCardData:function(a){var
b=mangoPay._validation._cardNumberValidator._validate(a.cardNumber);if(b!==true)return
b;var
c=mangoPay._validation._expirationDateValidator._validate(a.cardExpirationDate,new
Date());if(c!==true)return c;var
d=mangoPay._validation._cvvValidator._validate(a.cardCvx,a.cardType);if(d!==true)return
d;return
true},_tokenizeCard:function(c,d,e,f){mangoPay._networking._ajax({type:"post",url:this._cardRegisterData.cardRegistrationURL,crossDomain:true,data:{data:this._cardRegisterData.preregistrationData,accessKeyRef:this._cardRegisterData.accessKey,cardNumber:c.cardNumber,cardExpirationDate:c.cardExpirationDate,cardCvx:c.cardCvx},success:function(a){var
b="";if(a===null){f({"ResultCode":"001599","ResultMessage":"Token
processing
error"});return}b={Id:mangoPay.cardRegistration._cardRegisterData.Id,RegistrationData:a};d(b,e,f)},error:function(a){f({"ResultCode":"001599","ResultMessage":"Token
processing
error"});return}})},_finishRegistration:function(d,e,f){mangoPay._networking._ajax({type:"post",crossDomain:true,url:mangoPay.cardRegistration.baseURL+'/v2/'+mangoPay.cardRegistration.clientId+'/CardRegistrations/'+d.Id,data:d,success:function(a){try{a=JSON.parse(a)}catch(err){f({"ResultCode":"101699","ResultMessage":"CardRegistration
should return a valid JSON
response"});return}if(a.ResultCode==="000000"){e(a)}else{f(a)}},error:function(a){var
b="CardRegistration error";if(a.response){try{var
c=JSON.parse(a.response);if(c.Message){b=c.Message}}catch(err){}}f({"ResultCode":"101699","ResultMessage":b})}})}},_validation:{_cvvValidator:{_validate:function(a,b){a=a?a.trim():"";b=b?b.trim():"";if(mangoPay._validation._helpers._validateNumericOnly(a)===true){if(b==="AMEX"&&(a.length===3||a.length===4)){return
true}if(b==="CB_VISA_MASTERCARD"&&a.length===3){return
true}}return{"ResultCode":"105204","ResultMessage":"CVV_FORMAT_ERROR"}}},_expirationDateValidator:{_validate:function(a,b){a=a?a.trim():"";if(a.length===4){var
c=parseInt(a.substr(2,2))+2000;var
d=parseInt(a.substr(0,2));if(d>0&&d<=12){var
e=b.getFullYear();if(e<c)return true;if(e===c){var
f=b.getMonth()+1;if(f<=d)return
true}return{"ResultCode":"105203","ResultMessage":"PAST_EXPIRY_DATE_ERROR"}}}return{"ResultCode":"105203","ResultMessage":"EXPIRY_DATE_FORMAT_ERROR"}}},_cardNumberValidator:{_validate:function(a){a=a?a.trim():"";if(mangoPay._validation._helpers._validateNumericOnly(a)===false){return{"ResultCode":"105202","ResultMessage":"CARD_NUMBER_FORMAT_ERROR"}}if(this._validateCheckDigit(a)===false){return{"ResultCode":"105202","ResultMessage":"CARD_NUMBER_FORMAT_ERROR"}}return
true},_validateCheckDigit:function(a){var b=0;var c=0;var d=false;var
e=a.replace(/\D/g,"");for(var n=e.length-1;n>=0;n--){var
f=e.charAt(n),c=parseInt(f,10);if(d){if((c*=2)>9)c-=9}b+=c;d=!d}return(b%10)===0},},_helpers:{_validateNumericOnly:function(a){var
b=/^[0-9]+$/;if(a.match(b)){return true}return
false}}},_networking:{_ajax:function(a){var b=new XMLHttpRequest();var
c="";for(key in
a.data){c+=(c.length>0?'&':'')+key+"="+encodeURIComponent(a.data[key])}var
d=a.url;if(a.type==="get"){d=a.url+(a.url.indexOf("?")>-1?'&':'?')+c}if(a.crossDomain&&!("withCredentials"in
b)&&window.XDomainRequest){xdr=new
XDomainRequest();xdr.onerror=function(){a.error(xdr)};xdr.onload=function(){a.success(xdr.responseText)};xdr.open(a.type,d);xdr.send(a.type==="post"?c:null);return}b.onreadystatechange=function(){if(b.readyState==4){if(/^2[0-9][0-9]$/.test(b.status)){a.success(b.responseText)}else{a.error(b,b.status,b.statusText)}}};b.open(a.type,d,true);if(a.type==="post"){b.setRequestHeader("Content-type","application/x-www-form-urlencoded")}b.send(a.type==="post"?c:null)},},browser:{corsSupport:function(){if("withCredentials"in
new XMLHttpRequest()){return true}if(window.XDomainRequest){return
true}return
false}}};if(!String.prototype.trim){String.prototype.trim=function(){return
this.replace(/^\s+|\s+$/g,'')}}mangolib/common/common.inc000064400000002047151162260700011612
0ustar00<?php
/**
* Function to auto include files with entities and types
* @param String $className
*/
function mangoPay_Autoload($className){
$fileName = substr(strrchr($className, '\\'), 1);
// include entities files
if (mangoPay_AutoloadCheckAndInclude($fileName, 'entities'))
return;
// include types files
if (mangoPay_AutoloadCheckAndInclude($fileName, 'types'))
return;
// include tools files
if (mangoPay_AutoloadCheckAndInclude($fileName, 'tools'))
return;
// include exceptions files
if (mangoPay_AutoloadCheckAndInclude($fileName,
'types/exceptions'))
return;
}
function mangoPay_AutoloadCheckAndInclude($fileName, $module) {
$path = __DIR__ . '/../' . $module . '/' .
lcfirst($fileName) . '.inc';
if (file_exists($path)){
include_once $path;
return true;
}
return false;
}
// register auto load function
spl_autoload_register('mangoPay_Autoload');
// include file with enums
require_once __DIR__ . '/../tools/enums.inc';
mangolib/common/index.html000064400000000054151162260700011620
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/entities/bankAccount.inc000064400000002674151162260700013114
0ustar00<?php
namespace MangoPay;
/**
* Bank Account entity
*/
class BankAccount extends EntityBase {
/**
* User identifier
* @var LeetchiId
*/
public $UserId;
/**
* Type of bank account
* @var string
*/
public $Type;
/**
* Owner name
* @var string
*/
public $OwnerName;
/**
* Owner address
* @var string
*/
public $OwnerAddress;
/**
* One of BankAccountDetails implementations, depending on $Type
* @var object
*/
public $Details;
/**
* Get array with mapping which property depends on other property
* @return array
*/
public function GetDependsObjects() {
return array(
'Type' => array(
'_property_name' => 'Details',
'IBAN' =>
'\MangoPay\BankAccountDetailsIBAN',
'GB' =>
'\MangoPay\BankAccountDetailsGB',
'US' =>
'\MangoPay\BankAccountDetailsUS',
'CA' =>
'\MangoPay\BankAccountDetailsCA',
'OTHER' =>
'\MangoPay\BankAccountDetailsOTHER',
)
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'UserId' );
array_push( $properties, 'Type' );
return $properties;
}
}
mangolib/entities/card.inc000064400000001423151162260700011564
0ustar00<?php
namespace MangoPay;
/**
* Card entity
*/
class Card extends EntityBase {
/**
* Expiration date
* @var string
*/
public $ExpirationDate;
/**
* Alias
* @var string
*/
public $Alias;
/**
* Card type
* @var string
*/
public $CardType;
/**
* Product
* @var string
*/
public $Product ;
/**
* Bank code
* @var string
*/
public $BankCode;
/**
* Active
* @var bool
*/
public $Active;
/**
* Currency
* @var string
*/
public $Currency;
/**
* Validity
* @var \MangoPay\CardValidity
*/
public $Validity;
}mangolib/entities/cardPreAuthorization.inc000064400000006107151162260700015020
0ustar00<?php
namespace MangoPay;
/**
* Pre-authorization entity
*/
class CardPreAuthorization extends EntityBase {
/**
* The user Id of the author of the pre-authorization
* @var string
*/
public $AuthorId;
/**
* It represents the amount debited on the bank account
* of the Author.DebitedFunds = Fees + CreditedFunds
* (amount received on wallet)
* @var \MangoPay\Money
*/
public $DebitedFunds;
/**
* Status of the PreAuthorization: CREATED, SUCCEEDED, FAILED
* @var string
*/
public $Status;
/**
* The status of the payment after the PreAuthorization:
* WAITING, CANCELED, EXPIRED, VALIDATED
* @var string
*/
public $PaymentStatus;
/**
* The PreAuthorization result code
* @var string
*/
public $ResultCode;
/**
* The PreAuthorization result Message explaining the result code
* @var string
*/
public $ResultMessage;
/**
* How the PreAuthorization has been executed.
* Only on value for now: CARD
* @var string
*/
public $ExecutionType;
/**
* The SecureMode correspond to '3D secure' for CB Visa and
MasterCard
* or 'Amex Safe Key' for American Express.
* This field lets you activate it manually.
* @var string
*/
public $SecureMode;
/**
* The ID of the registered card (Got through CardRegistration object)
* @var string
*/
public $CardId;
/**
* Boolean. The value is 'true' if the SecureMode was used
* @var string
*/
public $SecureModeNeeded;
/**
* This is the URL where to redirect users to proceed
* to 3D secure validation
* @var string
*/
public $SecureModeRedirectURL;
/**
* This is the URL where users are automatically redirected
* after 3D secure validation (if activated)
* @var string
*/
public $SecureModeReturnURL;
/**
* The date when the payment is processed
* @var Timestamp
*/
public $ExpirationDate;
/**
* The date when the payment was authorized
* @var Timestamp
*/
public $AuthorizationDate;
/**
* The type of pre-authorization ("CARD" is the only
acceptable value at present
* @var string
*/
public $PaymentType;
/**
* The Id of the associated PayIn
* @var string
*/
public $PayInId;
/**
* Get array with mapping which property is object and what type of
object
* @return array
*/
public function GetSubObjects() {
return array(
'DebitedFunds' => '\MangoPay\Money'
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'Status' );
array_push( $properties, 'ResultCode' );
array_push( $properties, 'ResultMessage' );
return $properties;
}
}
mangolib/entities/cardRegistration.inc000064400000003251151162260700014160
0ustar00<?php
namespace MangoPay;
/**
* CardRegistration entity
*/
class CardRegistration extends EntityBase {
/**
* User Id
* @var string
*/
public $UserId;
/**
* Access key
* @var string
*/
public $AccessKey;
/**
* Preregistration data
* @var string
*/
public $PreregistrationData;
/**
* Card registration URL
* @var string
*/
public $CardRegistrationURL;
/**
* Card Id
* @var string
*/
public $CardId;
/**
* Card registration data
* @var string
*/
public $RegistrationData;
/**
* The result code of the object
* @var string
*/
public $ResultCode;
/**
* The message explaning the result code
* @var string
*/
public $ResultMessage;
/**
* Currency
* @var string
*/
public $Currency;
/**
* Status
* @var string
*/
public $Status;
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'AccessKey' );
array_push( $properties, 'PreregistrationData' );
array_push( $properties, 'CardRegistrationURL' );
array_push( $properties, 'CardId' );
array_push( $properties, 'ResultCode' );
array_push( $properties, 'ResultMessage' );
array_push( $properties, 'Status' );
return $properties;
}
}mangolib/entities/client.inc000064400000000657151162260700012141
0ustar00<?php
namespace MangoPay;
/**
* Client entity
*/
class Client extends EntityBase {
/**
* Client identifier
* @var String
*/
public $ClientId;
/**
* Name of client
* @var String
*/
public $Name;
/**
* Email of client
* @var String
*/
public $Email;
/**
* Password for client
* @var String
*/
public $Passphrase;
}
mangolib/entities/entityBase.inc000064400000001346151162260700012766
0ustar00<?php
namespace MangoPay;
/**
* Abstract class with common properties
*/
abstract class EntityBase extends Dto {
/**
* @var Int Unique identifier
* (At this moment type is Integer - in the feature will be GUID)
*/
public $Id;
/**
* @var String Custom data
*/
public $Tag;
/**
* @var Time Date of creation
*/
public $CreationDate;
/**
* Construct
* @param type $id Entity identifier
*/
function __construct($id = null) {
$this->Id = $id;
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
return array( 'Id', 'CreationDate' );
}
}
mangolib/entities/event.inc000064400000000523151162260700011774
0ustar00<?php
namespace MangoPay;
/**
* Event entity
*/
class Event extends Dto {
/**
* Resource ID
* @var string
*/
public $ResourceId;
/**
* Event type
* @var \MangoPay\EventType
*/
public $EventType;
/**
* Date of event
* @var Date
*/
public $Date;
}
mangolib/entities/hook.inc000064400000000776151162260700011625
0ustar00<?php
namespace MangoPay;
/**
* Hooks and Notifications entity
*/
class Hook extends EntityBase {
/**
* This is the URL where your receive notification for each EventType
* @var string
*/
public $Url;
/**
* Status: ENABLED, DISABLED
* @var string
*/
public $Status;
/**
* Validity: VALID, INVALID
* @var string
*/
public $Validity;
/**
* EventType
* @var EventType
*/
public $EventType;
}mangolib/entities/index.html000064400000000054151162260700012154
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/entities/kycDocument.inc000064400000001125151162260700013137
0ustar00<?php
namespace MangoPay;
/**
* KYC document entity
*/
class KycDocument extends EntityBase {
/**
* Document type
* @var \MangoPay\KycDocumentType
*/
public $Type;
/**
* Document status
* @var \MangoPay\KycDocumentStatus
*/
public $Status;
/**
* Refused reason type
* @var type string
*/
public $RefusedReasonType;
/**
* Refused reason message
* @var type string
*/
public $RefusedReasonMessage;
/**
* User identifier
* @var type string
*/
public $UserId;
}mangolib/entities/kycPage.inc000064400000000267151162260700012243
0ustar00<?php
namespace MangoPay;
/**
* KYC page entity for Kyc document
*/
class KycPage extends Dto {
/**
* Image base64
* @var type string
*/
public $File;
}mangolib/entities/payIn.inc000064400000004045151162260700011736
0ustar00<?php
namespace MangoPay;
/**
* Pay-in entity
*/
class PayIn extends Transaction {
/**
* Credited wallet Id
* @var int
*/
public $CreditedWalletId;
/**
* PaymentType {CARD, BANK_WIRE, AUTOMATIC_DEBIT, DIRECT_DEBIT }
* @var string
*/
public $PaymentType;
/**
* One of PayInPaymentDetails implementations, depending on
$PaymentType
* @var object
*/
public $PaymentDetails;
/**
* ExecutionType { WEB, TOKEN, DIRECT, PREAUTHORIZED,
RECURRING_ORDER_EXECUTION }
* @var string
*/
public $ExecutionType;
/**
* One of PayInExecutionDetails implementations, depending on
$ExecutionType
* @var object
*/
public $ExecutionDetails;
/**
* Get array with mapping which property depends on other property
* @return array
*/
public function GetDependsObjects() {
return array(
'PaymentType' => array(
'_property_name' =>
'PaymentDetails',
'CARD' =>
'\MangoPay\PayInPaymentDetailsCard',
'PREAUTHORIZED' =>
'\MangoPay\PayInPaymentDetailsPreAuthorized',
'BANK_WIRE' =>
'\MangoPay\PayInPaymentDetailsBankWire',
'DIRECT_DEBIT' =>
'\MangoPay\PayInPaymentDetailsDirectDebit',
// ...and more in future...
),
'ExecutionType' => array(
'_property_name' =>
'ExecutionDetails',
'WEB' =>
'\MangoPay\PayInExecutionDetailsWeb',
'DIRECT' =>
'\MangoPay\PayInExecutionDetailsDirect',
// ...and more in future...
)
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'PaymentType' );
array_push( $properties, 'ExecutionType' );
return $properties;
}
}
mangolib/entities/payOut.inc000064400000002224151162260700012134
0ustar00<?php
namespace MangoPay;
/**
* PayOut entity
*/
class PayOut extends Transaction {
/**
* Debited wallet Id
* @var int
*/
public $DebitedWalletId;
/**
* PaymentType (BANK_WIRE, MERCHANT_EXPENSE, AMAZON_GIFTCARD)
* @var string
*/
public $PaymentType;
/**
* One of PayOutPaymentDetails implementations, depending on
$PaymentType
* @var object
*/
public $MeanOfPaymentDetails;
/**
* Get array with mapping which property depends on other property
* @return array
*/
public function GetDependsObjects() {
return array(
'PaymentType' => array(
'_property_name' =>
'MeanOfPaymentDetails',
'BANK_WIRE' =>
'\MangoPay\PayOutPaymentDetailsBankWire',
// ...and more in future...
)
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'PaymentType' );
return $properties;
}
}mangolib/entities/refund.inc000064400000000627151162260700012143
0ustar00<?php
namespace MangoPay;
/**
* Refund entity
*/
class Refund extends Transaction {
/**
* Initial transaction Id
* @var string
*/
public $InitialTransactionId;
/**
* Debited wallet Id
* @var string
*/
public $DebitedWalletId;
/**
* Credited wallet Id
* @var string
*/
public $CreditedWalletId;
}mangolib/entities/temporaryImmediatePayIn.inc000064400000000732151162260700015457
0ustar00<?php
namespace MangoPay;
/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have
any questions.
*
* Temporary immediate pay-in entity.
*/
class TemporaryImmediatePayIn extends Transaction {
/**
* Payment card Id
* @var string
*/
public $PaymentCardId;
/**
* Credited wallet Id
* @var string
*/
public $CreditedWalletId;
}mangolib/entities/temporaryPaymentCard.inc000064400000001377151162260700015035
0ustar00<?php
namespace MangoPay;
/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have
any questions.
*
* Temporary Payment Card entity.
*/
class TemporaryPaymentCard extends EntityBase {
/**
* User Id
* @var string
*/
public $UserId;
/**
* Culture
* @var string
*/
public $Culture;
/**
* Return URL
* @var string
*/
public $ReturnURL;
/**
* Template URL
* @var string
*/
public $TemplateURL;
/**
* Redirect URL
* @var string
*/
public $RedirectURL;
/**
* Alias
* @var string
*/
public $Alias;
}mangolib/entities/transaction.inc000064400000003632151162260700013204
0ustar00<?php
namespace MangoPay;
/**
* Transaction entity.
* Base class for: PayIn, PayOut, Transfer.
*/
class Transaction extends EntityBase {
/**
* Author Id
* @var int
*/
public $AuthorId;
/**
* Credited user Id
* @var int
*/
public $CreditedUserId;
/**
* Debited funds
* @var \MangoPay\Money
*/
public $DebitedFunds;
/**
* Credited funds
* @var \MangoPay\Money
*/
public $CreditedFunds;
/**
* Fees
* @var \MangoPay\Money
*/
public $Fees;
/**
* TransactionStatus {CREATED, SUCCEEDED, FAILED}
* @var string
*/
public $Status;
/**
* Result code
* @var string
*/
public $ResultCode;
/**
* The PreAuthorization result Message explaining the result code
* @var string
*/
public $ResultMessage;
/**
* Execution date;
* @var date
*/
public $ExecutionDate;
/**
* TransactionType {PAYIN, PAYOUT, TRANSFER}
* @var string
*/
public $Type;
/**
* TransactionNature { REGULAR, REFUND, REPUDIATION }
* @var string
*/
public $Nature;
/**
* Get array with mapping which property is object and what type of
object
* @return array
*/
public function GetSubObjects() {
return array(
'DebitedFunds' => '\MangoPay\Money' ,
'CreditedFunds' => '\MangoPay\Money' ,
'Fees' => '\MangoPay\Money'
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'Status' );
array_push( $properties, 'ResultCode' );
array_push( $properties, 'ExecutionDate' );
return $properties;
}
}
mangolib/entities/transfer.inc000064400000000426151162260700012501
0ustar00<?php
namespace MangoPay;
/**
* Transfer entity
*/
class Transfer extends Transaction {
/**
* Debited wallet Id
* @var int
*/
public $DebitedWalletId;
/**
* Credited wallet Id
* @var int
*/
public $CreditedWalletId;
}mangolib/entities/user.inc000064400000001335151162260700011633
0ustar00<?php
namespace MangoPay;
/**
* User entity
*/
abstract class User extends EntityBase {
/**
* Type of user
* @var String
*/
public $PersonType;
/**
* Email address
* @var String
*/
public $Email;
/**
* Construct
* @param string $personType String with type of person
*/
protected function SetPersonType($personType) {
$this->PersonType = $personType;
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'PersonType' );
return $properties;
}
}mangolib/entities/userLegal.inc000064400000003453151162260700012603
0ustar00<?php
namespace MangoPay;
/**
* UserLegal entity
*/
class UserLegal extends User {
/**
* Name of user
* @var String
*/
public $Name;
/**
* Type for legal user. Possible: ‘BUSINESS’, ’ORGANIZATION’
* @var String
*/
public $LegalPersonType;
/**
*
* @var String
*/
public $HeadquartersAddress;
/**
*
* @var String
*/
public $LegalRepresentativeFirstName;
/**
*
* @var String
*/
public $LegalRepresentativeLastName;
/**
*
* @var String
*/
public $LegalRepresentativeAddress;
/**
*
* @var String
*/
public $LegalRepresentativeEmail;
/**
*
* @var Unix timestamp
*/
public $LegalRepresentativeBirthday;
/**
*
* @var String
*/
public $LegalRepresentativeNationality;
/**
*
* @var String
*/
public $LegalRepresentativeCountryOfResidence;
/**
*
* @var String
*/
public $Statute;
/**
*
* @var String
*/
public $ProofOfRegistration;
/**
*
* @var String
*/
public $ShareholderDeclaration;
/**
* Construct
*/
function __construct($id = null) {
parent::__construct($id);
$this->SetPersonType(PersonType::Legal);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'Statute' );
array_push( $properties, 'ProofOfRegistration' );
array_push( $properties, 'ShareholderDeclaration' );
return $properties;
}
}mangolib/entities/userNatural.inc000064400000002666151162260700013172
0ustar00<?php
namespace MangoPay;
/**
* UserNatural entity
*/
class UserNatural extends User {
/**
* First name for user
* @var String
*/
public $FirstName;
/**
* Last name for user
* @var String
*/
public $LastName;
/**
* Address for user
* @var String
*/
public $Address;
/**
* Date of birth
* @var Unix timestamp
*/
public $Birthday;
/**
* User's country
* @var String
*/
public $Nationality;
/**
* Country of residence
* @var String
*/
public $CountryOfResidence;
/**
* User's occupation
* @var String
*/
public $Occupation;
/**
*
* @var Int
*/
public $IncomeRange;
/**
*
* @var String
*/
public $ProofOfIdentity;
/**
*
* @var String
*/
public $ProofOfAddress;
/**
* Construct
*/
function __construct($id = null) {
parent::__construct($id);
$this->SetPersonType(PersonType::Natural);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'ProofOfIdentity' );
array_push( $properties, 'ProofOfAddress' );
return $properties;
}
}mangolib/entities/wallet.inc000064400000001662151162260700012150
0ustar00<?php
namespace MangoPay;
/**
* Wallet entity
*/
class Wallet extends EntityBase {
/**
* Array with owners identities
* @var array
*/
public $Owners;
/**
* Wallet description
* @var string
*/
public $Description;
/**
* Money in wallet
* @var Money
*/
public $Balance;
/**
* Currency code in ISO
* @var string
*/
public $Currency;
/**
* Get array with mapping which property is object and what type of
object
* @return array
*/
public function GetSubObjects() {
return array( 'Balance' => '\MangoPay\Money'
);
}
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'Balance' );
return $properties;
}
}
mangolib/index.html000064400000000054151162260700010330
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/mangoPayApi.inc000064400000006242151162260700011240
0ustar00<?php
namespace MangoPay;
require_once __DIR__ . '/common/common.inc';
/**
* MangoPay API main entry point.
* Provides managers to connect, send and read data from MangoPay API
* as well as holds configuration/authorization data.
*/
class MangoPayApi {
/////////////////////////////////////////////////
// Config/authorization related props
/////////////////////////////////////////////////
/**
* Authorization token methods
* @var \MangoPay\AuthorizationTokenManager
*/
public $OAuthTokenManager;
/**
* Configuration instance
* @var \MangoPay\Configuration
*/
public $Config;
/////////////////////////////////////////////////
// API managers props
/////////////////////////////////////////////////
/**
* OAuth methods
* @var ApiOAuth
*/
public $AuthenticationManager;
/**
* Clients methods
* @var Client
*/
public $Clients;
/**
* Users methods
* @var ApiUsers
*/
public $Users;
/**
* Wallets methods
* @var ApiWallets
*/
public $Wallets;
/**
* Transfers methods
* @var ApiTransfers
*/
public $Transfers;
/**
* Pay-in methods
* @var ApiPayIns
*/
public $PayIns;
/**
* Pay-out methods
* @var ApiPayOuts
*/
public $PayOuts;
/**
* Refund methods
* @var ApiRefunds
*/
public $Refunds;
/**
* Card registration methods
* @var ApiCardRegistrations
*/
public $CardRegistrations;
/**
* Pre-authorization methods
* @var ApiCardPreAuthorization
*/
public $CardPreAuthorizations;
/**
* Card methods
* @var ApiCards
*/
public $Cards;
/**
* Events methods
* @var ApiEvents
*/
public $Events;
/**
* Hooks methods
* @var ApiHooks
*/
public $Hooks;
/**
* Kyc documents list
* @var ApiKycDocuments
*/
public $KycDocuments;
/**
* Constructor
*/
function __construct() {
// default config setup
$this->Config = new Configuration();
$this->OAuthTokenManager = new
AuthorizationTokenManager($this);
// API managers
$this->AuthenticationManager = new ApiOAuth($this);
$this->Clients = new ApiClients($this);
$this->Users = new ApiUsers($this);
$this->Wallets = new ApiWallets($this);
$this->Transfers = new ApiTransfers($this);
$this->PayIns = new ApiPayIns($this);
$this->PayOuts = new ApiPayOuts($this);
$this->Refunds = new ApiRefunds($this);
$this->CardRegistrations = new ApiCardRegistrations($this);
$this->Cards = new ApiCards($this);
$this->Events = new ApiEvents($this);
$this->Hooks = new ApiHooks($this);
$this->CardPreAuthorizations = new
ApiCardPreAuthorizations($this);
$this->KycDocuments = new ApiKycDocuments($this);
}
}mangolib/tools/apiBase.inc000064400000037106151162260700011542
0ustar00<?php
namespace MangoPay;
/**
* Base class for MangoPay API managers
*/
abstract class ApiBase {
/**
* Root/parent instance that holds the OAuthToken and Configuration
instance
* @var \MangoPay\MangoPayApi
*/
protected $_root;
/**
* Array with REST url and request type
* @var array
*/
private $_methods = array(
'authentication_base' => array(
'/api/clients/', RequestType::POST ),
'authentication_oauth' => array( '/oauth/token
', RequestType::POST ),
'events_all' => array( '/events',
RequestType::GET ),
'hooks_create' => array( '/hooks',
RequestType::POST ),
'hooks_all' => array( '/hooks',
RequestType::GET ),
'hooks_get' => array( '/hooks/%s',
RequestType::GET ),
'hooks_save' => array( '/hooks/%s',
RequestType::PUT ),
'cardregistration_create' => array(
'/cardregistrations', RequestType::POST ),
'cardregistration_get' => array(
'/cardregistrations/%s', RequestType::GET ),
'cardregistration_save' => array(
'/cardregistrations/%s', RequestType::PUT ),
'preauthorization_create' => array(
'/preauthorizations/card/direct', RequestType::POST ),
'preauthorization_get' => array(
'/preauthorizations/%s', RequestType::GET ),
'preauthorization_save' => array(
'/preauthorizations/%s', RequestType::PUT ),
'card_get' => array( '/cards/%s',
RequestType::GET ),
'card_save' => array( '/cards/%s',
RequestType::PUT ),
// pay ins URLs
'payins_card-web_create' => array(
'/payins/card/web/', RequestType::POST ),
'payins_card-direct_create' => array(
'/payins/card/direct/', RequestType::POST ),
'payins_preauthorized-direct_create' => array(
'/payins/preauthorized/direct/', RequestType::POST ),
'payins_bankwire-direct_create' => array(
'/payins/bankwire/direct/', RequestType::POST ),
'payins_directdebit-web_create' => array(
'/payins/directdebit/web', RequestType::POST ),
'payins_get' => array( '/payins/%s',
RequestType::GET ),
'payins_getrefunds' => array(
'/payins/%s/refunds', RequestType::GET ),
'payins_createrefunds' => array(
'/payins/%s/refunds', RequestType::POST ),
'payouts_bankwire_create' => array(
'/payouts/bankwire/', RequestType::POST ),
'payouts_get' => array( '/payouts/%s',
RequestType::GET ),
'refunds_get' => array( '/refunds/%s',
RequestType::GET ),
'transfers_create' => array( '/transfers',
RequestType::POST ),
'transfers_get' => array( '/transfers/%s',
RequestType::GET ),
'transfers_getrefunds' => array(
'/transfers/%s/refunds', RequestType::GET ),
'transfers_createrefunds' => array(
'/transfers/%s/refunds', RequestType::POST ),
'users_createnaturals' => array(
'/users/natural', RequestType::POST ),
'users_createlegals' => array(
'/users/legal', RequestType::POST ),
'users_createbankaccounts_iban' => array(
'/users/%s/bankaccounts/iban', RequestType::POST ),
'users_createbankaccounts_gb' => array(
'/users/%s/bankaccounts/gb', RequestType::POST ),
'users_createbankaccounts_us' => array(
'/users/%s/bankaccounts/us', RequestType::POST ),
'users_createbankaccounts_ca' => array(
'/users/%s/bankaccounts/ca', RequestType::POST ),
'users_createbankaccounts_other' => array(
'/users/%s/bankaccounts/other', RequestType::POST ),
'users_all' => array( '/users',
RequestType::GET ),
'users_allwallets' => array(
'/users/%s/wallets', RequestType::GET ),
'users_allbankaccount' => array(
'/users/%s/bankaccounts', RequestType::GET ),
'users_allcards' => array(
'/users/%s/cards', RequestType::GET ),
'users_alltransactions' => array(
'/users/%s/transactions', RequestType::GET ),
'users_allkycdocuments' => array(
'/users/%s/KYC/documents', RequestType::GET ),
'users_get' => array( '/users/%s',
RequestType::GET ),
'users_getnaturals' => array(
'/users/natural/%s', RequestType::GET ),
'users_getlegals' => array(
'/users/legal/%s', RequestType::GET ),
'users_getbankaccount' => array(
'/users/%s/bankaccounts/%s', RequestType::GET ),
'users_savenaturals' => array(
'/users/natural/%s', RequestType::PUT ),
'users_savelegals' => array(
'/users/legal/%s', RequestType::PUT ),
'wallets_create' => array( '/wallets',
RequestType::POST ),
'wallets_alltransactions' => array(
'/wallets/%s/transactions', RequestType::GET ),
'wallets_get' => array( '/wallets/%s',
RequestType::GET ),
'wallets_save' => array( '/wallets/%s',
RequestType::PUT ),
'kyc_documents_create' => array(
'/users/%s/KYC/documents/', RequestType::POST ),
'kyc_documents_get' => array(
'/users/%s/KYC/documents/%s', RequestType::GET ),
'kyc_documents_save' => array(
'/users/%s/KYC/documents/%s', RequestType::PUT ),
'kyc_page_create' => array(
'/users/%s/KYC/documents/%s/pages', RequestType::POST ),
'kyc_documents_all' => array(
'/KYC/documents', RequestType::GET ),
// These are temporary functions and WILL be removed in the future.
// Please, contact with support before using these features or if
you have any questions.
'temp_paymentcards_create' => array(
'/temp/paymentcards', RequestType::POST ),
'temp_paymentcards_get' => array(
'/temp/paymentcards/%s', RequestType::GET ),
'temp_immediatepayins_create' => array(
'/temp/immediate-payins', RequestType::POST )
);
/**
* Constructor
* @param \MangoPay\MangoPayApi Root/parent instance that holds the
OAuthToken and Configuration instance
*/
function __construct($root) {
$this->_root = $root;
}
/**
* Get URL for REST Mango Pay API
* @param string $key Key with data
* @return string
*/
protected function GetRequestUrl($key){
return $this->_methods[$key][0];
}
/**
* Get request type for REST Mango Pay API
* @param string $key Key with data
* @return RequestType
*/
protected function GetRequestType($key){
return $this->_methods[$key][1];
}
/**
* Create object in API
* @param string $methodKey Key with request data
* @param object $entity Entity object
* @param object $responseClassName Name of entity class from response
* @param int $entityId Entity identifier
* @return object Response data
*/
protected function CreateObject($methodKey, $entity, $responseClassName
= null, $entityId = null, $subEntityId = null) {
if (is_null($entityId))
$urlMethod = $this->GetRequestUrl($methodKey);
elseif (is_null($subEntityId))
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$entityId);
else
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$entityId, $subEntityId);
$requestData = null;
if (!is_null($entity))
$requestData = $this->BuildRequestData($entity);
$rest = new RestTool(true, $this->_root);
$response = $rest->Request($urlMethod,
$this->GetRequestType($methodKey), $requestData);
if (!is_null($responseClassName))
return $this->CastResponseToEntity($response,
$responseClassName);
return $response;
}
/**
* Get entity object from API
* @param string $methodKey Key with request data
* @param int $entityId Entity identifier
* @param object $responseClassName Name of entity class from response
* @param int $secondEntityId Entity identifier for second entity
* @return object Response data
*/
protected function GetObject($methodKey, $entityId, $responseClassName
= null, $secondEntityId = null) {
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$entityId, $secondEntityId);
$rest = new RestTool(true, $this->_root);
$response = $rest->Request($urlMethod,
$this->GetRequestType($methodKey));
if (!is_null($responseClassName))
return $this->CastResponseToEntity($response,
$responseClassName);
return $response;
}
/**
* Get lst with entities object from API
* @param string $methodKey Key with request data
* @param \MangoPay\Pagination $pagination Pagination object
* @param object $responseClassName Name of entity class from response
* @param int $entityId Entity identifier
* @param object $filter Object to filter data
* @return object Response data
*/
protected function GetList($methodKey, & $pagination,
$responseClassName = null, $entityId = null, $filter = null, $sorting =
null) {
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$entityId);
if (is_null($pagination) || !is_object($pagination) ||
get_class($pagination) != 'MangoPay\Pagination') {
$pagination = new Pagination();
}
$rest = new RestTool(true, $this->_root);
$additionalUrlParams = array();
if (!is_null($filter))
$additionalUrlParams["filter"] = $filter;
if (!is_null($sorting)){
if (!is_a($sorting, "\MangoPay\Sorting"))
throw new Exception('Wrong type of sorting
object');
$additionalUrlParams["sort"] =
$sorting->GetSortParameter();
}
$response = $rest->Request($urlMethod,
$this->GetRequestType($methodKey), null, $pagination,
$additionalUrlParams);
if (!is_null($responseClassName))
return $this->CastResponseToEntity($response,
$responseClassName);
return $response;
}
/**
* Save object in API
* @param string $methodKey Key with request data
* @param object $entity Entity object to save
* @param object $responseClassName Name of entity class from response
* @return object Response data
*/
protected function SaveObject($methodKey, $entity, $responseClassName =
null, $secondEntityId = null) {
if (is_null($secondEntityId))
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$entity->Id);
else
$urlMethod = sprintf($this->GetRequestUrl($methodKey),
$secondEntityId, $entity->Id);
$requestData = $this->BuildRequestData($entity);
$rest = new RestTool(true, $this->_root);
$response = $rest->Request($urlMethod,
$this->GetRequestType($methodKey), $requestData);
if (!is_null($responseClassName))
return $this->CastResponseToEntity($response,
$responseClassName);
return $response;
}
/**
* Cast response object to entity object
* @param object $response Object from API response
* @param string $entityClassName Name of entity class to cast
* @return \MangoPay\$entityClassName Return entity object
*/
protected function CastResponseToEntity($response, $entityClassName,
$asDependentObject = false)
{
if (is_array($response)) {
$list = array();
foreach ($response as $responseObject) {
array_push($list,
$this->CastResponseToEntity($responseObject, $entityClassName));
}
return $list;
}
if (is_string($entityClassName)) {
$entity = new $entityClassName();
} else {
throw new Exception('Cannot cast response to entity
object. Wrong entity class name');
}
$responseReflection = new \ReflectionObject($response);
$entityReflection = new \ReflectionObject($entity);
$responseProperties = $responseReflection->getProperties();
$subObjects = $entity->GetSubObjects();
$dependsObjects = $entity->GetDependsObjects();
foreach ($responseProperties as $responseProperty) {
$responseProperty->setAccessible(true);
$name = $responseProperty->getName();
$value = $responseProperty->getValue($response);
if ($entityReflection->hasProperty($name)) {
$entityProperty =
$entityReflection->getProperty($name);
$entityProperty->setAccessible(true);
// is sub object?
if (isset($subObjects[$name])) {
if (is_null($value))
$object = null;
else
$object = $this->CastResponseToEntity($value,
$subObjects[$name]);
$entityProperty->setValue($entity, $object);
} else {
$entityProperty->setValue($entity, $value);
}
// has dependent object?
if (isset($dependsObjects[$name])) {
$dependsObject = $dependsObjects[$name];
$entityDependProperty =
$entityReflection->getProperty($dependsObject['_property_name']);
$entityDependProperty->setAccessible(true);
$entityDependProperty->setValue($entity,
$this->CastResponseToEntity($response, $dependsObject[$value], true));
}
} else {
if ($asDependentObject || !empty($dependsObjects)) {
continue;
}
else {
/* UNCOMMENT THE LINE BELOW TO ENABLE RESTRICTIVE REFLECTION MODE */
//throw new Exception('Cannot cast response to entity object.
Missing property ' . $name .' in entity ' .
$entityClassName);
continue;
}
}
}
return $entity;
}
/**
* Get array with request data
* @param object $entity Entity object to send as request data
* @return array
*/
protected function BuildRequestData($entity) {
$entityProperties = get_object_vars($entity);
$blackList = $entity->GetReadOnlyProperties();
$requestData = array();
foreach ($entityProperties as $propertyName => $propertyValue)
{
if (in_array($propertyName, $blackList))
continue;
if ($this->CanReadSubRequestData($entity, $propertyName)) {
$subRequestData =
$this->BuildRequestData($propertyValue);
foreach ($subRequestData as $key => $value) {
$requestData[$key] = $value;
}
} else {
if (isset($propertyValue))
$requestData[$propertyName] = $propertyValue;
}
}
return $requestData;
}
private function CanReadSubRequestData($entity, $propertyName) {
if (get_class($entity) == 'MangoPay\PayIn' &&
($propertyName == 'PaymentDetails' ||
$propertyName == 'ExecutionDetails')) {
return true;
}
if (get_class($entity) == 'MangoPay\PayOut' &&
$propertyName == 'MeanOfPaymentDetails') {
return true;
}
if (get_class($entity) == 'MangoPay\BankAccount'
&& $propertyName == 'Details' ) {
return true;
}
return false;
}
}mangolib/tools/apiCardPreAuthorizations.inc000064400000002551151162260700015150
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for pre-authorization process
*/
class ApiCardPreAuthorizations extends ApiBase {
/**
* Create new pre-authorization object
* @param \MangoPay\CardPreAuthorization $cardPreAuthorization
PreAuthorization object to create
* @return \MangoPay\CardPreAuthorization PreAuthorization object
returned from API
*/
public function Create($cardPreAuthorization) {
return $this->CreateObject('preauthorization_create',
$cardPreAuthorization, '\MangoPay\CardPreAuthorization');
}
/**
* Get pre-authorization object
* @param int $cardPreAuthorizationId PreAuthorization identifier
* @return \MangoPay\CardPreAuthorization Card registration object
returned from API
*/
public function Get($cardPreAuthorizationId) {
return $this->GetObject('preauthorization_get',
$cardPreAuthorizationId, '\MangoPay\CardPreAuthorization');
}
/**
* Update pre-authorization object
* @param \MangoPay\CardPreAuthorization $preAuthorization
PreAuthorization object to save
* @return \MangoPay\CardPreAuthorization PreAuthorization object
returned from API
*/
public function Update($cardPreAuthorization) {
return $this->SaveObject('preauthorization_save',
$cardPreAuthorization, '\MangoPay\CardPreAuthorization');
}
}mangolib/tools/apiCardRegistrations.inc000064400000002460151162260700014312
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for card registrations
*/
class ApiCardRegistrations extends ApiBase {
/**
* Create new card registration
* @param \MangoPay\CardRegistration $cardRegistration Card
registration object to create
* @return \MangoPay\CardRegistration Card registration object returned
from API
*/
public function Create($cardRegistration) {
return $this->CreateObject('cardregistration_create',
$cardRegistration, '\MangoPay\CardRegistration');
}
/**
* Get card registration
* @param int $cardRegistrationId Card Registration identifier
* @return \MangoPay\CardRegistration Card registration object
returned from API
*/
public function Get($cardRegistrationId) {
return $this->GetObject('cardregistration_get',
$cardRegistrationId, '\MangoPay\CardRegistration');
}
/**
* Update card registration
* @param \MangoPay\CardRegistration $cardRegistration Card
registration object to save
* @return \MangoPay\CardRegistration Card registration object returned
from API
*/
public function Update($cardRegistration) {
return $this->SaveObject('cardregistration_save',
$cardRegistration, '\MangoPay\CardRegistration');
}
}mangolib/tools/apiCards.inc000064400000003444151162260710011723
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for cards
*/
class ApiCards extends ApiBase {
/**
* Get card
* @param int $cardId Card identifier
* @return \MangoPay\Card object returned from API
*/
public function Get($cardId) {
return $this->GetObject('card_get', $cardId,
'\MangoPay\Card');
}
/**
* Update card
* @param \MangoPay\Card $card Card object to save
* @return \MangoPay\Card Card object returned from API
*/
public function Update($card) {
return $this->SaveObject('card_save', $card,
'\MangoPay\Card');
}
/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you
have any questions.
*
* Create new temporary payment card
* @param \MangoPay\TemporaryPaymentCard $paymentCard Payment card
object to create
* @return \MangoPay\TemporaryPaymentCard Card registration object
returned from API
*/
public function CreateTemporaryPaymentCard($paymentCard) {
return $this->CreateObject('temp_paymentcards_create',
$paymentCard, '\MangoPay\TemporaryPaymentCard');
}
/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you
have any questions.
*
* Get temporary payment card
* @param string $paymentCardId Card identifier
* @return \MangoPay\TemporaryPaymentCard object returned from API
*/
public function GetTemporaryPaymentCard($paymentCardId) {
return $this->GetObject('temp_paymentcards_get',
$paymentCardId, '\MangoPay\TemporaryPaymentCard');
}
}mangolib/tools/apiClients.inc000064400000001750151162260710012266
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for users
*/
class ApiClients extends ApiBase {
/**
* Get client data for Basic Access Authentication
* @param string $clientId Client identifier
* @param string $clientName Beautiful name for presentation
* @param string $clientEmail Client's email
* @return \MangoPay\Client Client object
*/
public function Create($clientId, $clientName, $clientEmail) {
$urlMethod =
$this->GetRequestUrl('authentication_base');
$requestType =
$this->GetRequestType('authentication_base');
$requestData = array(
'ClientId' => $clientId,
'Name' => $clientName,
'Email' => $clientEmail,
);
$rest = new RestTool(false, $this->_root);
$response = $rest->Request($urlMethod, $requestType,
$requestData);
return $this->CastResponseToEntity($response,
'\MangoPay\Client');
}
}mangolib/tools/apiEvents.inc000064400000000762151162260710012133
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for cards
*/
class ApiEvents extends ApiBase {
/**
* Get events
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterEvents $filter Object to filter data
* @return \MangoPay\Event[] Events list
*/
public function GetAll(& $pagination = null, $filter = null) {
return $this->GetList('events_all', $pagination,
'\MangoPay\Event', null, $filter);
}
}
mangolib/tools/apiHooks.inc000064400000002263151162260710011750
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for hooks and notifications
*/
class ApiHooks extends ApiBase {
/**
* Create new hook
* @param Hook $hook
* @return \MangoPay\Hook Hook object returned from API
*/
public function Create($hook) {
return $this->CreateObject('hooks_create', $hook,
'\MangoPay\Hook');
}
/**
* Get hook
* @param type $hookId Hook identifier
* @return \MangoPay\Hook Wallet object returned from API
*/
public function Get($hookId) {
return $this->GetObject('hooks_get', $hookId,
'\MangoPay\Hook');
}
/**
* Save hook
* @param type $hook Hook object to save
* @return \MangoPay\Hook Hook object returned from API
*/
public function Update($hook) {
return $this->SaveObject('hooks_save', $hook,
'\MangoPay\Hook');
}
/**
* Get all hooks
* @param \MangoPay\Pagination $pagination Pagination object
* @return \MangoPay\Hook[] Array with objects returned from API
*/
public function GetAll(& $pagination = null) {
return $this->GetList('hooks_all', $pagination,
'\MangoPay\Hook');
}
}mangolib/tools/apiKycDocuments.inc000064400000001077151162260710013277
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for KYC document list
*/
class ApiKycDocuments extends ApiBase {
/**
* Get all KYC documents
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return \MangoPay\KycDocument[] Array with objects returned from API
*/
public function GetAll(& $pagination = null, $sorting = null) {
return $this->GetList('kyc_documents_all',
$pagination, '\MangoPay\KycDocument', null, null, $sorting);
}
}mangolib/tools/apiOAuth.inc000064400000002173151162260710011705
0ustar00<?php
namespace MangoPay;
/**
* Authentication manager
*/
class ApiOAuth extends ApiBase {
/**
* Get token information to OAuth Authentication
* @return \MangoPay\OAuthToken OAuthToken object with token
information
*/
public function CreateToken() {
$urlMethod =
$this->GetRequestUrl('authentication_oauth');
$requestType =
$this->GetRequestType('authentication_oauth');
$requestData = array(
'grant_type' => 'client_credentials'
);
$rest = new RestTool(false, $this->_root);
$authHlp = new AuthenticationHelper($this->_root);
$urlDetails = parse_url($this->_root->Config->BaseUrl);
$rest->AddRequestHttpHeader('Host: ' .
@$urlDetails['host']);
$rest->AddRequestHttpHeader('Authorization: Basic ' .
$authHlp->GetHttpHeaderBasicKey());
$rest->AddRequestHttpHeader('Content-Type:
application/x-www-form-urlencoded');
$response = $rest->Request($urlMethod, $requestType,
$requestData);
return $this->CastResponseToEntity($response,
'\MangoPay\OAuthToken');
}
}mangolib/tools/apiPayIns.inc000064400000005666151162260710012102
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for pay-ins
*/
class ApiPayIns extends ApiBase {
/**
* Create new pay-in object
* @param \MangoPay\PayIn $payIn \MangoPay\PayIn object
* @return \MangoPay\PayIn Object returned from API
*/
public function Create($payIn) {
$paymentKey = $this->GetPaymentKey($payIn);
$executionKey = $this->GetExecutionKey($payIn);
return $this->CreateObject('payins_' . $paymentKey .
'-' . $executionKey . '_create', $payIn,
'\MangoPay\PayIn');
}
/**
* Get pay-in object
* @param $payInId Pay-in identifier
* @return \MangoPay\PayIn Object returned from API
*/
public function Get($payInId) {
return $this->GetObject('payins_get', $payInId,
'\MangoPay\PayIn');
}
/**
* Create refund for pay-in object
* @param type $payInId Pay-in identifier
* @param \MangoPay\Refund $refund Refund object to create
* @return \MangoPay\Refund Object returned by REST API
*/
public function CreateRefund($payInId, $refund) {
return $this->CreateObject('payins_createrefunds',
$refund, '\MangoPay\Refund', $payInId);
}
/**
* Get refund for pay-in object
* @param type $payInId Pay-in identifier
* @return \MangoPay\Refund Object returned by REST API
*/
public function GetRefund($payInId) {
return $this->GetObject('payins_getrefunds', $payInId,
'\MangoPay\Refund');
}
/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you
have any questions.
*
* Create new temporary immediate pay-in
* @param \MangoPay\TemporaryImmediatePayIn $immediatePayIn Immediate
pay-in object to create
* @return \MangoPay\TemporaryImmediatePayIn Immediate pay-in object
returned from API
*/
public function CreateTemporaryImmediatePayIn($immediatePayIn) {
return
$this->CreateObject('temp_immediatepayins_create',
$immediatePayIn, '\MangoPay\TemporaryImmediatePayIn');
}
private function GetPaymentKey($payIn) {
if (!isset($payIn->PaymentDetails) ||
!is_object($payIn->PaymentDetails))
throw new Exception ('Payment is not defined or it is not
object type');
$className = str_replace('MangoPay\\PayInPaymentDetails',
'', get_class($payIn->PaymentDetails));
return strtolower($className);
}
private function GetExecutionKey($payIn) {
if (!isset($payIn->ExecutionDetails) ||
!is_object($payIn->ExecutionDetails))
throw new Exception ('Execution is not defined or it is
not object type');
$className =
str_replace('MangoPay\\PayInExecutionDetails', '',
get_class($payIn->ExecutionDetails));
return strtolower($className);
}
}mangolib/tools/apiPayOuts.inc000064400000002161151162260710012266
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for pay-outs
*/
class ApiPayOuts extends ApiBase {
/**
* Create new pay-out
* @param PayOut $payOut
* @return \MangoPay\PayOut Object returned from API
*/
public function Create($payOut) {
$paymentKey = $this->GetPaymentKey($payOut);
return $this->CreateObject('payouts_' . $paymentKey .
'_create', $payOut, '\MangoPay\PayOut');
}
/**
* Get pay-out object
* @param $payOutId PayOut identifier
* @return \MangoPay\PayOut Object returned from API
*/
public function Get($payOutId) {
return $this->GetObject('payouts_get', $payOutId,
'\MangoPay\PayOut');
}
private function GetPaymentKey($payOut) {
if (!isset($payOut->MeanOfPaymentDetails) ||
!is_object($payOut->MeanOfPaymentDetails))
throw new Exception('Mean of payment is not defined or it
is not object type');
$className =
str_replace('MangoPay\\PayOutPaymentDetails', '',
get_class($payOut->MeanOfPaymentDetails));
return strtolower($className);
}
}mangolib/tools/apiRefunds.inc000064400000000627151162260710012275
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for refunds
*/
class ApiRefunds extends ApiBase {
/**
* Get refund object
* @param string $refundId Refund Id
* @return \MangoPay\Refund Refund object returned from API
*/
public function Get($refundId) {
return $this->GetObject('refunds_get', $refundId,
'\MangoPay\Refund');
}
}mangolib/tools/apiTransfers.inc000064400000002670151162260710012636
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for transfers
*/
class ApiTransfers extends ApiBase {
/**
* Create new transfer
* @param \MangoPay\Transfer $transfer
* @return \MangoPay\Transfer Transfer object returned from API
*/
public function Create($transfer) {
return $this->CreateObject('transfers_create',
$transfer, '\MangoPay\Transfer');
}
/**
* Get transfer
* @param type $transferId Transfer identifier
* @return \MangoPay\Transfer Transfer object returned from API
*/
public function Get($transfer) {
return $this->GetObject('transfers_get', $transfer,
'\MangoPay\Transfer');
}
/**
* Create refund for transfer object
* @param type $transferId Transfer identifier
* @param \MangoPay\Refund $refund Refund object to create
* @return \MangoPay\Refund Object returned by REST API
*/
public function CreateRefund($transferId, $refund) {
return $this->CreateObject('transfers_createrefunds',
$refund, '\MangoPay\Refund', $transferId);
}
/**
* Get refund for transfer object
* @param type $transferId Transfer identifier
* @return \MangoPay\Refund Object returned by REST API
*/
public function GetRefund($transferId) {
return $this->GetObject('transfers_getrefunds',
$transferId, '\MangoPay\Refund');
}
}
mangolib/tools/apiUsers.inc000064400000024164151162260710011772
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for users
*/
class ApiUsers extends ApiBase {
/**
* Create a new user
* @param UserLegal/UserNatural $user
* @return UserLegal/UserNatural User object returned from API
*/
public function Create($user) {
$className = get_class($user);
if ($className == 'MangoPay\UserNatural')
$methodKey = 'users_createnaturals';
elseif ($className == 'MangoPay\UserLegal')
$methodKey = 'users_createlegals';
else
throw new Exception('Wrong entity class for user');
$response = $this->CreateObject($methodKey, $user);
return $this->GetUserResponse($response);
}
/**
* Get all users
* @param \MangoPay\Pagination $pagination Pagination object
* @return array Array with users
*/
public function GetAll(& $pagination = null) {
$usersList = $this->GetList('users_all',
$pagination);
$users = array();
if (is_array($usersList)) {
foreach ($usersList as $user) {
array_push($users, $this->GetUserResponse($user));
}
}
return $users;
}
/**
* Get natural or legal user by ID
* @param Int/GUID $userId User identifier
* @return UserLegal/UserNatural User object returned from API
*/
public function Get($userId) {
$response = $this->GetObject('users_get', $userId);
return $this->GetUserResponse($response);
}
/**
* Get natural user by ID
* @param Int/GUID $userId User identifier
* @return UserLegal/UserNatural User object returned from API
*/
public function GetNatural($userId) {
$response = $this->GetObject('users_getnaturals',
$userId);
return $this->GetUserResponse($response);
}
/**
* Get legal user by ID
* @param Int/GUID $userId User identifier
* @return UserLegal/UserNatural User object returned from API
*/
public function GetLegal($userId) {
$response = $this->GetObject('users_getlegals',
$userId);
return $this->GetUserResponse($response);
}
/**
* Save user
* @param UserLegal/UserNatural $user
* @return UserLegal/UserNatural User object returned from API
*/
public function Update($user) {
$className = get_class($user);
if ($className == 'MangoPay\UserNatural')
$methodKey = 'users_savenaturals';
elseif ($className == 'MangoPay\UserLegal')
$methodKey = 'users_savelegals';
else
throw new Exception('Wrong entity class for user');
$response = $this->SaveObject($methodKey, $user);
return $this->GetUserResponse($response);
}
/**
* Create bank account for user
* @param int $userId User Id
* @param \MangoPay\BankAccount $bankAccount Entity of bank account
object
* @return \MangoPay\BankAccount Create bank account object
*/
public function CreateBankAccount($userId, $bankAccount) {
$type = $this->GetBankAccountType($bankAccount);
return $this->CreateObject('users_createbankaccounts_'
. $type, $bankAccount, '\MangoPay\BankAccount', $userId);
}
/**
* Get all bank accounts for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return array Array with bank account entities
*/
public function GetBankAccounts($userId, & $pagination = null,
$sorting = null) {
return $this->GetList('users_allbankaccount',
$pagination, 'MangoPay\BankAccount', $userId, null, $sorting);
}
/**
* Get bank account for user
* @param int $userId User Id
* @param int $bankAccountId Bank account Id
* @return \MangoPay\BankAccount Entity of bank account object
*/
public function GetBankAccount($userId, $bankAccountId) {
return $this->GetObject('users_getbankaccount',
$userId, 'MangoPay\BankAccount', $bankAccountId);
}
/**
* Get all wallets for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return \MangoPay\Wallet[] Array with objects returned from API
*/
public function GetWallets($userId, & $pagination = null, $sorting
= null) {
return $this->GetList('users_allwallets', $pagination,
'MangoPay\Wallet', $userId, null, $sorting);
}
/**
* Get all transactions for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Object to filter data
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return \MangoPay\Transaction[] Transactions for user returned from
API
*/
public function GetTransactions($userId, & $pagination = null,
$filter = null, $sorting = null) {
return $this->GetList('users_alltransactions',
$pagination, '\MangoPay\Transaction', $userId, $filter,
$sorting);
}
/**
* Get all cards for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return \MangoPay\Card[] Cards for user returned from API
*/
public function GetCards($userId, & $pagination = null, $sorting =
null) {
return $this->GetList('users_allcards', $pagination,
'\MangoPay\Card', $userId, null, $sorting);
}
/**
* Create new KYC document
* @param int $userId User Id
* @param \MangoPay\KycDocument $kycDocument
* @return \MangoPay\KycDocument Document returned from API
*/
public function CreateKycDocument($userId, $kycDocument) {
return $this->CreateObject('kyc_documents_create',
$kycDocument, '\MangoPay\KycDocument', $userId);
}
/**
* Get all KYC documents for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return array Array with KYC documents entities
*/
public function GetKycDocuments($userId, & $pagination = null,
$sorting = null) {
return $this->GetList('users_allkycdocuments',
$pagination, 'MangoPay\KycDocument', $userId, null, $sorting);
}
/**
* Get KYC document
* @param int $userId User Id
* @param string $kycDocumentId Document identifier
* @return \MangoPay\KycDocument Document returned from API
*/
public function GetKycDocument($userId, $kycDocumentId) {
return $this->GetObject('kyc_documents_get', $userId,
'\MangoPay\KycDocument', $kycDocumentId);
}
/**
* Save KYC document
* @param int $userId User Id
* @param \MangoPay\KycDocument $kycDocument Document to save
* @return \MangoPay\KycDocument Document returned from API
*/
public function UpdateKycDocument($userId, $kycDocument) {
return $this->SaveObject('kyc_documents_save',
$kycDocument, '\MangoPay\KycDocument', $userId);
}
/**
* Create page for Kyc document
* @param int $userId User Id
* @param \MangoPay\KycPage $page Kyc
*/
public function CreateKycPage($userId, $kycDocumentId, $kycPage) {
try{
$this->CreateObject('kyc_page_create', $kycPage,
null, $userId, $kycDocumentId);
} catch (\MangoPay\ResponseException $exc) {
if ($exc->getCode() != 204)
throw $exc;
}
}
/**
* Create page for Kyc document from file
* @param int $userId User Id
* @param \MangoPay\KycPage $page Kyc
*/
public function CreateKycPageFromFile($userId, $kycDocumentId, $file)
{
$filePath = $file;
if (is_array($file)) {
$filePath = $file['tmp_name'];
}
if (empty($filePath))
throw new \MangoPay\Exception('Path of file cannot be
empty');
if (!file_exists($filePath))
throw new \MangoPay\Exception('File not exist');
$kycPage = new \MangoPay\KycPage();
$kycPage->File = base64_encode(file_get_contents($filePath));
if (empty($kycPage->File))
throw new \MangoPay\Exception('Content of the file cannot
be empty');
$this->CreateKycPage($userId, $kycDocumentId, $kycPage);
}
/**
* Get correct user object
* @param object $response Response from API
* @return UserLegal/UserNatural User object returned from API
* @throws \MangoPay\Exception If occur unexpected response from API
*/
private function GetUserResponse($response) {
if (isset($response->PersonType)) {
switch ($response->PersonType) {
case PersonType::Natural:
return $this->CastResponseToEntity($response,
'\MangoPay\UserNatural');
case PersonType::Legal:
return $this->CastResponseToEntity($response,
'\MangoPay\UserLegal');
default:
throw new Exception('Unexpected response. Wrong
PersonType value');
}
} else {
throw new Exception('Unexpected response. Missing
PersonType property');
}
}
private function GetBankAccountType($bankAccount) {
if (!isset($bankAccount->Details) ||
!is_object($bankAccount->Details))
throw new Exception ('Details is not defined or it is not
object type');
$className = str_replace('MangoPay\\BankAccountDetails',
'', get_class($bankAccount->Details));
return strtolower($className);
}
}
mangolib/tools/apiWallets.inc000064400000003025151162260710012275
0ustar00<?php
namespace MangoPay;
/**
* Class to management MangoPay API for wallets
*/
class ApiWallets extends ApiBase {
/**
* Create new wallet
* @param Wallet $wallet
* @return \MangoPay\Wallet Wallet object returned from API
*/
public function Create($wallet) {
return $this->CreateObject('wallets_create', $wallet,
'\MangoPay\Wallet');
}
/**
* Get wallet
* @param int $walletId Wallet identifier
* @return \MangoPay\Wallet Wallet object returned from API
*/
public function Get($walletId) {
return $this->GetObject('wallets_get', $walletId,
'\MangoPay\Wallet');
}
/**
* Save wallet
* @param Wallet $wallet Wallet object to save
* @return \MangoPay\Wallet Wallet object returned from API
*/
public function Update($wallet) {
return $this->SaveObject('wallets_save', $wallet,
'\MangoPay\Wallet');
}
/**
* Get transactions for the wallet
* @param type $walletId Wallet identifier
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Object to filter data
* @param \MangoPay\Sorting $sorting Object to sorting data
* @return \MangoPay\Transaction[] Transactions for wallet returned
from API
*/
public function GetTransactions($walletId, & $pagination = null,
$filter = null, $sorting = null) {
return $this->GetList('wallets_alltransactions',
$pagination, '\MangoPay\Transaction', $walletId, $filter,
$sorting);
}
}
mangolib/tools/authenticationHelper.inc000064400000004754151162260710014361
0ustar00<?php
namespace MangoPay;
class AuthenticationHelper {
/**
* Root/parent instance that holds the OAuth token and Configuration
instance
* @var \MangoPay\MangoPayApi
*/
private $_root;
/**
* Constructor
* @param \MangoPay\MangoPayApi Root/parent instance that holds the
OAuth token and Configuration instance
*/
function __construct($root) {
$this->_root = $root;
}
/**
* Get HTTP header value with authorization string
* @return string Authorization string
*/
public function GetHttpHeaderKey(){
return $this->GetHttpHeaderStrong();
}
/**
* Get basic key for HTTP header
* @return string
* @throws \MangoPay\Exception If MangoPay_ClientId or
MangoPay_ClientPassword is not defined
*/
public function GetHttpHeaderBasicKey() {
if (is_null($this->_root->Config->ClientId) ||
strlen($this->_root->Config->ClientId) == 0)
throw new Exception ('MangoPayApi.Config.ClientId is not
set.');
if (is_null($this->_root->Config->ClientPassword) ||
strlen($this->_root->Config->ClientPassword) == 0)
throw new Exception ('MangoPayApi.Config.ClientPassword is
not set.');
$signature = $this->_root->Config->ClientId .
':' . $this->_root->Config->ClientPassword;
return base64_encode($signature);
}
/**
* Get HTTP header value with authorization string for basic
authentication
*
* @return string Value for HTTP header with authentication string
* @throws \MangoPay\Exception If required constants are not defined.
*/
private function GetHttpHeaderBasic() {
return 'Authorization: Basic ' .
$this->GetHttpHeaderBasicKey();
}
/**
* Get HTTP header value with authorization string for strong
authentication
*
* @return string Value for HTTP header with authentication string
* @throws \MangoPay\Exception If OAuth token is not created (or is
invalid) for strong authentication.
*/
private function GetHttpHeaderStrong() {
$token = $this->_root->OAuthTokenManager->GetToken();
if (is_null($token) || !isset($token->access_token) ||
!isset($token->token_type))
throw new Exception ('OAuth token is not created (or is
invalid) for strong authentication');
return 'Authorization: ' . $token->token_type . '
' . $token->access_token;
}
}mangolib/tools/authorizationTokenManager.inc000064400000003465151162260710015374
0ustar00<?php
namespace MangoPay;
/**
* Authorization token manager
*/
class AuthorizationTokenManager extends ApiBase {
/**
* Storage object
* @var \MangoPay\IStorageStrategy
*/
private $_storageStrategy;
function __construct($root) {
$this->_root = $root;
$this->RegisterCustomStorageStrategy(new
DefaultStorageStrategy($this->_root->Config));
}
/**
* Gets the current authorization token.
* In the very first call, this method creates a new token before
returning.
* If currently stored token is expired, this method creates a new
one.
* @return \MangoPay\OAuthToken Valid OAuthToken instance.
*/
public function GetToken() {
$token = $this->_storageStrategy->get();
if (is_null($token) || $token->IsExpired()) {
$this->storeToken($this->_root->AuthenticationManager->createToken());
}
return $this->_storageStrategy->get();
}
/**
* Stores authorization token passed as an argument in the underlying
* storage strategy implementation.
* @param \MangoPay\OAuthToken $token Token instance to be stored.
*/
public function StoreToken($token) {
$this->_storageStrategy->Store($token);
}
/**
* Registers custom storage strategy implementation.
* By default, the DefaultStorageStrategy instance is used.
* There is no need to explicitly call this method until some more
complex
* storage implementation is needed.
* @param \MangoPay\IStorageStrategy $customStorageStrategy
IStorageStrategy interface implementation.
*/
public function RegisterCustomStorageStrategy($customStorageStrategy)
{
$this->_storageStrategy = $customStorageStrategy;
}
}mangolib/tools/defaultStorageStrategy.inc000064400000004115151162260710014665
0ustar00<?php
namespace MangoPay;
/**
* Default storage strategy implementation.
*/
class DefaultStorageStrategy implements IStorageStrategy {
private $_prefixContent = '<?php exit(); ?>';
private $_fileName = 'MangoPaySdkStorage.tmp.php';
private $_config;
function __construct($config) {
$this->_config = $config;
}
/**
* Gets the current authorization token.
* @return \MangoPay\OAuthToken Currently stored token instance or
null.
*/
public function Get() {
$filename = $this->GetPathToFile();
if (!file_exists($filename))
return null;
$data = file_get_contents($filename);
if ($data === false)
return null;
$serialized = str_replace($this->_prefixContent, '',
$data);
return unserialize($serialized);
}
/**
* Stores authorization token passed as an argument.
* @param \MangoPay\OAuthToken $token Token instance to be stored.
*/
public function Store($token) {
if (!is_writable($this->GetPathToTemporaryFolder()))
throw new \MangoPay\Exception('Cannot create or write to
file ' . $this->GetPathToTemporaryFolder());
$serialized = serialize($token);
$result = file_put_contents($this->GetPathToFile(),
$this->_prefixContent . $serialized, LOCK_EX);
if ($result === false)
throw new \MangoPay\Exception('Cannot put token to
file');
}
/**
* Get path to storage file
* @return string
*/
private function GetPathToFile() {
return $this->GetPathToTemporaryFolder() . DIRECTORY_SEPARATOR .
$this->_fileName;
}
/**
* Get path to temporary folder
* @return string
*/
private function GetPathToTemporaryFolder() {
if (is_null($this->_config->TemporaryFolder))
throw new \MangoPay\Exception('Path to temporary folder is
not defined');
return $this->_config->TemporaryFolder;
}
}mangolib/tools/enums.inc000064400000004333151162260710011322
0ustar00<?php
namespace MangoPay;
/**
* Request type enum
*/
class RequestType {
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
}
/**
* Person type for users
*/
class PersonType {
const Natural = 'NATURAL';
const Legal = 'LEGAL';
}
/**
* Event types
*/
class EventType {
const KycCreated = "KYC_CREATED";
const KycSucceeded = "KYC_SUCCEEDED";
const KycFailed = "KYC_FAILED";
const KycValidationAsked = "KYC_VALIDATION_ASKED ";
const PayinNormalCreated = "PAYIN_NORMAL_CREATED";
const PayinNormalSucceeded = "PAYIN_NORMAL_SUCCEEDED";
const PayinNormalFailed = "PAYIN_NORMAL_FAILED";
const PayoutNormalCreated = "PAYOUT_NORMAL_CREATED";
const PayoutNormalSucceeded = "PAYOUT_NORMAL_SUCCEEDED";
const PayoutNormalFailed = "PAYOUT_NORMAL_FAILED";
const TransferNormalCreated = "TRANSFER_NORMAL_CREATED";
const TransferNormalSucceeded = "TRANSFER_NORMAL_SUCCEEDED";
const TransferNormalFailed = "TRANSFER_NORMAL_FAILED";
const PayinRefundCreated = "PAYIN_REFUND_CREATED";
const PayinRefundSucceeded = "PAYIN_REFUND_SUCCEEDED";
const PayinRefundFailed = "PAYIN_REFUND_FAILED";
const PayoutRefundCreated = "PAYOUT_REFUND_CREATED";
const PayoutRefundSucceeded = "PAYOUT_REFUND_SUCCEEDED";
const PayoutRefundFailed = "PAYOUT_REFUND_FAILED";
const TransferRefundCreated = "TRANSFER_REFUND_CREATED";
const TransferRefundSucceeded = "TRANSFER_REFUND_SUCCEEDED";
const TransferRefundFailed = "TRANSFER_REFUND_FAILED";
}
/**
* KYC document types
*/
class KycDocumentType {
const IdentityProof = 'IDENTITY_PROOF';
const RegistrationProof = 'REGISTRATION_PROOF';
const ArticlesOfAssociation = 'ARTICLES_OF_ASSOCIATION';
const ShareholderDeclaration = 'SHAREHOLDER_DECLARATION';
const AddressProof = 'ADDRESS_PROOF';
}
/**
* KYC document statuses
*/
class KycDocumentStatus{
const Created = 'CREATED';
const ValidationAsked = 'VALIDATION_ASKED';
const Validated = 'VALIDATED';
const Refused = 'REFUSED';
}
class CardValidity {
const Unknown = 'UNKNOWN';
const Valid = 'VALID';
const Invalid = 'INVALID';
}
class SortDirection {
const DESC = 'desc';
const ASC = 'asc';
}mangolib/tools/filterBase.inc000064400000000630151162260740012252
0ustar00<?php
namespace MangoPay;
/**
* Base filter object
*/
class FilterBase extends Dto {
/**
* Start date in unix format:
* return only records that have CreationDate BEFORE this date
* @var time
*/
public $BeforeDate;
/**
* End date in unix format:
* return only records that have CreationDate AFTER this date
* @var time
*/
public $AfterDate;
}mangolib/tools/filterEvents.inc000064400000000304151162260740012642
0ustar00<?php
namespace MangoPay;
/**
* Filter for event list
*/
class FilterEvents extends FilterBase {
/**
* Event type
* @var \MangoPay\EventType
*/
public $EventType;
}
mangolib/tools/filterTransactions.inc000064400000001061151162260740014047
0ustar00<?php
namespace MangoPay;
/**
* Filter for transaction list
*/
class FilterTransactions extends FilterBase {
/**
* TransactionStatus {CREATED, SUCCEEDED, FAILED}
* @var string
*/
public $Status;
/**
* TransactionType {PAYIN, PAYOUT, TRANSFER}
* @var string
*/
public $Type;
/**
* TransactionNature { REGULAR, REFUND, REPUDIATION }
* @var string
*/
public $Nature;
/**
* TransactionDirection {DEBIT, CREDIT}
* @var string
*/
public $Direction;
}mangolib/tools/index.html000064400000000054151162260740011474
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/tools/iStorageStrategy.inc000064400000000707151162260740013477
0ustar00<?php
namespace MangoPay;
/**
* Storage strategy interface.
*/
interface IStorageStrategy {
/**
* Gets the current authorization token.
* @return \MangoPay\OAuthToken Currently stored token instance or
null.
*/
function Get();
/**
* Stores authorization token passed as an argument.
* @param \MangoPay\OAuthToken $token Token instance to be stored.
*/
function Store($token);
}mangolib/tools/logs.inc000064400000000460151162260740011137
0ustar00<?php
namespace MangoPay;
/**
* Class to manage debug logs in MangoPay SDK
*/
class Logs {
public static function Debug($message, $data){
print '<pre>';
print $message . ': ';
print_r($data);
print
'<br/>-------------------------------</pre>';
}
}mangolib/tools/restTool.inc000064400000023514151162260740012013
0ustar00<?php
namespace MangoPay;
/**
* Class to prepare HTTP request, call the request and decode the response
*/
class RestTool {
/**
* Root/parent instance that holds the OAuthToken and Configuration
instance
* @var \MangoPay\MangoPayApi
*/
private $_root;
/**
* Variable to flag that in request authentication data are required
* @var bool
*/
private $_authRequired;
/**
* Array with HTTP header to send with request
* @var array
*/
private $_requestHttpHeaders;
/**
* cURL handle
* @var resource
*/
private $_curlHandle;
/**
* Request type for current request
* @var RequestType
*/
private $_requestType;
/**
* Array with data to pass in the request
* @var array
*/
private $_requestData;
/**
* Code get from response
* @var int
*/
private $_responseCode;
/**
* Pagination object
* @var MangoPay\Pagination
*/
private $_pagination;
private $_requestUrl;
private static $_JSON_HEADER = 'Content-Type:
application/json';
/**
* Constructor
* @param bool $authRequired Variable to flag that in request the
authentication data are required
* @param \MangoPay\MangoPayApi Root/parent instance that holds the
OAuthToken and Configuration instance
*/
function __construct($authRequired = true, $root) {
$this->_authRequired = $authRequired;
$this->_root = $root;
}
public function AddRequestHttpHeader($httpHeader) {
if (is_null($this->_requestHttpHeaders))
$this->_requestHttpHeaders = array();
array_push($this->_requestHttpHeaders, $httpHeader);
}
/**
* Call request to MangoPay API
* @param string $urlMethod Type of method in REST API
* @param \MangoPay\RequestType $requestType Type of request
* @param array $requestData Data to send in request
* @param \MangoPay\Pagination $pagination Pagination object
* @param array Array with additional parameters to URL. Expected keys:
"sort" and "filter"
* @return object Response data
*/
public function Request($urlMethod, $requestType, $requestData = null,
& $pagination = null, $additionalUrlParams = null) {
$this->_requestType = $requestType;
$this->_requestData = $requestData;
$this->BuildRequest($urlMethod, $pagination,
$additionalUrlParams);
$responseResult = $this->RunRequest();
if(!is_null($pagination)){
$pagination = $this->_pagination;
}
return $responseResult;
}
/**
* Execute request and check response
* @return object Response data
* @throws Exception If cURL has error
*/
private function RunRequest() {
$result = curl_exec($this->_curlHandle);
if ($result === false && curl_errno($this->_curlHandle)
!= 0)
throw new Exception('cURL error: ' .
curl_error($this->_curlHandle));
$this->_responseCode = (int)curl_getinfo($this->_curlHandle,
CURLINFO_HTTP_CODE);
curl_close($this->_curlHandle);
$logClass = $this->_root->Config->LogClass;
if ($this->_root->Config->DebugMode)
$logClass::Debug('Response JSON', $result);
$response = json_decode($result);
if ($this->_root->Config->DebugMode)
$logClass::Debug('Response object', $response);
$this->CheckResponseCode($response);
return $response;
}
/**
* Prepare all parameter to request
* @param String $urlMethod Type of method in REST API
* @throws Exception If some parameters are not set
*/
private function BuildRequest($urlMethod, $pagination,
$additionalUrlParams = null) {
$urlTool = new UrlTool($this->_root);
$restUrl = $urlTool->GetRestUrl($urlMethod,
$this->_authRequired, $pagination, $additionalUrlParams);
$this->_requestUrl = $urlTool->GetFullUrl($restUrl);
$logClass = $this->_root->Config->LogClass;
if ($this->_root->Config->DebugMode)
$logClass::Debug('FullUrl', $this->_requestUrl);
$this->_curlHandle = curl_init($this->_requestUrl);
if ($this->_curlHandle === false)
throw new Exception('Cannot initialize cURL
session');
curl_setopt($this->_curlHandle, CURLOPT_RETURNTRANSFER, true);
if ($this->_root->Config->CertificatesFilePath ==
'')
curl_setopt($this->_curlHandle, CURLOPT_SSL_VERIFYPEER,
false);
else {
curl_setopt($this->_curlHandle, CURLOPT_SSL_VERIFYPEER,
true);
curl_setopt($this->_curlHandle, CURLOPT_CAINFO,
$this->_root->Config->CertificatesFilePath);
}
if (!is_null($pagination)) {
curl_setopt($this->_curlHandle, CURLOPT_HEADERFUNCTION,
array(&$this, 'ReadResponseHeader'));
$this->_pagination = $pagination;
}
switch ($this->_requestType) {
case RequestType::POST:
curl_setopt($this->_curlHandle, CURLOPT_POST, true);
break;
case RequestType::PUT:
curl_setopt($this->_curlHandle, CURLOPT_CUSTOMREQUEST,
'PUT');
break;
case RequestType::DELETE:
curl_setopt($this->_curlHandle, CURLOPT_CUSTOMREQUEST,
"DELETE");
break;
}
if ($this->_root->Config->DebugMode)
$logClass::Debug('RequestType',
$this->_requestType);
$httpHeaders = $this->GetHttpHeaders();
curl_setopt($this->_curlHandle, CURLOPT_HTTPHEADER,
$httpHeaders);
if ($this->_root->Config->DebugMode)
$logClass::Debug('HTTP Headers', $httpHeaders);
if (!is_null($this->_requestData)) {
if ($this->_root->Config->DebugMode)
$logClass::Debug('RequestData object',
$this->_requestData);
// encode to json if needed
if (in_array(self::$_JSON_HEADER, $httpHeaders)) {
$this->_requestData =
json_encode($this->_requestData);
if ($this->_root->Config->DebugMode)
$logClass::Debug('RequestData JSON',
$this->_requestData);
}
curl_setopt($this->_curlHandle, CURLOPT_POSTFIELDS,
$this->_requestData);
}
}
/**
* Callback to read response headers
* @param resource $handle cURL handle
* @param string $header Header from response
* @return int Length of header
*/
private function ReadResponseHeader($handle, $header) {
$logClass = $this->_root->Config->LogClass;
if ($this->_root->Config->DebugMode)
$logClass::Debug('Response headers', $header);
if (strpos($header, 'X-Number-Of-Pages:') !== false) {
$this->_pagination->TotalPages =
(int)trim(str_replace('X-Number-Of-Pages:', '',
$header));
}
if (strpos($header, 'X-Number-Of-Items:') !== false) {
$this->_pagination->TotalItems =
(int)trim(str_replace('X-Number-Of-Items:', '',
$header));
}
if (strpos($header, 'Link: ') !== false) {
$strLinks = trim(str_replace('Link:', '',
$header));
$arrayLinks = explode(',', $strLinks);
if ($arrayLinks !== false) {
$this->_pagination->Links = array();
foreach ($arrayLinks as $link) {
$tmp = str_replace(array('<"',
'">', ' rel="', '"'),
'', $link);
$oneLink = explode(';', $tmp);
if (is_array($oneLink) && isset($oneLink[0])
&& isset($oneLink[1]))
$this->_pagination->Links[$oneLink[1]] =
$oneLink[0];
}
}
}
return strlen($header);
}
/**
* Get HTTP header to use in request
* @return array Array with HTTP headers
*/
private function GetHttpHeaders(){
// return if already created...
if (!is_null($this->_requestHttpHeaders))
return $this->_requestHttpHeaders;
// ...or initialize with default headers
$this->_requestHttpHeaders = array();
// content type
array_push($this->_requestHttpHeaders, self::$_JSON_HEADER);
// Authentication http header
if ($this->_authRequired) {
$authHlp = new AuthenticationHelper($this->_root);
array_push($this->_requestHttpHeaders,
$authHlp->GetHttpHeaderKey());
}
return $this->_requestHttpHeaders;
}
/**
* Check response code
* @param object $response Response from REST API
* @throws ResponseException If response code not OK
*/
private function CheckResponseCode($response){
if ($this->_responseCode != 200) {
if (isset($response) && is_object($response) &&
isset($response->Message)) {
$error = new Error();
$error->Message = $response->Message;
$error->Errors = property_exists($response,
'Errors')
? $response->Errors
: property_exists($response, 'errors') ?
$response->errors : null;
throw new ResponseException($this->_requestUrl,
$this->_responseCode, $error);
} else
throw new ResponseException($this->_requestUrl,
$this->_responseCode);
}
}
}mangolib/tools/sorting.inc000064400000002271151162260740011662
0ustar00<?php
namespace MangoPay;
/**
* Base sorting object
*/
class Sorting {
/**
* Fields separator in sort parameters in URL
*/
const SortFieldSeparator = "_";
/**
* Fields separator in sort parameters in URL
*/
const SortUrlParameterName = "Sort";
/**
* Array with fileds to sort
* @var type Array
*/
private $_sortFields;
/**
* Add filed to sort
* @param string $filedName Property name to sort
* @param \MangoPay\SortDirection $sortDirection Sort direction
*/
public function AddFiled($filedName, $sortDirection) {
$this->_sortFields[$filedName] = $sortDirection;
}
/**
* Get sort parametrs to URL
* @return array
*/
public function GetSortParameter() {
return array(self::SortUrlParameterName =>
$this->_getFields());
}
private function _getFields() {
$sortValues = "";
foreach ($this->_sortFields as $key => $value) {
if (!empty($sortValues))
$sortValues .= self::SortFieldSeparator;
$sortValues .= $key . ":" . $value;
}
return $sortValues;
}
}mangolib/tools/urlTool.inc000064400000004026151162260740011635
0ustar00<?php
namespace MangoPay;
class UrlTool {
/**
* Root/parent instance that holds the OAuthToken and Configuration
instance
* @var \MangoPay\MangoPayApi
*/
private $_root;
/**
* Constructor
* @param \MangoPay\MangoPayApi Root/parent instance that holds the
OAuthToken and Configuration instance
*/
function __construct($root) {
$this->_root = $root;
}
private function GetHost(){
if (is_null($this->_root->Config->BaseUrl) ||
strlen($this->_root->Config->BaseUrl) == 0)
throw new Exception ('Neither MangoPay_BaseUrl constant
nor BaseUrl config setting is defined.');
$baseUrl = $this->_root->Config->BaseUrl;
if (strpos($baseUrl, '/', strlen($baseUrl) - 1 ))
$baseUrl = substr ($baseUrl, 0, strlen($baseUrl) - 1);
return $baseUrl;
}
public function GetRestUrl($urlKey, $addClientId = true, $pagination =
null, $additionalUrlParams = null) {
if (!$addClientId) {
$url = '/v2' . $urlKey;
} else {
$url = '/v2/' .
$this->_root->Config->ClientId . $urlKey;
}
$paramsAdded = false;
if (!is_null($pagination)) {
$url .= '?page=' . $pagination->Page .
'&per_page=' . $pagination->ItemsPerPage;
$paramsAdded = true;
}
if (!is_null($additionalUrlParams)) {
if (array_key_exists("sort", $additionalUrlParams)) {
$url .= $paramsAdded ? '&' : '?';
$url .=
http_build_query($additionalUrlParams["sort"]);
$paramsAdded = true;
}
if (array_key_exists("filter", $additionalUrlParams))
{
$url .= $paramsAdded ? '&' : '?';
$url .=
http_build_query($additionalUrlParams["filter"]);
$paramsAdded = true;
}
}
return $url;
}
public function GetFullUrl($restUrl) {
return $this->GetHost() . $restUrl;
}
}
mangolib/types/bankAccountDetails.inc000064400000000215151162260740013733
0ustar00<?php
namespace MangoPay;
/**
* Marker interface for classes with details option in BankAccount entity
*/
interface BankAccountDetails {
}mangolib/types/bankAccountDetailsCA.inc000064400000001015151162260740014136
0ustar00<?php
namespace MangoPay;
/**
* Class represents CA bank account type for in BankAccount entity
*/
class BankAccountDetailsCA extends Dto implements BankAccountDetails {
/**
* Bank name
* @var string
*/
public $BankName;
/**
* Institution number
* @var string
*/
public $InstitutionNumber;
/**
* Branch code
* @var string
*/
public $BranchCode;
/**
* Account number
* @var string
*/
public $AccountNumber;
}mangolib/types/bankAccountDetailsGB.inc000064400000000527151162260740014152
0ustar00<?php
namespace MangoPay;
/**
* Class represents GB bank account type for in BankAccount entity
*/
class BankAccountDetailsGB extends Dto implements BankAccountDetails {
/**
* Account number
* @var string
*/
public $AccountNumber;
/**
* Sort code
* @var string
*/
public $SortCode;
}mangolib/types/bankAccountDetailsIBAN.inc000064400000000504151162260740014366
0ustar00<?php
namespace MangoPay;
/**
* Class represents IBAN bank account type for in BankAccount entity
*/
class BankAccountDetailsIBAN extends Dto implements BankAccountDetails {
/**
* IBAN number
* @var string
*/
public $IBAN;
/**
* BIC
* @var string
*/
public $BIC;
}mangolib/types/bankAccountDetailsOTHER.inc000064400000001105151162260740014534
0ustar00<?php
namespace MangoPay;
/**
* Class represents OTHER bank account type for in BankAccount entity
*/
class BankAccountDetailsOTHER extends Dto implements BankAccountDetails {
/**
* Type
* @var string
*/
public $Type;
/**
* The Country associate to the BankAccount,
* ISO 3166-1 alpha-2 format is expected
* @var string
*/
public $Country;
/**
* Valid BIC format
* @var string
*/
public $BIC;
/**
* Account number
* @var string
*/
public $AccountNumber;
}mangolib/types/bankAccountDetailsUS.inc000064400000000514151162260740014205
0ustar00<?php
namespace MangoPay;
/**
* Class represents US bank account type for in BankAccount entity
*/
class BankAccountDetailsUS extends Dto implements BankAccountDetails {
/**
* Account number
* @var string
*/
public $AccountNumber;
/**
* ABA
* @var string
*/
public $ABA;
}mangolib/types/configuration.inc000064400000002052151162260740013045
0ustar00<?php
namespace MangoPay;
/**
* Configuration settings
*/
class Configuration {
/**
* Client Id
* @var string
*/
public $ClientId;
/**
* Client password
* @var string
*/
public $ClientPassword;
/**
* Base URL to MangoPay API
* @var string
*/
/**Producion URL changes to {public $BaseUrl =
'https://api.mangopay.com';}**/
public $BaseUrl = 'https://api.sandbox.mangopay.com';
/**
* Path to folder with temporary files (with permissions to write)
*/
public $TemporaryFolder = null;
/**
* Absolute path to file holding one or more certificates to verify the
peer with.
* If empty - don't verifying the peer's certificate.
* @var string
*/
public $CertificatesFilePath = '';
/**
* [INTERNAL USAGE ONLY]
* Switch debug mode: log all request and response data
*/
public $DebugMode = false;
/**
* Set the logging class if DebugMode is enabled
*/
public $LogClass = 'MangoPay\Logs';
}mangolib/types/dto.inc000064400000001517151162260740010771
0ustar00<?php
namespace MangoPay;
/**
* Abstract class for all DTOs (entities and their composites)
*/
abstract class Dto {
/**
* Get array with mapping which property is object and what type of
object.
* To be overridden in child class if has any sub objects.
* @return array
*/
public function GetSubObjects() { return array(); }
/**
* Get array with mapping which property depends on other property
* To be overridden in child class if has any dependent objects.
* @return array
*/
public function GetDependsObjects() { return array(); }
/**
* Get array with read only properties - not used in response
* To be overridden in child class if has any read-only properties.
* @return array
*/
public function GetReadOnlyProperties() { return array(); }
}
mangolib/types/error.inc000064400000000516151162260740011332
0ustar00<?php
namespace MangoPay;
/**
* Class represents error object
*/
class Error {
/**
* Error message
* @var String
* @access public
*/
public $Message;
/**
* Array with errors information
* @var KeyValueArray
* @access public
*/
public $Errors;
}
mangolib/types/exceptions/exception.inc000064400000000102151162260740014347
0ustar00<?php
namespace MangoPay;
class Exception extends \Exception {
}
mangolib/types/exceptions/index.html000064400000000054151162260740013661
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/types/exceptions/responseException.inc000064400000003171151162260740016077
0ustar00<?php
namespace MangoPay;
/**
* Response exception class
*/
class ResponseException extends Exception {
/**
* Array with response code and corresponding response message
* @var array
*/
private $_responseCodes = array(
200 => 'OK',
206 => 'PartialContent',
400 => 'Bad request',
401 => 'Unauthorized',
403 => 'Prohibition to use the method',
404 => 'Not found',
405 => 'Method not allowed',
413 => 'Request entity too large',
422 => 'Unprocessable entity',
500 => 'Internal server error',
501 => 'Not implemented'
);
/**
* Error details
* @var Error
*/
private $_errorInfo;
/**
* Request URL
* @var string
*/
public $RequestUrl;
/**
* Construct
* @param int $code Response code
* @param Error $errorInfo Details with the error
*/
function __construct($requestUrl, $code, $errorInfo = null) {
$this->RequestUrl = $requestUrl;
$this->_code = $code;
if (isset($this->_responseCodes[$code])) {
$errorMsg = $this->_responseCodes[$code];
} else {
$errorMsg = 'Unknown response error';
}
if (!is_null($errorInfo)) {
$errorMsg .= '. ' . $errorInfo->Message;
$this->_errorInfo = $errorInfo;
}
parent::__construct($errorMsg, $code);
}
/**
* Get Error object returned by REST API
* @return Error
*/
public function GetErrorDetails(){
return $this->_errorInfo;
}
}mangolib/types/index.html000064400000000054151162260750011501
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>mangolib/types/keyValueArray.inc000064400000000501151162260750012760
0ustar00<?php
namespace MangoPay;
/**
* Class represents tabular values
*/
class KeyValueArray {
/**
* Key for tabular variable
* @var String
* @access public
*/
public $Key;
/**
* Value for tabular variable
* @var String
* @access public
*/
public $Value;
}
mangolib/types/money.inc000064400000000500151162260750011322
0ustar00<?php
namespace MangoPay;
/**
* Class represents money value with currency
*/
class Money extends Dto {
/**
* Text with currency code with ISO 4217 standard
* @var String
*/
public $Currency;
/**
* The currency amount of money
* @var Long
*/
public $Amount;
}
mangolib/types/oAuthToken.inc000064400000001450151162260750012261
0ustar00<?php
namespace MangoPay;
/**
* OAuthToken
*/
class OAuthToken extends Dto {
/**
* Created time
* @var int
*/
private $create_time;
/**
* Value of token
* @var string
*/
public $access_token;
/**
* Token type
* @var string
*/
public $token_type;
/**
* Expires time for the token
* @var int
*/
public $expires_in;
/**
* Constructor
*/
function __construct() {
$this->create_time = time() - 5;
}
/**
* Check that current tokens are expire and return true if yes
* @return bool
*/
public function IsExpired() {
return (time() >= ($this->create_time +
$this->expires_in));
}
}mangolib/types/pagination.inc000064400000001774151162260750012342
0ustar00<?php
namespace MangoPay;
/**
* Class represents pagination information
*/
class Pagination extends Dto {
/**
* Page number
* @var Int
*/
public $Page;
/**
* Number of items per page
* @var Int
*/
public $ItemsPerPage;
/**
* Number of total pages
* @var Int
*/
public $TotalPages;
/**
* Number of total items
* @var Int
*/
public $TotalItems;
/**
* Array with links to navigation.
* All values optional. Format:
* array(
* first => http url
* prev => http url
* next => http url
* last => http url
* )
* @var array
*/
public $Links = array();
/**
* Construct
* @param int $page Number of page
* @param int $itemsPerPage Number of items on one page
*/
function __construct($page = 1, $itemsPerPage = 10) {
$this->Page = $page;
$this->ItemsPerPage = $itemsPerPage;
}
}mangolib/types/payInExecutionDetails.inc000064400000000230151162260750014445
0ustar00<?php
namespace MangoPay;
/**
* Marker interface for classes with details of execution option in PayIn
entity
*/
interface PayInExecutionDetails { }
mangolib/types/payInExecutionDetailsDirect.inc000064400000001005151162260750015601
0ustar00<?php
namespace MangoPay;
/**
* Class represents Web type for execution option in PayIn entity
*/
class PayInExecutionDetailsDirect extends Dto implements
PayInExecutionDetails {
/**
* SecureMode { DEFAULT, FORCE }
* @var string
*/
public $SecureMode;
/**
* SecureModeReturnURL
* @var string
*/
public $SecureModeReturnURL;
/**
* SecureModeRedirectURL
* @var string
*/
public $SecureModeRedirectURL;
}
mangolib/types/payInExecutionDetailsWeb.inc000064400000003116151162260750015111
0ustar00<?php
namespace MangoPay;
/**
* Class represents Web type for execution option in PayIn entity
*/
class PayInExecutionDetailsWeb extends Dto implements PayInExecutionDetails
{
/**
* URL format expected
* @var string
*/
public $RedirectURL;
/**
* URL format expected
* @var string
*/
public $ReturnURL;
/**
* URL format expected.
* @var string
*/
public $TemplateURL;
/**
* The URL where you host the iFramed template.
* For CB, Visa, MasterCard you need to specify PAYLINE: before your
URL
* with the iFramed template
* ex: PAYLINE: https://www.maysite.com/payline_template/
* Used for:
* - direct debit web type pay-in.
*
* @var PayInTemplateURLOptions
*/
public $TemplateURLOptions;
/**
* @var string
*/
public $Culture;
/**
* Mode3DSType { DEFAULT, FORCE }
* @var string
*/
public $SecureMode;
/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'RedirectURL' );
return $properties;
}
/**
* Get array with mapping which property is object and what type of
object
* @return array
*/
public function GetSubObjects() {
return array(
'TemplateURLOptions' =>
'\MangoPay\PayInTemplateURLOptions'
);
}
}mangolib/types/payInPaymentDetails.inc000064400000000226151162260750014124
0ustar00<?php
namespace MangoPay;
/**
* Marker interface for classes with details of means of payment in PayIn
entity
*/
interface PayInPaymentDetails { }
mangolib/types/payInPaymentDetailsBankWire.inc000064400000001661151162260750015553
0ustar00<?php
namespace MangoPay;
/**
* Class represents BankWire type for mean of payment in PayIn entity
*/
class PayInPaymentDetailsBankWire extends Dto implements
PayInPaymentDetails {
/**
* Declared debited funds
* @var \MangoPay\Money
*/
public $DeclaredDebitedFunds;
/**
* Declared fees
* @var \MangoPay\Money
*/
public $DeclaredFees;
/**
* Bank account details
* @var \MangoPay\BankAccount
*/
public $BankAccount;
/**
* Wire reference
* @var string
*/
public $WireReference;
/**
* Get array with mapping which property is object and what type of
object
* @return array
*/
public function GetSubObjects() {
return array(
'DeclaredDebitedFunds' =>
'\MangoPay\Money' ,
'DeclaredFees' => '\MangoPay\Money' ,
'BankAccount' => '\MangoPay\BankAccount'
);
}
}
mangolib/types/payInPaymentDetailsCard.inc000064400000000570151162260750014720
0ustar00<?php
namespace MangoPay;
/**
* Class represents Card type for mean of payment in PayIn entity
*/
class PayInPaymentDetailsCard extends Dto implements PayInPaymentDetails {
/**
* CardType { CB_VISA_MASTERCARD, AMEX }
* @var string
*/
public $CardType;
/**
* CardId
* @var string
*/
public $CardId;
}
mangolib/types/payInPaymentDetailsDirectDebit.inc000064400000000462151162260750016231
0ustar00<?php
namespace MangoPay;
/**
* Class represents direct debit type for mean of payment in PayIn entity
*/
class PayInPaymentDetailsDirectDebit extends Dto implements
PayInPaymentDetails {
/**
* Direct debit type {SOFORT, ELV, GIROPAY}
* @var string
*/
public $DirectDebitType;
}
mangolib/types/payInPaymentDetailsPreAuthorized.inc000064400000000457151162260750016640
0ustar00<?php
namespace MangoPay;
/**
* Class represents Web type for execution option in PayIn entity
*/
class PayInPaymentDetailsPreAuthorized extends Dto implements
PayInPaymentDetails {
/**
* The ID of the Preauthorization object
* @var string
*/
public $PreauthorizationId;
}mangolib/types/payInTemplateURLOptions.inc000064400000000327151162260750014715
0ustar00<?php
namespace MangoPay;
/**
* Class represents template URL options
*/
class PayInTemplateURLOptions extends Dto {
/**
* PAYLINE options
*
* @var string
*/
public $PAYLINE;
}mangolib/types/payOutPaymentDetails.inc000064400000000230151162260750014320
0ustar00<?php
namespace MangoPay;
/**
* Marker interface for classes with details of means of payment in PayOut
entity
*/
interface PayOutPaymentDetails { }
mangolib/types/payOutPaymentDetailsBankWire.inc000064400000000645151162260750015755
0ustar00<?php
namespace MangoPay;
/**
* Class represents BankWire type for mean of payment in PayOut entity
*/
class PayOutPaymentDetailsBankWire extends Dto implements
PayOutPaymentDetails {
/**
* Bank account Id
* @var string
*/
public $BankAccountId;
/**
* A custom reference you wish to appear on the user’s bank statement
* @var string
*/
public $BankWireRef;
}
mangopay_checkout.php000064400000000447151162260760010770 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
mangopay_end.php000064400000002471151162260760007730 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
if(!empty($this->createdCardRegister)) {
?>
<form action="<?php echo
$this->createdCardRegister->CardRegistrationURL; ?>"
method="post">
<input type="hidden" name="data"
value="<?php echo
$this->createdCardRegister->PreregistrationData; ?>" />
<input type="hidden" name="accessKeyRef"
value="<?php echo $this->createdCardRegister->AccessKey;
?>" />
<input type="hidden" name="returnURL"
value="<?php echo $this->return_url; ?>" />
<label for="cardNumber"><?php echo
JText::_('CARD_NUMBER'); ?></label>
<input type="text" autocomplete="off"
name="cardNumber" value="" />
<div class="clear"></div>
<label for="cardExpirationDate"><?php echo
JText::_('EXPIRATION_DATE'); ?></label>
<input type="text" autocomplete="off"
name="cardExpirationDate" value=""
placeholder="MMYY"/>
<div class="clear"></div>
<label for="cardCvx"><?php echo
JText::_('CVV'); ?></label>
<input type="text" autocomplete="off"
name="cardCvx" value="" />
<div class="clear"></div>
<input type="submit" value="Pay" />
</form>
<?php
}