|
@@ -24,23 +24,23 @@ switch ($action) {
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$userId = isset($_POST['id']) ? intval($_POST['id']) : '';
|
|
$userId = isset($_POST['id']) ? intval($_POST['id']) : '';
|
|
$isUserHavePaypalAccount = $plugin->verifyPaypalAccountByBeneficiary($userId);
|
|
$isUserHavePaypalAccount = $plugin->verifyPaypalAccountByBeneficiary($userId);
|
|
-
|
|
|
|
|
|
+
|
|
if ($isUserHavePaypalAccount) {
|
|
if ($isUserHavePaypalAccount) {
|
|
echo '';
|
|
echo '';
|
|
} else {
|
|
} else {
|
|
echo '<b style="color: red; font-size: 70%;">* '.$plugin->get_lang('NoPayPalAccountDetected').'</b>';
|
|
echo '<b style="color: red; font-size: 70%;">* '.$plugin->get_lang('NoPayPalAccountDetected').'</b>';
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'saleInfo':
|
|
case 'saleInfo':
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$saleId = isset($_POST['id']) ? intval($_POST['id']) : '';
|
|
$saleId = isset($_POST['id']) ? intval($_POST['id']) : '';
|
|
$sale = $plugin->getSale($saleId);
|
|
$sale = $plugin->getSale($saleId);
|
|
$productType = ($sale['product_type'] == 1) ? get_lang('Course') : get_lang('Session');
|
|
$productType = ($sale['product_type'] == 1) ? get_lang('Course') : get_lang('Session');
|
|
@@ -52,9 +52,9 @@ switch ($action) {
|
|
} else {
|
|
} else {
|
|
$productImage = ($productInfo['image']) ? $productInfo['image'] : Template::get_icon_path('session_default.png');
|
|
$productImage = ($productInfo['image']) ? $productInfo['image'] : Template::get_icon_path('session_default.png');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$userInfo = api_get_user_info($sale['user_id']);
|
|
$userInfo = api_get_user_info($sale['user_id']);
|
|
-
|
|
|
|
|
|
+
|
|
$html = '<h2>' . $sale['product_name'] .'</h2>';
|
|
$html = '<h2>' . $sale['product_name'] .'</h2>';
|
|
$html .= '<div class="row">';
|
|
$html .= '<div class="row">';
|
|
$html .= '<div class="col-sm-6 col-md-6">';
|
|
$html .= '<div class="col-sm-6 col-md-6">';
|
|
@@ -73,14 +73,14 @@ switch ($action) {
|
|
$html .= '</div>';
|
|
$html .= '</div>';
|
|
|
|
|
|
echo $html;
|
|
echo $html;
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'stats':
|
|
case 'stats':
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$stats = [];
|
|
$stats = [];
|
|
$stats['completed_count'] = 0;
|
|
$stats['completed_count'] = 0;
|
|
$stats['completed_total_amount'] = 0;
|
|
$stats['completed_total_amount'] = 0;
|
|
@@ -88,31 +88,31 @@ switch ($action) {
|
|
$stats['pending_total_amount'] = 0;
|
|
$stats['pending_total_amount'] = 0;
|
|
$stats['canceled_count'] = 0;
|
|
$stats['canceled_count'] = 0;
|
|
$stats['canceled_total_amount'] = 0;
|
|
$stats['canceled_total_amount'] = 0;
|
|
-
|
|
|
|
|
|
+
|
|
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
|
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
|
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING);
|
|
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING);
|
|
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
|
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
|
$currency = $plugin->getSelectedCurrency();
|
|
$currency = $plugin->getSelectedCurrency();
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($completedPayouts as $completed) {
|
|
foreach ($completedPayouts as $completed) {
|
|
$stats['completed_count'] = count($completedPayouts);
|
|
$stats['completed_count'] = count($completedPayouts);
|
|
$stats['completed_total_amount'] += $completed['commission'];
|
|
$stats['completed_total_amount'] += $completed['commission'];
|
|
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2);
|
|
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($pendingPayouts as $pending) {
|
|
foreach ($pendingPayouts as $pending) {
|
|
$stats['pending_count'] = count($pendingPayouts);
|
|
$stats['pending_count'] = count($pendingPayouts);
|
|
$stats['pending_total_amount'] += $pending['commission'];
|
|
$stats['pending_total_amount'] += $pending['commission'];
|
|
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2);
|
|
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($canceledPayouts as $canceled) {
|
|
foreach ($canceledPayouts as $canceled) {
|
|
$stats['canceled_count'] = count($canceledPayouts);
|
|
$stats['canceled_count'] = count($canceledPayouts);
|
|
$stats['canceled_total_amount'] += $canceled['commission'];
|
|
$stats['canceled_total_amount'] += $canceled['commission'];
|
|
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2);
|
|
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
$html = '<div class="row">'
|
|
$html = '<div class="row">'
|
|
. '<p>'
|
|
. '<p>'
|
|
. '<ul>'
|
|
. '<ul>'
|
|
@@ -123,41 +123,41 @@ switch ($action) {
|
|
. '</p>';
|
|
. '</p>';
|
|
$html .= '</div>';
|
|
$html .= '</div>';
|
|
echo $html;
|
|
echo $html;
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'processPayout':
|
|
case 'processPayout':
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$html = '';
|
|
$html = '';
|
|
$allPays = [];
|
|
$allPays = [];
|
|
$totalAccounts = 0;
|
|
$totalAccounts = 0;
|
|
$totalPayout = 0;
|
|
$totalPayout = 0;
|
|
-
|
|
|
|
|
|
+
|
|
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
|
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
|
-
|
|
|
|
|
|
+
|
|
if (!$payouts) {
|
|
if (!$payouts) {
|
|
-
|
|
|
|
|
|
+
|
|
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
|
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($payouts as $index => $id) {
|
|
foreach ($payouts as $index => $id) {
|
|
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
|
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($allPays as $payout) {
|
|
foreach ($allPays as $payout) {
|
|
$totalPayout += number_format($payout['commission'], 2);
|
|
$totalPayout += number_format($payout['commission'], 2);
|
|
$totalAccounts++;
|
|
$totalAccounts++;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$currentCurrency = $plugin->getSelectedCurrency();
|
|
$currentCurrency = $plugin->getSelectedCurrency();
|
|
-
|
|
|
|
|
|
+
|
|
$isoCode = $currentCurrency['iso_code'];
|
|
$isoCode = $currentCurrency['iso_code'];
|
|
-
|
|
|
|
|
|
+
|
|
$html .= '<p>'. get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin") .'</p>';
|
|
$html .= '<p>'. get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin") .'</p>';
|
|
$html .= ''
|
|
$html .= ''
|
|
. '<p>'
|
|
. '<p>'
|
|
@@ -167,65 +167,65 @@ switch ($action) {
|
|
. '</ul>'
|
|
. '</ul>'
|
|
. '</p>';
|
|
. '</p>';
|
|
$html .= '<p>'. get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin") .'</p>';
|
|
$html .= '<p>'. get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin") .'</p>';
|
|
- $html .= '</br></br>';
|
|
|
|
|
|
+ $html .= '<br /><br />';
|
|
$html .= '<div id="spinner" class="text-center"></div>';
|
|
$html .= '<div id="spinner" class="text-center"></div>';
|
|
-
|
|
|
|
|
|
+
|
|
echo $html;
|
|
echo $html;
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'proceedPayout':
|
|
case 'proceedPayout':
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$paypalParams = $plugin->getPaypalParams();
|
|
$paypalParams = $plugin->getPaypalParams();
|
|
-
|
|
|
|
|
|
+
|
|
$pruebas = $paypalParams['sandbox'] == 1;
|
|
$pruebas = $paypalParams['sandbox'] == 1;
|
|
$paypalUsername = $paypalParams['username'];
|
|
$paypalUsername = $paypalParams['username'];
|
|
$paypalPassword = $paypalParams['password'];
|
|
$paypalPassword = $paypalParams['password'];
|
|
$paypalSignature = $paypalParams['signature'];
|
|
$paypalSignature = $paypalParams['signature'];
|
|
-
|
|
|
|
|
|
+
|
|
require_once("paypalfunctions.php");
|
|
require_once("paypalfunctions.php");
|
|
-
|
|
|
|
|
|
+
|
|
$allPayouts = [];
|
|
$allPayouts = [];
|
|
$totalAccounts = 0;
|
|
$totalAccounts = 0;
|
|
$totalPayout = 0;
|
|
$totalPayout = 0;
|
|
-
|
|
|
|
|
|
+
|
|
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
|
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : '';
|
|
-
|
|
|
|
|
|
+
|
|
if (!$payouts) {
|
|
if (!$payouts) {
|
|
-
|
|
|
|
|
|
+
|
|
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
|
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false);
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach ($payouts as $index => $id) {
|
|
foreach ($payouts as $index => $id) {
|
|
$allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
|
$allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$currentCurrency = $plugin->getSelectedCurrency();
|
|
$currentCurrency = $plugin->getSelectedCurrency();
|
|
-
|
|
|
|
|
|
+
|
|
$isoCode = $currentCurrency['iso_code'];
|
|
$isoCode = $currentCurrency['iso_code'];
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
$result = MassPayment($allPayouts, $isoCode);
|
|
$result = MassPayment($allPayouts, $isoCode);
|
|
-
|
|
|
|
|
|
+
|
|
if ($result['ACK'] === 'Success') {
|
|
if ($result['ACK'] === 'Success') {
|
|
foreach ($allPayouts as $payout) {
|
|
foreach ($allPayouts as $payout) {
|
|
$plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
|
$plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false);
|
|
echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false);
|
|
-
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- echo Display::return_message('<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '.$result['L_SHORTMESSAGE0'].'</br><ul><li>'. $result['L_LONGMESSAGE0'].'</li></ul>', 'error', false);
|
|
|
|
-
|
|
|
|
|
|
+ echo Display::return_message('<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '.$result['L_SHORTMESSAGE0'].'<br /><ul><li>'. $result['L_LONGMESSAGE0'].'</li></ul>', 'error', false);
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'cancelPayout':
|
|
case 'cancelPayout':
|
|
if (api_is_anonymous()) {
|
|
if (api_is_anonymous()) {
|
|
break;
|
|
break;
|
|
@@ -234,9 +234,9 @@ switch ($action) {
|
|
// $payoutId only gets used in setStatusPayout(), where it is filtered
|
|
// $payoutId only gets used in setStatusPayout(), where it is filtered
|
|
$payoutId = isset($_POST['id']) ? $_POST['id'] : '';
|
|
$payoutId = isset($_POST['id']) ? $_POST['id'] : '';
|
|
$plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
|
$plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED);
|
|
-
|
|
|
|
|
|
+
|
|
echo '';
|
|
echo '';
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
exit;
|
|
exit;
|