Changeset 3298119
- Timestamp:
- 05/21/2025 01:39:04 PM (10 months ago)
- Location:
- webtonative/trunk
- Files:
-
- 12 edited
-
README.md (modified) (1 diff)
-
admin/iap/rest.php (modified) (2 diffs)
-
index.php (modified) (1 diff)
-
simple-iap/js/wtn-iap.js (modified) (1 diff)
-
simple-iap/simple-iap.php (modified) (4 diffs)
-
website/iap.php (modified) (1 diff)
-
website/scripts/woocommerce.js (modified) (7 diffs)
-
webtonative-biometric/assets/biometric.js (modified) (2 diffs)
-
webtonative-biometric/webtonative-biometric.php (modified) (2 diffs)
-
webtonative-radio-player/css/player.css (modified) (1 diff)
-
webtonative-radio-player/js/player.js (modified) (1 diff)
-
webtonative-radio-player/webtonative-radio-player.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
webtonative/trunk/README.md
r3297334 r3298119 4 4 Requires at least: 2.0.2 5 5 Tested up to: 6.7.1 6 Stable tag: 2.8. 26 Stable tag: 2.8.3 7 7 License: GPLv2 or later 8 8 -
webtonative/trunk/admin/iap/rest.php
r3296993 r3298119 140 140 141 141 $product_data = wc_get_product($product_id); 142 $order = wc_create_order(); 142 $order = wc_create_order(array( 143 'customer_id' => $current_user->ID, 144 )); 143 145 $order->add_product($product_data); 144 146 $order->set_payment_method('webtonative'); 145 147 $order->set_status('wc-completed'); 146 $order->set_customer_id($current_user->ID);148 // $order->set_customer_id($current_user->ID); 147 149 $order->calculate_totals(); 148 150 $order->save(); … … 188 190 189 191 $product_data = wc_get_product($product_id); 190 $order = wc_create_order(); 192 $order = wc_create_order(array( 193 'customer_id' => $current_user->ID, 194 )); 191 195 $order->add_product($product_data); 192 196 $order->set_payment_method('webtonative'); 193 197 $order->set_status('wc-completed'); 194 $order->set_customer_id($current_user->ID);198 // $order->set_customer_id($current_user->ID); 195 199 $order->calculate_totals(); 196 200 $order->save(); -
webtonative/trunk/index.php
r3297334 r3298119 3 3 Plugin Name: webtonative 4 4 Description: webtonative Plugin 5 Version: 2.8. 25 Version: 2.8.3 6 6 Author: webtonative 7 7 */ -
webtonative/trunk/simple-iap/js/wtn-iap.js
r3227974 r3298119 1 1 document.addEventListener('DOMContentLoaded', function () { 2 if (!window.WTN) return;2 if (!window.WTN) return; 3 3 4 const isAndroidApp = window.WTN.isAndroidApp;5 const isLoggedIn = simpleIAPData.isLoggedIn;6 const iosSecretKey = simpleIAPData.iosSecretKey;4 const isAndroidApp = window.WTN.isAndroidApp; 5 const isLoggedIn = simpleIAPData.isLoggedIn; 6 const iosSecretKey = simpleIAPData.iosSecretKey; 7 7 8 document.querySelectorAll('.iap-button').forEach(button=> {9 button.addEventListener('click', function () {10 if (!isLoggedIn) {11 alert('Please login to continue');12 return;13 }8 document.querySelectorAll('.iap-button').forEach((button) => { 9 button.addEventListener('click', function () { 10 if (!isLoggedIn) { 11 alert('Please login to continue'); 12 return; 13 } 14 14 15 if(!isAndroidApp && !iosSecretKey) {16 alert('Please configure the App store secret key in settings');17 return;18 }15 if (!isAndroidApp && !iosSecretKey) { 16 alert('Please configure the App store secret key in settings'); 17 return; 18 } 19 19 20 const dataToProcess = {21 productId: isAndroidApp ? button.dataset.googlePlayId : button.dataset.appStoreId,22 productType: button.dataset.productType,23 isConsumable: button.dataset.isConsumable === 'true',24 };20 const dataToProcess = { 21 productId: isAndroidApp ? button.dataset.googlePlayId : button.dataset.appStoreId, 22 productType: button.dataset.productType, 23 isConsumable: button.dataset.isConsumable === 'true', 24 }; 25 25 26 button.disabled = true;27 button.textContent = 'Processing...';26 button.disabled = true; 27 button.textContent = 'Processing...'; 28 28 29 window.WTN.inAppPurchase({ 30 ...dataToProcess, 31 callback: (data) => handlePaymentResponse(data, button), 32 }); 33 }); 29 window.WTN.inAppPurchase({ 30 ...dataToProcess, 31 callback: (data) => handlePaymentResponse(data, button), 32 }); 34 33 }); 34 }); 35 35 36 function handlePaymentResponse(data, button) {37 button.disabled = false;38 button.textContent = 'Buy Now';36 function handlePaymentResponse(data, button) { 37 button.disabled = false; 38 button.textContent = 'Buy Now'; 39 39 40 if (!data.isSuccess) { 41 alert('Payment failed'); 42 return; 40 if (!data.isSuccess) { 41 alert('Payment failed'); 42 return; 43 } 44 45 const receiptData = typeof data.receiptData === 'string' ? data.receiptData : JSON.stringify(data.receiptData); 46 47 const formData = new FormData(); 48 formData.append('action', 'simple_iap_verify'); 49 formData.append('nonce', simpleIAPData.nonce); 50 formData.append('platform', /iPhone|iPad|iPod/.test(navigator.userAgent) ? 'ios' : 'android'); 51 formData.append('receipt', receiptData); 52 53 fetch(simpleIAPData.ajax_url, { 54 method: 'POST', 55 body: formData, 56 }) 57 .then((response) => response.json()) 58 .then((result) => { 59 if (result.success) { 60 alert('Purchase successful!'); 61 } else { 62 alert('Verification failed: ' + result?.data?.message); 43 63 } 44 45 const formData = new FormData(); 46 formData.append('action', 'simple_iap_verify'); 47 formData.append('nonce', simpleIAPData.nonce); 48 formData.append('platform', /iPhone|iPad|iPod/.test(navigator.userAgent) ? 'ios' : 'android'); 49 formData.append('receipt', data.receiptData); 50 51 fetch(simpleIAPData.ajax_url, { 52 method: 'POST', 53 body: formData, 54 }) 55 .then(response => response.json()) 56 .then(result => { 57 if (result.success) { 58 alert('Purchase successful!'); 59 } else { 60 alert('Verification failed: '+ result?.data?.message); 61 } 62 }) 63 .catch(error => { 64 console.error('Error:', error); 65 alert('Verification error: ' + error.message); 66 }); 67 } 64 }) 65 .catch((error) => { 66 console.error('Error:', error); 67 alert('Verification error: ' + error.message); 68 }); 69 } 68 70 }); -
webtonative/trunk/simple-iap/simple-iap.php
r3227974 r3298119 80 80 // Enqueue scripts 81 81 add_action('wp_enqueue_scripts', function () { 82 wp_enqueue_script('simple-iap-js', plugin_dir_url(__FILE__) . 'js/wtn-iap.js ', [], '1.1', true);82 wp_enqueue_script('simple-iap-js', plugin_dir_url(__FILE__) . 'js/wtn-iap.js?ver=1.1.6', [], '1.1', true); 83 83 84 84 wp_localize_script('simple-iap-js', 'simpleIAPData', [ … … 123 123 124 124 $platform = sanitize_text_field($_POST['platform'] ?? ''); 125 $receipt = sanitize_text_field($_POST['receipt'] ?? '');125 $receipt = ($platform === 'ios') ? sanitize_text_field($_POST['receipt'] ?? '') : $_POST['receipt']; 126 126 127 127 if (empty($platform) || empty($receipt)) { … … 136 136 $callback_function = get_option('simple_iap_callback_function'); 137 137 if (!empty($callback_function) && function_exists($callback_function)) { 138 call_user_func($callback_function, $platform, ['receipt' => $receipt, 'verification_result' => $result]);138 call_user_func($callback_function, $platform, ['receipt' => ($platform === 'ios') ? $receipt : '', 'verification_result' => $result]); 139 139 } 140 140 … … 232 232 } 233 233 234 235 234 // Placeholder for Android receipt verification 236 235 function simple_iap_verify_android_receipt($receipt) 237 236 { 238 return ['success' => true, 'data' => $receipt]; // Implement actual Android verification here 239 } 237 $receipt_json = json_decode(stripslashes($receipt), true); 238 return ['success' => true, 'data' => $receipt_json]; // Implement actual Android verification here 239 } -
webtonative/trunk/website/iap.php
r3297334 r3298119 21 21 $webtonative_settings = get_option('woocommerce_webtonative_settings'); 22 22 23 wp_register_script('webtonative-iap', plugins_url('scripts/woocommerce.js?var=6.1 3.10', __FILE__), array('webtonative', 'jquery'), filemtime(plugin_dir_path(__FILE__) . 'scripts/woocommerce.js'), true);23 wp_register_script('webtonative-iap', plugins_url('scripts/woocommerce.js?var=6.14.2', __FILE__), array('webtonative', 'jquery'), filemtime(plugin_dir_path(__FILE__) . 'scripts/woocommerce.js'), true); 24 24 wp_localize_script('webtonative-iap', 'wtn_biometric_settings', array( 25 25 'btn_proccessing_text' => $saved_settings['processing_button_text'], -
webtonative/trunk/website/scripts/woocommerce.js
r3297334 r3298119 27 27 28 28 let productListCache = null; 29 let isIAPInitialized = false; 29 30 30 31 async function fetchProductList() { … … 78 79 79 80 try { 81 isIAPInitialized = true; 80 82 const productData = await getProductIds(productId); 81 83 WTN.inAppPurchase({ … … 85 87 alert(btnTexts.failed); 86 88 toggleButtonState(button, false, btnTexts.buyNow); 89 isIAPInitialized = false; 87 90 return; 88 91 } … … 91 94 alert('Already purchased'); 92 95 toggleButtonState(button, false, btnTexts.buyNow); 96 isIAPInitialized = false; 93 97 return; 94 98 } … … 106 110 toggleButtonState(button, false, btnTexts.success); 107 111 } 112 isIAPInitialized = false; 108 113 } catch (orderError) { 109 114 toggleButtonState(button, false, btnTexts.failed); 115 isIAPInitialized = false; 110 116 } 111 117 }, … … 114 120 console.error('Error in processPayment:', error); 115 121 toggleButtonState(button, false, btnTexts.failed); 122 isIAPInitialized = false; 116 123 } 117 124 } … … 168 175 169 176 $(document).ajaxComplete(async function () { 177 if (isIAPInitialized) return; 170 178 debounce(setupButtons, 300)(); 171 179 }); -
webtonative/trunk/webtonative-biometric/assets/biometric.js
r3296993 r3298119 160 160 function showBiometricPrompt() { 161 161 window.WTN.Biometric.show({ 162 isAuthenticationOptional: true, 162 163 prompt: 'Authenticate to continue!', 163 164 callback: function (data) { … … 176 177 return new Promise((resolve) => { 177 178 window.WTN.Biometric.show({ 179 isAuthenticationOptional: true, 178 180 prompt: promptText, 179 181 callback: resolve, -
webtonative/trunk/webtonative-biometric/webtonative-biometric.php
r3296993 r3298119 13 13 function wtn_biometric_enqueue_scripts() 14 14 { 15 wp_enqueue_script('wtn-biometric-js', plugins_url('assets/biometric.js?ver=1.1. 8', __FILE__), ['jquery'], '1.0.0', true);15 wp_enqueue_script('wtn-biometric-js', plugins_url('assets/biometric.js?ver=1.1.9', __FILE__), ['jquery'], '1.0.0', true); 16 16 17 17 wp_localize_script('wtn-biometric-js', 'WTN_Biometric_Settings', [ … … 233 233 loginButton.addEventListener('click', () => { 234 234 window.WTN.Biometric.show({ 235 isAuthenticationOptional: true, 235 236 prompt: "Authenticate to login", 236 237 callback: function(data) { -
webtonative/trunk/webtonative-radio-player/css/player.css
r3216434 r3298119 79 79 } 80 80 81 .d-none { 82 display: none !important; 83 } 84 81 85 /* Disabled Buttons */ 82 86 button:disabled { -
webtonative/trunk/webtonative-radio-player/js/player.js
r3216434 r3298119 1 1 (function ($) { 2 let tracks = wtnPlayerData.tracks || [];3 let currentTrackIndex = 0;4 let audio = new Audio();2 const wtnPlayerWrapper = $('#wtn-player'); 3 const isAndroidApp = window.WTN && window.WTN.isAndroidApp; 4 if (!isAndroidApp) return; 5 5 6 function loadTrack(index) { 7 let track = tracks[index]; 8 if (!track) return; 6 wtnPlayerWrapper.removeClass('d-none'); 9 7 10 $('#track-title').text(track.name || 'Unknown Track'); 11 $('#track-image').attr('src', track.image || ''); 12 audio.src = track.url || ''; 8 let tracks = wtnPlayerData.tracks || []; 9 let currentTrackIndex = 0; 10 // let audio = new Audio(); 11 let isPlaying = false; 13 12 14 // Disable/Enable Prev and Next buttons based on track availability 15 $('#wtn-prev').prop('disabled', index === 0).toggle(tracks.length > 1); 16 $('#wtn-next').prop('disabled', index === tracks.length - 1).toggle(tracks.length > 1); 13 function loadTrack(index) { 14 let track = tracks[index]; 15 if (!track) return; 16 17 $('#track-title').text(track.name || 'Unknown Track'); 18 $('#track-image').attr('src', track.image || ''); 19 // audio.src = track.url || ''; 20 21 // Disable/Enable Prev and Next buttons based on track availability 22 $('#wtn-prev') 23 .prop('disabled', index === 0) 24 .toggle(tracks.length > 1); 25 $('#wtn-next') 26 .prop('disabled', index === tracks.length - 1) 27 .toggle(tracks.length > 1); 28 } 29 30 // Play/Pause Button 31 $('#wtn-play-pause').on('click', function () { 32 // alert('Play/Pause button clicked => ' + audio.paused); 33 if (!isPlaying) { 34 // audio.play(); 35 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 36 $(this).text('⏸'); 37 isPlaying = true; 38 // alert('Audio is paused, playing now'); 39 } else { 40 // audio.pause(); 41 window?.WTN?.MediaPlayer?.pauseMedia(); 42 $(this).text('▶'); 43 isPlaying = false; 44 // alert('Audio is playing, pausing now'); 17 45 } 46 }); 18 47 19 // Play/Pause Button 20 $('#wtn-play-pause').on('click', function () { 21 if (audio.paused) { 22 audio.play(); 23 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 24 $(this).text('⏸'); 25 } else { 26 audio.pause(); 27 window?.WTN?.MediaPlayer?.pauseMedia(); 28 $(this).text('▶'); 29 } 30 }); 48 // Previous Button 49 $('#wtn-prev').on('click', function () { 50 if (currentTrackIndex > 0) { 51 window?.WTN?.MediaPlayer?.stopMedia(); 52 currentTrackIndex--; 53 loadTrack(currentTrackIndex); 54 // audio.play(); 55 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 56 $('#wtn-play-pause').text('⏸'); // Update button state 57 isPlaying = true; 58 // alert('Prev track loaded =>' + tracks[currentTrackIndex]?.url); 59 } 60 }); 31 61 32 // Previous Button 33 $('#wtn-prev').on('click', function () { 34 if (currentTrackIndex > 0) { 35 currentTrackIndex--; 36 loadTrack(currentTrackIndex); 37 audio.play(); 38 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 39 $('#wtn-play-pause').text('⏸'); // Update button state 40 } 41 }); 62 // Next Button 63 $('#wtn-next').on('click', function () { 64 if (currentTrackIndex < tracks.length - 1) { 65 window?.WTN?.MediaPlayer?.stopMedia(); 66 currentTrackIndex++; 67 loadTrack(currentTrackIndex); 68 // audio.play(); 69 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 70 $('#wtn-play-pause').text('⏸'); // Update button state 71 isPlaying = true; 72 // alert('Next track loaded =>' + tracks[currentTrackIndex]?.url); 73 } 74 }); 42 75 43 // Next Button 44 $('#wtn-next').on('click', function () { 45 if (currentTrackIndex < tracks.length - 1) { 46 currentTrackIndex++; 47 loadTrack(currentTrackIndex); 48 audio.play(); 49 window?.WTN?.MediaPlayer?.playMedia({ url: tracks[currentTrackIndex]?.url, image: tracks[currentTrackIndex]?.image }); 50 $('#wtn-play-pause').text('⏸'); // Update button state 51 } 52 }); 76 // Hide Prev/Next buttons if only one track is present 77 if (tracks.length === 1) { 78 $('#wtn-prev, #wtn-next').hide(); 79 } 53 80 54 // Hide Prev/Next buttons if only one track is present 55 if (tracks.length === 1) { 56 $('#wtn-prev, #wtn-next').hide(); 57 } 58 59 // Load the initial track without autoplay 60 if (tracks.length > 0) { 61 loadTrack(currentTrackIndex); 62 } 81 // Load the initial track without autoplay 82 if (tracks.length > 0) { 83 loadTrack(currentTrackIndex); 84 } 63 85 })(jQuery); -
webtonative/trunk/webtonative-radio-player/webtonative-radio-player.php
r3216434 r3298119 10 10 function wtn_enqueue_assets() 11 11 { 12 wp_enqueue_style('wtn-player-css', plugin_dir_url(__FILE__) . 'css/player.css ');13 wp_enqueue_script('wtn-player-js', plugin_dir_url(__FILE__) . 'js/player.js ', array('jquery'), null, true);12 wp_enqueue_style('wtn-player-css', plugin_dir_url(__FILE__) . 'css/player.css?ver=1.0.2'); 13 wp_enqueue_script('wtn-player-js', plugin_dir_url(__FILE__) . 'js/player.js?ver=1.0.9', array('jquery'), null, true); 14 14 15 15 // Pass settings to JavaScript … … 55 55 ob_start(); 56 56 ?> 57 <div id="wtn-player" >57 <div id="wtn-player" class="d-none"> 58 58 <div id="track-info"> 59 59 <img id="track-image" src="" alt="Track Image">
Note: See TracChangeset
for help on using the changeset viewer.