Skip to content

Commit

Permalink
Merge pull request #48 from DanielnetoDotCom/master
Browse files Browse the repository at this point in the history
update unstable
  • Loading branch information
Vinzenz Hersche authored Apr 10, 2018
2 parents bd3d356 + aac3c26 commit 179c2b7
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 73 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
/plugin/SubtitleSwitcher/
/plugin/AWS_S3/
/plugin/SignUpAgreement/
/plugin/YPTWallet/plugins/YPTWalletPayPal/
/plugin/PromoteVideos/
/plugin/Livesearch/
/plugin/AudioVisualizer/
1 change: 1 addition & 0 deletions plugin/Gallery/view/modeGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ function afterExtraVideos($liveLi) {
$countCols = 0;
unset($_POST['sort']);
$_POST['sort']['created'] = $_GET['dateAddedOrder'];
$_POST['current'] = $_GET['page'];
$_POST['rowCount'] = $obj->DateAddedRowCount;
$videos = Video::getAllVideos();
createGallerySection($videos);
Expand Down
9 changes: 6 additions & 3 deletions plugin/Live/stats.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@

$users = false;
if($liveUsersEnabled){
require_once $global['systemRootPath'] . 'plugin/LiveUsers/Objects/LiveOnlineUsers.php';
$liveUsers = new LiveOnlineUsers(0);
$users = $liveUsers->getUsersFromTransmitionKey($value->name);
$filename = $global['systemRootPath'] . 'plugin/LiveUsers/Objects/LiveOnlineUsers.php';
if(file_exists($filename)){
require_once $filename;
$liveUsers = new LiveOnlineUsers(0);
$users = $liveUsers->getUsersFromTransmitionKey($value->name);
}
}

$u = new User($row['users_id']);
Expand Down
39 changes: 39 additions & 0 deletions plugin/YPTWallet/plugins/YPTWalletPayPal/YPTWalletPayPal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

global $global;
require_once $global['systemRootPath'] . 'plugin/YPTWallet/YPTWalletPlugin.php';

class YPTWalletPayPal extends YPTWalletPlugin{

public function getAprovalLink() {
global $global;
$plugin = YouPHPTubePlugin::loadPluginIfEnabled("PayPalYPT");
$payment = $plugin->setUpPayment(
$this->getInvoiceNumber(),
$this->getRedirectURL(),
$this->getCancelURL(),
$this->getValue(),
$this->getCurrency());
if (!empty($payment)) {
return $payment->getApprovalLink();
}
return false;
}

public function getAprovalButton() {
global $global;
include $global['systemRootPath'].'plugin/YPTWallet/plugins/YPTWalletPayPal/confirmButton.php';
}

public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->ClientID = "ASUkHFpWX0T8sr8EiGdLZ05m-RAb8l-hdRxoq-OXWmua2i7EUfqFkMZvSoGgH2LhK7zAqt29IiS2oRTn";
$obj->ClientSecret = "ECxtMBsLr0cFwSCgI0uaDiVzEUbVlV3r_o_qaU-SOsQqCEOKPq4uGlr1C0mhdDmEyO30mw7-PF0bOnfo";
$obj->RedirectURL = "{$global['webSiteRootURL']}plugin/YPTWallet/plugins/YPTWalletPayPal/redirect_url.php";
$obj->CancelURL = "{$global['webSiteRootURL']}plugin/YPTWallet/plugins/YPTWalletPayPal/cancel_url.php";
$obj->disableSandbox = false;
return $obj;
}

}
7 changes: 7 additions & 0 deletions plugin/YPTWallet/plugins/YPTWalletPayPal/cancel_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../../../../';
}
require_once $global['systemRootPath'] . 'videos/configuration.php';

header("Location: {$global['webSiteRootURL']}plugin/SupportAuthor/view/addFunds.php?status=cancel");
27 changes: 27 additions & 0 deletions plugin/YPTWallet/plugins/YPTWalletPayPal/confirmButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<button type="submit" class="btn btn-primary" id="YPTWalletPayPalButton"><?php echo __("Confirm"); ?> PayPal</button>
<script>
$(document).ready(function () {
$('#YPTWalletPayPalButton').click(function (evt) {
evt.preventDefault();
modal.showPleaseWait();

$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/YPTWallet/plugins/YPTWalletPayPal/requestPayment.json.php',
data: {
"value": $('#value').val()
},
type: 'post',
success: function (response) {
if (!response.error) {
document.location = response.approvalLink;
} else {
swal("<?php echo __("Sorry!"); ?>", "<?php echo __("Error!"); ?>", "error");
modal.hidePleaseWait();
}
}
});
return false;
});
});

</script>
34 changes: 34 additions & 0 deletions plugin/YPTWallet/plugins/YPTWalletPayPal/redirect_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

header('Content-Type: application/json');

if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../../../../';
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';

$plugin = YouPHPTubePlugin::loadPluginIfEnabled("YPTWallet");
$paypal = YouPHPTubePlugin::loadPluginIfEnabled("PayPalYPT");
$users_id = User::getId();

$invoiceNumber = uniqid();
$redirect_url = "{$global['webSiteRootURL']}plugin/SupportAuthor/redirect_url.php";
$cancel_url = "{$global['webSiteRootURL']}plugin/SupportAuthor/cancel_url.php";

$payment = $paypal->executePayment();
//var_dump($amount);
$obj= new stdClass();
$obj->error = true;
if (!empty($payment)) {
$amount = PayPalYPT::getAmountFromPayment($payment);
$plugin->addBalance($users_id, $amount->total, "Paypal payment", json_encode($payment));
$obj->error = false;
header("Location: {$global['webSiteRootURL']}plugin/YPTWallet/view/addFunds.php?status=success");
}else{
header("Location: {$global['webSiteRootURL']}plugin/YPTWallet/view/addFunds.php?status=fail");
}
error_log(json_encode($obj));


?>
32 changes: 32 additions & 0 deletions plugin/YPTWallet/plugins/YPTWalletPayPal/requestPayment.json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

header('Content-Type: application/json');

if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../../../../';
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';

$plugin = YouPHPTubePlugin::loadPluginIfEnabled("PayPalYPT");
$pluginS = YouPHPTubePlugin::loadPluginIfEnabled("YPTWallet");
$objS = $pluginS->getDataObject();
$options = json_decode($objS->addFundsOptions);

$obj= new stdClass();
$obj->error = true;

if(empty($_POST['value']) || !in_array($_POST['value'], $options)){
$obj->msg = "Invalid Value";
die(json_encode($obj));
}

$invoiceNumber = uniqid();

$payment = $plugin->setUpPayment($invoiceNumber, $objS->RedirectURL, $objS->CancelURL, $_POST['value'], $objS->currency);

if (!empty($payment)) {
$obj->error = false;
$obj->approvalLink = $payment->getApprovalLink();
}
die(json_encode($obj));
Loading

0 comments on commit 179c2b7

Please sign in to comment.