mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00

- Implemented cancelSubscription.json.php for handling subscription cancellations via JSON API. - Created cancelSubscription.php for managing subscription views and cancellation in the UI. - Developed getAcceptHostedToken.json.php to generate payment tokens for Authorize.Net. - Added getProfileManager.json.php for managing user profiles with Authorize.Net. - Implemented getSubscriptionStatus.json.php to check the status of subscriptions. - Created getSubscriptions.json.php to retrieve all subscriptions for the logged-in user. - Added SQL installation script for webhook logging. - Implemented processPayment.json.php for processing payments through Authorize.Net. - Developed webhook.php to handle incoming webhooks from Authorize.Net. - Integrated YPTWallet with Authorize.Net for wallet funding and subscription management. - Added confirmButton.php and confirmRecurrentButton.php for payment confirmation buttons in YPTWallet.
82 lines
3.1 KiB
PHP
82 lines
3.1 KiB
PHP
<?php
|
|
$uniqid = uniqid('anetSub_');
|
|
?>
|
|
|
|
<div class="btn-group" role="group" aria-label="Authorize.Net Actions">
|
|
<button type="button"
|
|
class="btn btn-primary"
|
|
id="AuthorizeNetRecurringBtn<?php echo $uniqid; ?>">
|
|
<i class="fas fa-sync-alt"></i> <?php echo __('Subscribe with Authorize.Net'); ?>
|
|
</button>
|
|
<button class="btn btn-info" onclick="openAuthorizeNetProfileManager()">
|
|
<i class="fas fa-user-cog"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<script>
|
|
$(function() {
|
|
$('#AuthorizeNetRecurringBtn<?php echo $uniqid; ?>').on('click', function(e) {
|
|
e.preventDefault();
|
|
modal.showPleaseWait();
|
|
|
|
$.ajax({
|
|
url: webSiteRootURL + 'plugin/AuthorizeNet/getAcceptHostedToken.json.php',
|
|
type: 'POST',
|
|
data: {
|
|
"plans_id": "<?php echo @$_GET['plans_id']; ?>"
|
|
},
|
|
success: function(resp) {
|
|
modal.hidePleaseWait();
|
|
|
|
if (resp.error) {
|
|
avideoAlertError(resp.msg || 'Unknown error');
|
|
return;
|
|
}
|
|
|
|
// Show payment details and redirect to Accept Hosted
|
|
if (resp.token && resp.url) {
|
|
const strWindowFeatures = "directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,height=650,width=1000";
|
|
openWindowWithPost(resp.url, 'Authorize.Net', {
|
|
'token': resp.token
|
|
}, strWindowFeatures);
|
|
return;
|
|
}
|
|
|
|
// Fallback
|
|
avideoAlertSuccess(resp.msg || "<?php echo __('Request processed successfully'); ?>");
|
|
},
|
|
error: function(xhr, status, error) {
|
|
modal.hidePleaseWait();
|
|
console.error('XHR Error:', xhr, status, error);
|
|
try {
|
|
var errorResp = JSON.parse(xhr.responseText);
|
|
avideoAlertError(errorResp.msg || 'Connection error');
|
|
} catch (e) {
|
|
avideoAlertError('Connection error: ' + (error || 'Unknown error'));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
function openAuthorizeNetProfileManager() {
|
|
modal.showPleaseWait();
|
|
fetch(webSiteRootURL + 'plugin/AuthorizeNet/getProfileManager.json.php')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
modal.hidePleaseWait();
|
|
if (!data.error && data.token && data.url) {
|
|
avideoDialogWithPost(data.url, {
|
|
'token': data.token
|
|
});
|
|
} else {
|
|
avideoAlertError('Profile error: ' + (data.msg || 'Could not get profile token'));
|
|
}
|
|
})
|
|
.catch(err => {
|
|
modal.hidePleaseWait();
|
|
avideoAlertError('Profile request failed: ' + err);
|
|
});
|
|
}
|
|
</script>
|