PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.4
StreamCast – bring live radio to your site with a sleek player v2.3.4
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / freemius / templates / checkout / process-redirect.php

process-redirect.php in StreamCast – bring live radio to your site with a sleek player 2.3.4, at freemius/templates/checkout/process-redirect.php

130 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2024, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 2.9.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $fs = freemius( $VARS['id'] );
18 $fs_checkout = FS_Checkout_Manager::instance();
19
20 $plugin_id = fs_request_get( 'plugin_id' );
21 if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
22 $plugin_id = $fs->get_id();
23 }
24
25 $fs_checkout->verify_checkout_redirect_nonce( $fs );
26
27 wp_enqueue_script( 'jquery' );
28 wp_enqueue_script( 'json2' );
29 fs_enqueue_local_script( 'fs-form', 'jquery.form.js', array( 'jquery' ) );
30
31 $action = fs_request_get( '_fs_checkout_action' );
32 $data = json_decode( fs_request_get_raw( '_fs_checkout_data' ) );
33 ?>
34 <div class="fs-checkout-process-redirect">
35 <div class="fs-checkout-process-redirect__loader">
36 <?php fs_include_template( 'ajax-loader.php' ); ?>
37 </div>
38
39 <div class="fs-checkout-process-redirect__content">
40 <p>
41 <?php echo esc_html( fs_text_inline( 'Processing, please wait and do not close or refresh this window...' ) ); ?>
42 </p>
43 </div>
44 </div>
45
46 <script type="text/javascript">
47 jQuery(function ($) {
48 var $loader = $( '.fs-checkout-process-redirect .fs-ajax-loader' ),
49 action = <?php echo wp_json_encode( $action ); ?>,
50 data = <?php echo wp_json_encode( $data ); ?>;
51
52 $loader.show();
53
54 // This remains compatible with the same filter in /templates/checkout/frame.php.
55 // You can return a promise to make the successive redirection wait until your own processing is completed.
56 // However for most cases, we recommend sending a beacon request {https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon}
57 var processPurchaseEvent = (<?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
58 console.log("checkout", "purchaseCompleted");
59 }'); ?>)(data.purchaseData);
60
61 if (typeof Promise !== 'undefined' && processPurchaseEvent instanceof Promise) {
62 processPurchaseEvent.finally(function () {
63 finishProcessing(action, data);
64 });
65 } else {
66 finishProcessing(action, data);
67 }
68
69 function finishProcessing(action, data) {
70 switch ( action ) {
71 case 'install':
72 processInstall( data );
73 break;
74 case 'pending_activation':
75 processPendingActivation( data );
76 break;
77 case 'return_without_sync':
78 goToAccount();
79 break;
80 default:
81 syncLicense( data );
82 break;
83 }
84 }
85
86 function processInstall( data ) {
87 var requestData = {
88 user_id : data.user.id,
89 user_secret_key : data.user.secret_key,
90 user_public_key : data.user.public_key,
91 install_id : data.install.id,
92 install_secret_key: data.install.secret_key,
93 install_public_key: data.install.public_key
94 };
95
96 if ( true === data.auto_install )
97 requestData.auto_install = true;
98
99 // Post data to activation URL.
100 $.form( '<?php echo $fs_checkout->get_install_url( $fs, $plugin_id ); ?>', requestData ).submit();
101 }
102
103 function processPendingActivation( data ) {
104 var requestData = {
105 user_email : data.user_email,
106 support_email_address: data.support_email_address
107 };
108
109 if ( true === data.auto_install )
110 requestData.auto_install = true;
111
112 $.form( '<?php echo $fs_checkout->get_pending_activation_url( $fs, $plugin_id ); ?>', requestData ).submit();
113 }
114
115 function syncLicense(data) {
116 var redirectUrl = new URL( <?php echo wp_json_encode( $fs->_get_sync_license_url( $plugin_id ) ); ?> );
117
118 if (true === data.auto_install) {
119 redirectUrl.searchParams.set( 'auto_install', 'true' );
120 }
121
122 window.location.href = redirectUrl.toString();
123 }
124
125 function goToAccount() {
126 window.location.href = <?php echo wp_json_encode( $fs->get_account_url() ) ?>;
127 }
128 });
129 </script>
130