-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from DanielnetoDotCom/master
update unstable
- Loading branch information
Showing
11 changed files
with
252 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
plugin/YPTWallet/plugins/YPTWalletPayPal/YPTWalletPayPal.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
plugin/YPTWallet/plugins/YPTWalletPayPal/confirmButton.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
plugin/YPTWallet/plugins/YPTWalletPayPal/requestPayment.json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
Oops, something went wrong.