Changeset 2801375
- Timestamp:
- 10/19/2022 06:01:09 PM (3 years ago)
- Location:
- pipe-web-monetization/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (2 diffs)
-
includes/class-pipe-web-monetization.php (modified) (1 diff)
-
pipe-web-monetization.php (modified) (2 diffs)
-
public/js/pipe-web-monetization.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pipe-web-monetization/trunk/README.txt
r2796736 r2801375 5 5 Requires at least: 4.9 6 6 Tested up to: 6.0.2 7 Stable tag: 1.0. 27 Stable tag: 1.0.3 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 46 46 * Fix small issues 47 47 48 = 1.0.3 = 49 * Send tips data to dashboard 50 48 51 == Upgrade Notice == 49 * Fix small issues52 * Send tips data to dashboard 50 53 51 54 == Arbitrary section == -
pipe-web-monetization/trunk/includes/class-pipe-web-monetization.php
r2796736 r2801375 117 117 118 118 ?> 119 <div class="wrap pipe-div">119 <div class="wrap"> 120 120 121 121 <div class="div-main-title"><span><?php echo esc_html( get_admin_page_title() ); ?></span></div> -
pipe-web-monetization/trunk/pipe-web-monetization.php
r2796736 r2801375 16 16 * Plugin URI: http://plugin.pipewebmonetization.com/ 17 17 * Description: Pipe allows you to control who gets paid for your content and connect your payments to an admin dashboard. 18 * Version: 1.0. 218 * Version: 1.0.3 19 19 * Author: Pipe 20 20 * Requires at least: 4.9 … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'PIPE_WEB_MONETIZATION_VERSION', '1.0. 0' );38 define( 'PIPE_WEB_MONETIZATION_VERSION', '1.0.3' ); 39 39 40 40 /** -
pipe-web-monetization/trunk/public/js/pipe-web-monetization.js
r2787294 r2801375 1 1 class Batcher { 2 3 2 transactionsList = []; 4 timeout = 60 * 300;5 pluginId = "" 6 paymentPointer = "" 7 3 timeout = 2000; 4 pluginId = ""; 5 paymentPointer = ""; 6 8 7 setPluginId(value) { 9 this.pluginId = value 8 this.pluginId = value; 10 9 } 11 10 12 11 setPaymentPointer(value) { 13 this.paymentPointer = String(value).trim() 12 this.paymentPointer = String(value).trim(); 14 13 } 15 14 … … 38 37 } 39 38 const totalValue = this.transactionsList.reduce( 40 (previousValue, currentValue) => previousValue + currentValue.value, 0 39 (previousValue, currentValue) => previousValue + currentValue.value, 40 0 41 41 ); 42 42 const data = { 43 "pluginId": this.pluginId, 44 "paymentPointer": this.paymentPointer, 45 "date": new Date().getTime(), 46 "totalValue": totalValue, 47 "transactions": this.transactionsList 48 } 49 await fetch(`https://94w4fmrdq3.execute-api.us-east-1.amazonaws.com/Dev/api/transactions`, { 50 method: 'POST', 51 body: JSON.stringify(data), 52 headers: 43 pluginId: this.pluginId, 44 paymentPointer: this.paymentPointer, 45 date: new Date().getTime(), 46 totalValue: totalValue, 47 transactions: this.transactionsList, 48 }; 49 await fetch( 50 `https://94w4fmrdq3.execute-api.us-east-1.amazonaws.com/Dev/api/transactions`, 53 51 { 54 'Content-Type': 'application/json', 52 method: "POST", 53 body: JSON.stringify(data), 54 headers: { 55 "Content-Type": "application/json", 56 }, 55 57 } 56 });58 ); 57 59 this.transactionsList = []; 58 60 } … … 60 62 61 63 jQuery(function ($) { 62 63 64 function setupMetaTag(pointer) { 64 65 $("head").append(pointer); … … 66 67 67 68 if (!ajax_variables.logged_in) { 68 const pointer = "<meta name='monetization' content='" + $('#monetization').attr('name') + "' />"; 69 setupMetaTag(pointer) 70 setupMonetizationListeners() 69 const pointer = 70 "<meta name='monetization' content='" + 71 $("#monetization").attr("name") + 72 "' />"; 73 setupMetaTag(pointer); 74 setupMonetizationListeners(); 71 75 } 72 73 76 74 77 async function setupMonetizationListeners() { 75 78 const batcher = new Batcher(); 76 79 77 if (!document.monetization) {78 return;79 }80 if (!document.monetization) { 81 return; 82 } 80 83 81 batcher.setPluginId(plugin_options.pwm_plugin_id); 82 batcher.setPaymentPointer(document.querySelector('meta[name="monetization"]').getAttribute('content')); 84 batcher.setPluginId(plugin_options.pwm_plugin_id); 85 batcher.setPaymentPointer( 86 document 87 .querySelector('meta[name="monetization"]') 88 .getAttribute("content") 89 ); 83 90 84 document.monetization.addEventListener( 85 'monetizationprogress', 86 (event) => { 87 batcher.add({ 88 date: new Date().getTime(), 89 value: Number((Number(event.detail.amount) * (10**(-1*event.detail.assetScale))).toFixed(event.detail.assetScale)) 90 }); 91 } 92 ); 93 94 batcher.scheduleFlush(); 91 document.monetization.addEventListener("monetizationprogress", (event) => { 92 batcher.add({ 93 date: new Date().getTime(), 94 value: Number( 95 ( 96 Number(event.detail.amount) * 97 10 ** (-1 * event.detail.assetScale) 98 ).toFixed(event.detail.assetScale) 99 ), 100 }); 101 }); 102 103 document.monetization.addEventListener("tip", (event) => { 104 batcher.add({ 105 date: new Date().getTime(), 106 value: Number( 107 ( 108 Number(event.detail.amount) * 109 10 ** (-1 * event.detail.assetScale) 110 ).toFixed(event.detail.assetScale) 111 ), 112 }); 113 }); 114 115 batcher.scheduleFlush(); 95 116 } 96 117 97 118 function simulateMonetization() { 98 119 if (document.monetization) { 99 const randomGuid = 'c7ff7da9-8a41-4660-98a8-ca4df0176fbe';120 const randomGuid = "c7ff7da9-8a41-4660-98a8-ca4df0176fbe"; 100 121 101 122 const meta = document.querySelector('meta[name="monetization"]'); 102 123 let metaContent = null; 103 124 if (meta) { 104 metaContent = meta.getAttribute( 'content');125 metaContent = meta.getAttribute("content"); 105 126 } 106 127 107 128 if (metaContent) { 108 const resolvedEndpoint = metaContent.replace(/^\$/, 'https://');129 const resolvedEndpoint = metaContent.replace(/^\$/, "https://"); 109 130 110 const monetizationstartEvent = new CustomEvent( 'monetizationstart', {131 const monetizationstartEvent = new CustomEvent("monetizationstart", { 111 132 detail: { 112 133 requestId: randomGuid, 113 134 id: randomGuid, 114 135 metaContent, 115 resolvedEndpoint 116 } 136 resolvedEndpoint, 137 }, 117 138 }); 118 139 119 120 const monetizationprogressEvent = new CustomEvent('monetizationprogress', { 121 detail: { 122 "amount": "200000", 123 "assetCode": "USD", 124 "assetScale": 9 140 const monetizationprogressEvent = new CustomEvent( 141 "monetizationprogress", 142 { 143 detail: { 144 amount: "200000", 145 assetCode: "USD", 146 assetScale: 9, 147 }, 125 148 } 126 });149 ); 127 150 128 151 document.monetization.dispatchEvent(monetizationstartEvent); … … 131 154 setInterval(() => { 132 155 document.monetization.dispatchEvent(monetizationprogressEvent); 133 }, 6000) 134 } 135 else { 136 alert('monetization meta tag is not correctly configured.') 156 }, 6000); 157 } else { 158 alert("monetization meta tag is not correctly configured."); 137 159 } 138 160 } 139 161 } 140 141 162 });
Note: See TracChangeset
for help on using the changeset viewer.