Changeset 2233903
- Timestamp:
- 01/27/2020 02:34:31 PM (6 years ago)
- Location:
- wallkit/trunk
- Files:
-
- 4 edited
-
public/js/wallkit-integration-library.js (modified) (11 diffs)
-
public/js/wallkit-integration-library.min.js (modified) (1 diff)
-
vendor/wallkit-php-sdk/src/WallkitClient.php (modified) (4 diffs)
-
wallkit-wp.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wallkit/trunk/public/js/wallkit-integration-library.js
r2157879 r2233903 20 20 var queue = []; 21 21 var callbacks = []; 22 var currentModal = null; 22 23 var helper = (function() { 23 24 return { … … 27 28 addToTopCss: function () { 28 29 const css = '#wk-overlay {' + 29 'display: none;position: ' +30 'fixed;top: 0px;' +31 'left: 0px;' +32 'right: 0px;' +33 'bottom: 0px;' +34 'background: #121214;' +35 'z-index: 300000;' +36 'opacity: 0;' +37 '-webkit-transition: opacity .25s linear;' +38 '-moz-transition: opacity .25s linear;' +39 '-ms-transition: opacity .25s linear;' +40 '-o-transition: opacity .25s linear;' +41 'transition: opacity .25s linear;' +42 '}' +43 '#wk-overlay.wk-active {' +44 'opacity: .9;' +45 'z-index: 300000;' +46 'display: block;' +47 'height: 100%;' +48 '}' +49 '#wk-popup-wrapper {' +50 'overflow-x: hidden;' +51 'overflow-y: auto;' +52 'display: none;' +53 'position: fixed;' +54 'top: 0;' +55 'bottom: 0;' +56 'left: 0;' +57 'right: 0;' +58 'overflow: auto;' +59 '-webkit-overflow-scrolling: touch;' +60 '}' +61 '#wk-popup-wrapper.wk-active {' +62 'z-index: 300050;' +63 'display: block;' +64 '}' +65 '#wk-popup-close-button {' +66 'line-height: 37px;' +67 'position: absolute;' +68 'top: 10px;right: 10px;' +69 'width: 37px;' +70 'height: 37px;' +71 'z-index: 300100;' +72 'opacity: 0;' +73 'cursor: pointer;' +74 'color: #ccc;' +75 'font-family: Arial, sans-serif;' +76 'text-align: center;' +77 '}' +78 '#wk-popup-wrapper.wk-active ' +79 '#wk-popup-close-button {' +80 'display: block;' +81 'font-size: 37px;' +82 'transform: rotateZ(45deg);' +83 'opacity: 1;' +84 '}' +85 '#wk-iframe-wrapper {' +86 'position: relative;' +87 'margin: 40px auto;' +88 'box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);' +89 '}' +90 '@media all and (max-width: 500px) {' +91 '#wk-iframe-wrapper' +92 '{ margin: 0 auto; }' +93 '}' +94 '#wk-popup-wrapper.wk-active ' +95 '#wk-iframe-wrapper {' +96 'transform: scale(1.0, 1.0);' +97 '-moz-transform: scale(1.0, 1.0);' +98 '-ms-transform: scale(1.0, 1.0);' +99 '-webkit-transform: scale(1.0, 1.0);' +100 '-o-transform: scale(1.0, 1.0);' +101 'width: 500px;min-height: 250px;' +102 'max-width: 100%;' +103 '}';30 'display: none;position: ' + 31 'fixed;top: 0px;' + 32 'left: 0px;' + 33 'right: 0px;' + 34 'bottom: 0px;' + 35 'background: #121214;' + 36 'z-index: 300000;' + 37 'opacity: 0;' + 38 '-webkit-transition: opacity .25s linear;' + 39 '-moz-transition: opacity .25s linear;' + 40 '-ms-transition: opacity .25s linear;' + 41 '-o-transition: opacity .25s linear;' + 42 'transition: opacity .25s linear;' + 43 '}' + 44 '#wk-overlay.wk-active {' + 45 'opacity: .9;' + 46 'z-index: 300000;' + 47 'display: block;' + 48 'height: 100%;' + 49 '}' + 50 '#wk-popup-wrapper {' + 51 'overflow-x: hidden;' + 52 'overflow-y: auto;' + 53 'display: none;' + 54 'position: fixed;' + 55 'top: 0;' + 56 'bottom: 0;' + 57 'left: 0;' + 58 'right: 0;' + 59 'overflow: auto;' + 60 '-webkit-overflow-scrolling: touch;' + 61 '}' + 62 '#wk-popup-wrapper.wk-active {' + 63 'z-index: 300050;' + 64 'display: block;' + 65 '}' + 66 '#wk-popup-close-button {' + 67 'line-height: 37px;' + 68 'position: absolute;' + 69 'top: 10px;right: 10px;' + 70 'width: 37px;' + 71 'height: 37px;' + 72 'z-index: 300100;' + 73 'opacity: 0;' + 74 'cursor: pointer;' + 75 'color: #ccc;' + 76 'font-family: Arial, sans-serif;' + 77 'text-align: center;' + 78 '}' + 79 '#wk-popup-wrapper.wk-active ' + 80 '#wk-popup-close-button {' + 81 'display: block;' + 82 'font-size: 37px;' + 83 'transform: rotateZ(45deg);' + 84 'opacity: 1;' + 85 '}' + 86 '#wk-iframe-wrapper {' + 87 'position: relative;' + 88 'margin: 40px auto;' + 89 'box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);' + 90 '}' + 91 '@media all and (max-width: 500px) {' + 92 '#wk-iframe-wrapper' + 93 '{ margin: 0 auto; }' + 94 '}' + 95 '#wk-popup-wrapper.wk-active ' + 96 '#wk-iframe-wrapper {' + 97 'transform: scale(1.0, 1.0);' + 98 '-moz-transform: scale(1.0, 1.0);' + 99 '-ms-transform: scale(1.0, 1.0);' + 100 '-webkit-transform: scale(1.0, 1.0);' + 101 '-o-transform: scale(1.0, 1.0);' + 102 'width: 500px;min-height: 250px;' + 103 'max-width: 100%;' + 104 '}'; 104 105 var head = document.head || document.getElementsByTagName('head')[0]; 105 106 var style = document.createElement('style'); … … 202 203 helper.display(false); 203 204 helper.addClassSlug(false); 205 currentModal = null; 204 206 }, 205 207 … … 282 284 getCookie: function (name) { 283 285 var matches = document.cookie.match(new RegExp( 284 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"286 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 285 287 )); 286 288 return matches ? decodeURIComponent(matches[1]) : undefined; … … 333 335 } 334 336 335 this.dispatchEvent("close" );337 this.dispatchEvent("close", currentModal); 336 338 } 337 339 if(!show && queue.length) … … 473 475 for (var k in callbacks) { 474 476 if( 475 typeof callbacks[k] === "object" &&476 typeof callbacks[k].event !== "undefined" &&477 callbacks[k].event === event &&478 typeof callbacks[k].callback !== "undefined" &&479 typeof callbacks[k].callback === "function"477 typeof callbacks[k] === "object" && 478 typeof callbacks[k].event !== "undefined" && 479 callbacks[k].event === event && 480 typeof callbacks[k].callback !== "undefined" && 481 typeof callbacks[k].callback === "function" 480 482 ) 481 483 { … … 588 590 } 589 591 helper.display(true); 592 currentModal = name; 590 593 } 591 594 }, … … 617 620 on: function(event, callback) { 618 621 callbacks.push({ "event": event, "callback": callback}) 622 }, 623 624 /** 625 * Unsubscribe on hooks 626 * @param event 627 * @param callback 628 */ 629 off: function(event, callback) { 630 for (var i = 0; i < callbacks.length; i++) { 631 if (callbacks[i].event === event && callbacks[i].callback === callback) { 632 callbacks.splice(i, 1); 633 } 634 } 619 635 } 620 636 … … 627 643 628 644 if (event && 629 env.origin.indexOf(event.origin) != -1 &&630 typeof event === "object" &&631 typeof event.data === "object" &&632 typeof event.data.name !== "undefined" &&633 typeof event.data.value !== "undefined") {645 env.origin.indexOf(event.origin) != -1 && 646 typeof event === "object" && 647 typeof event.data === "object" && 648 typeof event.data.name !== "undefined" && 649 typeof event.data.value !== "undefined") { 634 650 helper.log(" <<< ", event.data); 635 651 … … 676 692 677 693 case "wk-event-transaction" : 678 queue.push({"task": {"name": "reload", "value": true}});679 helper.dispatchEvent("transaction");694 queue.push({"task": {"name": "reload", "value": true}}); 695 helper.dispatchEvent("transaction"); 680 696 break; 681 697 … … 724 740 break; 725 741 742 case "wk-event-route-change" : 743 if (event.data.value) { 744 currentModal = event.data.value; 745 helper.dispatchEvent('modal-change', event.data.value); 746 } 747 break; 748 726 749 case "wk-event-modals-ready" : 727 750 if_ready = true; 728 751 try { 729 if (window.ApplePaySession)730 {731 wk.sendEvent("wk-event-applepay-ready", window.ApplePaySession.canMakePayments());732 }733 else734 {735 wk.sendEvent("wk-event-applepay-ready", false);736 }752 if (window.ApplePaySession) 753 { 754 wk.sendEvent("wk-event-applepay-ready", window.ApplePaySession.canMakePayments()); 755 } 756 else 757 { 758 wk.sendEvent("wk-event-applepay-ready", false); 759 } 737 760 } 738 761 catch (e) { 739 console.error("AP. e.", e);762 console.error("AP. e.", e); 740 763 } 741 764 -
wallkit/trunk/public/js/wallkit-integration-library.min.js
r2157879 r2233903 1 !function(e){"use strict";var t;const a={auth_url:"https://wallkit.net/popups",authOrigin:"*",iframeId:"wk-integration",origin:[document.location.origin,"https://wallkit.net","https://dev.wallkit.net","https://wallkit.local"]};var o=!1,n={},i=[],s=[],r= {addToTopCss:function(){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode("#wk-overlay {display: none;position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;background: #121214;z-index: 300000;opacity: 0;-webkit-transition: opacity .25s linear;-moz-transition: opacity .25s linear;-ms-transition: opacity .25s linear;-o-transition: opacity .25s linear;transition: opacity .25s linear;}#wk-overlay.wk-active {opacity: .9;z-index: 300000;display: block;height: 100%;}#wk-popup-wrapper {overflow-x: hidden;overflow-y: auto;display: none;position: fixed;top: 0;bottom: 0;left: 0;right: 0;overflow: auto;-webkit-overflow-scrolling: touch;}#wk-popup-wrapper.wk-active {z-index: 300050;display: block;}#wk-popup-close-button {line-height: 37px;position: absolute;top: 10px;right: 10px;width: 37px;height: 37px;z-index: 300100;opacity: 0;cursor: pointer;color: #ccc;font-family: Arial, sans-serif;text-align: center;}#wk-popup-wrapper.wk-active #wk-popup-close-button {display: block;font-size: 37px;transform: rotateZ(45deg);opacity: 1;}#wk-iframe-wrapper {position: relative;margin: 40px auto;box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);}@media all and (max-width: 500px) {#wk-iframe-wrapper{ margin: 0 auto; }}#wk-popup-wrapper.wk-active #wk-iframe-wrapper {transform: scale(1.0, 1.0);-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);width: 500px;min-height: 250px;max-width: 100%;}")),e.appendChild(t)},log:function(e,t){this.getConf("debug")&&console.log("WPWKP: ",e,t)},createIframe:function(e){var t=this.getConf("auth_url"),o=this.getConf("public_key"),n=this.getConf("api_version");if(void 0===o)throw new Error("wk not configured: public key");if(void 0===t)throw new Error("wk not configured: Auth url");var i=document.getElementById("wk-overlay");i||((i=document.createElement("div")).id="wk-overlay",document.body.appendChild(i));var s=document.getElementById("wk-popup-wrapper");s||((s=document.createElement("div")).id="wk-popup-wrapper",s.onclick=function(){r.closeModal()},document.body.appendChild(s));var d=document.getElementById("wk-iframe-wrapper");d||((d=document.createElement("div")).id="wk-iframe-wrapper",s.appendChild(d));var l=document.getElementById("wk-popup-close-button");l||((l=document.createElement("div")).id="wk-popup-close-button",l.innerText="+",l.onclick=function(){r.closeModal()},d.appendChild(l));var c=document.getElementById(a.iframeId);c||(c=document.createElement("iframe"),null!==e&&e?c.setAttribute("src",t+"/"+e+"/?PUBLIC_KEY="+o+"&api_version="+n):c.setAttribute("src",t+"/?PUBLIC_KEY="+o+"&api_version="+n),c.id=a.iframeId,c.scrolling="no",c.allowtransparency="true",c.frameborder="0",c.style.width="500px",c.style.minHeight="250px",c.style.display="block",c.style.border="0",d.appendChild(c))},closeModal:function(){t.sendEvent("wk-event-modal",!1),r.display(!1),r.addClassSlug(!1)},destroyHtml:function(){var e=document.getElementById("wk-overlay");e&&e.remove();var t=document.getElementById("wk-popup-wrapper");t&&t.remove();var o=document.getElementById("wk-iframe-wrapper");o&&o.remove();var n=document.getElementById("wk-popup-close-button");n&&n.remove();var i=document.getElementById(a.iframeId);i&&i.remove(),r.dispatchEvent("destroy")},setCookie:function(e,t,a){var o=(a=a||{}).expires;if("number"==typeof o&&o){var n=new Date;n.setTime(n.getTime()+1e3*o),o=a.expires=n}o&&o.toUTCString&&(a.expires=o.toUTCString());var i=e+"="+(t=encodeURIComponent(t));for(var s in a){i+="; "+s;var r=a[s];!0!==r&&(i+="="+r)}this.log("Set cookie",i),document.cookie=i},deleteCookie:function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1972 00:00:01 GMT; path=/; domain="+document.location.host},getCookie:function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},display:function(e){var t=document.getElementById("wk-overlay"),o=document.getElementById("wk-popup-wrapper"),n=document.getElementById(a.iframeId);return e?(t&&t.classList.add("wk-active"),o&&o.classList.add("wk-active"),n.style.width="500px",n.style.minHeight="250px",n.style.display="block",n.style.border="0",this.dispatchEvent("open")):(t&&t.classList.remove("wk-active"),o&&o.classList.remove("wk-active"),n&&(n.style.width="0px",n.style.minHeight="0px",n.style.display="none",n.style.border="0"),this.dispatchEvent("close")),!e&&i.length&&this.checkQueue(),e},addClassSlug:function(e){e&&void 0!==e?(document.getElementById("wk-popup-wrapper").classList.add("wk-inner-popup-wrapper-"+e),document.getElementById("wk-iframe-wrapper").classList.add("wk-inner-wrapper-"+e),document.getElementById("wk-overlay").classList.add("wk-inner-overlay-"+e)):(this.removeClassSlugs(document.getElementById("wk-popup-wrapper")),this.removeClassSlugs(document.getElementById("wk-iframe-wrapper")),this.removeClassSlugs(document.getElementById("wk-overlay")))},removeClassSlugs:function(e){e&&e.classList.forEach(function(e){e.indexOf("wk-inner-")>=0&&document.getElementById("wk-popup-wrapper").classList.remove(e)})},checkQueue:function(){if(i.length)for(var e in i){if(void 0!==i[e]&&void 0!==i[e].task&&void 0!==i[e].task.name&&(this.dispatchEvent(i[e].task.name),void 0!==i[e]))switch(i[e].task.name){case"reload":location.reload();break;case"modal":void 0!==i[e].task.value&&wk.sendEvent("wk-event-modal",i[e].task.value,i[e].task.params)}i.splice(e,1)}},flushQueue:function(){i=[]},getConf:function(e){return e&&void 0!==n[e]?n[e]:null},sendPageView:function(e){this.dispatchEvent("page-view");try{var t=new XMLHttpRequest;t.open("POST","https://"+this.getConf("api_host")+"/api/"+this.getConf("api_version")+"/user/event"),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("resource",this.getConf("public_key")),t.setRequestHeader("Wallkit-Client","WPWKP v"+this.getConf("plugin_version")),this.getCookie("wk-token")&&t.setRequestHeader("token",this.getCookie("wk-token"));var a={name:"page_view",value:e};void 0!==window.wk_content_key&&window.wk_content_key&&(a.content_key=window.wk_content_key),t.send(JSON.stringify(a))}catch(e){this.getConf("debug")&&console.error(e)}},dispatchEvent:function(e,t,a){for(var o in s)if("object"==typeof s[o]&&void 0!==s[o].event&&s[o].event===e&&void 0!==s[o].callback&&"function"==typeof s[o].callback)try{s[o].callback(this,t,a)}catch(e){this.getConf("debug")&&console.error(e)}},checkExecUry:function(){var e=/#WkModal\((.*)\)$/.exec(decodeURIComponent(window.location.hash));if(e&&e[1]){var t=e[1].split(",");if(void 0!==t[1]){try{t[1]=JSON.parse(t[1])}catch(e){t[1]={value:t[1]}}setTimeout(function(){wk.modal(t[0],"object"==typeof t[1]?t[1]:null)},500),window.location.hash=""}}}};e.wk={init:function(e){if("object"!=typeof e)throw new Error("wallkit is not configured");return n=e,t=this,r.dispatchEvent("init"),t},isAuth:function(){return void 0!==r.getCookie("wk-token")},sendEvent:function(e,t,o){document.getElementById(a.iframeId).contentWindow.postMessage({name:e,value:t,params:o},a.authOrigin)},modal:function(e,t){"boolean"!=typeof e||e?(r.createIframe(e),r.addClassSlug(e),r.dispatchEvent("modal",e,t),this.sendEvent("wk-event-modal",e,t),o||i.push({task:{name:"modal",value:e,params:t}}),r.display(!0)):r.closeModal()},logout:function(){this.isAuth()&&(this.sendEvent("wk-event-logout",!0),r.display(!1),r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout"),i.length&&setTimeout(function(){location.reload()},2e3))},on:function(e,t){s.push({event:e,callback:t})}},window.addEventListener("message",function(e){if(e&&-1!=a.origin.indexOf(e.origin)&&"object"==typeof e&&"object"==typeof e.data&&void 0!==e.data.name&&void 0!==e.data.value)switch(r.log(" <<< ",e.data),e.data.name){case"wk-event-token":e.data.value&&e.data.value.length&&(r.setCookie("wk-token",e.data.value,{expires:31104e3,path:"/",domain:document.location.host}),r.dispatchEvent("token"));break;case"wk-event-auth":case"wk-event-registration":if(void 0!==e.data.value.token){var t=new Date;t.setTime(1e3*e.data.value.expires),r.setCookie("wk-token",e.data.value.token,{expires:t,path:"/",domain:document.location.host}),i.push({task:{name:"reload",value:!0}}),"wk-event-auth"===e.data.name&&r.dispatchEvent("auth"),"wk-event-registration"===e.data.name&&r.dispatchEvent("registration")}break;case"wk-event-logout":r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout");break;case"wk-event-transaction":i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("transaction");break;case"wk-event-resize":o=!0;var n=e.data.value.width;n<500&&(n=500);var s=e.data.value.height;s<250&&(s=250);var d=document.getElementById(a.iframeId);d.setAttribute("style","-webkit-transition: all 0.3s linear"),d.style.maxWidth="100%",d.style.height=s+"px",d.style.width=n+"px",d.style.border="0";var l=document.getElementById("wk-iframe-wrapper");l.setAttribute("style","-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);"),l.style.transform="scale(1.0, 1.0)",l.style.height=s+"px",l.style.width=n+"px";break;case"wk-event-close-modal":r.display(!1);break;case"wk-event-modal":e.data.value||r.display(!1);break;case"wk-event-reload-page":r.display(!1),location.reload();break;case"wk-event-modals-ready":o=!0;try{window.ApplePaySession?wk.sendEvent("wk-event-applepay-ready",window.ApplePaySession.canMakePayments()):wk.sendEvent("wk-event-applepay-ready",!1)}catch(e){console.error("AP. e.",e)}wk.isAuth()||wk.sendEvent("wk-event-get-token",r.getConf("public_key")),r.dispatchEvent("wk-ready"),r.checkQueue()}}),"complete"===document.readyState||"interactive"===document.readyState?(r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)):document.addEventListener("DOMContentLoaded",function(e){r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)}),"undefined"!=typeof wallkitSettings?wk.init(wallkitSettings):setTimeout(function(){wk.init(wallkitSettings)},1e3),r.checkExecUry()}(this);1 !function(e){"use strict";var t;const a={auth_url:"https://wallkit.net/popups",authOrigin:"*",iframeId:"wk-integration",origin:[document.location.origin,"https://wallkit.net","https://dev.wallkit.net","https://wallkit.local"]};var o=!1,n={},i=[],s=[],r=null,d={addToTopCss:function(){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode("#wk-overlay {display: none;position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;background: #121214;z-index: 300000;opacity: 0;-webkit-transition: opacity .25s linear;-moz-transition: opacity .25s linear;-ms-transition: opacity .25s linear;-o-transition: opacity .25s linear;transition: opacity .25s linear;}#wk-overlay.wk-active {opacity: .9;z-index: 300000;display: block;height: 100%;}#wk-popup-wrapper {overflow-x: hidden;overflow-y: auto;display: none;position: fixed;top: 0;bottom: 0;left: 0;right: 0;overflow: auto;-webkit-overflow-scrolling: touch;}#wk-popup-wrapper.wk-active {z-index: 300050;display: block;}#wk-popup-close-button {line-height: 37px;position: absolute;top: 10px;right: 10px;width: 37px;height: 37px;z-index: 300100;opacity: 0;cursor: pointer;color: #ccc;font-family: Arial, sans-serif;text-align: center;}#wk-popup-wrapper.wk-active #wk-popup-close-button {display: block;font-size: 37px;transform: rotateZ(45deg);opacity: 1;}#wk-iframe-wrapper {position: relative;margin: 40px auto;box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);}@media all and (max-width: 500px) {#wk-iframe-wrapper{ margin: 0 auto; }}#wk-popup-wrapper.wk-active #wk-iframe-wrapper {transform: scale(1.0, 1.0);-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);width: 500px;min-height: 250px;max-width: 100%;}")),e.appendChild(t)},log:function(e,t){this.getConf("debug")&&console.log("WPWKP: ",e,t)},createIframe:function(e){var t=this.getConf("auth_url"),o=this.getConf("public_key"),n=this.getConf("api_version");if(void 0===o)throw new Error("wk not configured: public key");if(void 0===t)throw new Error("wk not configured: Auth url");var i=document.getElementById("wk-overlay");i||((i=document.createElement("div")).id="wk-overlay",document.body.appendChild(i));var s=document.getElementById("wk-popup-wrapper");s||((s=document.createElement("div")).id="wk-popup-wrapper",s.onclick=function(){d.closeModal()},document.body.appendChild(s));var r=document.getElementById("wk-iframe-wrapper");r||((r=document.createElement("div")).id="wk-iframe-wrapper",s.appendChild(r));var l=document.getElementById("wk-popup-close-button");l||((l=document.createElement("div")).id="wk-popup-close-button",l.innerText="+",l.onclick=function(){d.closeModal()},r.appendChild(l));var c=document.getElementById(a.iframeId);c||(c=document.createElement("iframe"),null!==e&&e?c.setAttribute("src",t+"/"+e+"/?PUBLIC_KEY="+o+"&api_version="+n):c.setAttribute("src",t+"/?PUBLIC_KEY="+o+"&api_version="+n),c.id=a.iframeId,c.scrolling="no",c.allowtransparency="true",c.frameborder="0",c.style.width="500px",c.style.minHeight="250px",c.style.display="block",c.style.border="0",r.appendChild(c))},closeModal:function(){t.sendEvent("wk-event-modal",!1),d.display(!1),d.addClassSlug(!1),r=null},destroyHtml:function(){var e=document.getElementById("wk-overlay");e&&e.remove();var t=document.getElementById("wk-popup-wrapper");t&&t.remove();var o=document.getElementById("wk-iframe-wrapper");o&&o.remove();var n=document.getElementById("wk-popup-close-button");n&&n.remove();var i=document.getElementById(a.iframeId);i&&i.remove(),d.dispatchEvent("destroy")},setCookie:function(e,t,a){var o=(a=a||{}).expires;if("number"==typeof o&&o){var n=new Date;n.setTime(n.getTime()+1e3*o),o=a.expires=n}o&&o.toUTCString&&(a.expires=o.toUTCString());var i=e+"="+(t=encodeURIComponent(t));for(var s in a){i+="; "+s;var r=a[s];!0!==r&&(i+="="+r)}this.log("Set cookie",i),document.cookie=i},deleteCookie:function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1972 00:00:01 GMT; path=/; domain="+document.location.host},getCookie:function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},display:function(e){var t=document.getElementById("wk-overlay"),o=document.getElementById("wk-popup-wrapper"),n=document.getElementById(a.iframeId);return e?(t&&t.classList.add("wk-active"),o&&o.classList.add("wk-active"),n.style.width="500px",n.style.minHeight="250px",n.style.display="block",n.style.border="0",this.dispatchEvent("open")):(t&&t.classList.remove("wk-active"),o&&o.classList.remove("wk-active"),n&&(n.style.width="0px",n.style.minHeight="0px",n.style.display="none",n.style.border="0"),this.dispatchEvent("close",r)),!e&&i.length&&this.checkQueue(),e},addClassSlug:function(e){e&&void 0!==e?(document.getElementById("wk-popup-wrapper").classList.add("wk-inner-popup-wrapper-"+e),document.getElementById("wk-iframe-wrapper").classList.add("wk-inner-wrapper-"+e),document.getElementById("wk-overlay").classList.add("wk-inner-overlay-"+e)):(this.removeClassSlugs(document.getElementById("wk-popup-wrapper")),this.removeClassSlugs(document.getElementById("wk-iframe-wrapper")),this.removeClassSlugs(document.getElementById("wk-overlay")))},removeClassSlugs:function(e){e&&e.classList.forEach(function(e){e.indexOf("wk-inner-")>=0&&document.getElementById("wk-popup-wrapper").classList.remove(e)})},checkQueue:function(){if(i.length)for(var e in i){if(void 0!==i[e]&&void 0!==i[e].task&&void 0!==i[e].task.name&&(this.dispatchEvent(i[e].task.name),void 0!==i[e]))switch(i[e].task.name){case"reload":location.reload();break;case"modal":void 0!==i[e].task.value&&wk.sendEvent("wk-event-modal",i[e].task.value,i[e].task.params)}i.splice(e,1)}},flushQueue:function(){i=[]},getConf:function(e){return e&&void 0!==n[e]?n[e]:null},sendPageView:function(e){this.dispatchEvent("page-view");try{var t=new XMLHttpRequest;t.open("POST","https://"+this.getConf("api_host")+"/api/"+this.getConf("api_version")+"/user/event"),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("resource",this.getConf("public_key")),t.setRequestHeader("Wallkit-Client","WPWKP v"+this.getConf("plugin_version")),this.getCookie("wk-token")&&t.setRequestHeader("token",this.getCookie("wk-token"));var a={name:"page_view",value:e};void 0!==window.wk_content_key&&window.wk_content_key&&(a.content_key=window.wk_content_key),t.send(JSON.stringify(a))}catch(e){this.getConf("debug")&&console.error(e)}},dispatchEvent:function(e,t,a){for(var o in s)if("object"==typeof s[o]&&void 0!==s[o].event&&s[o].event===e&&void 0!==s[o].callback&&"function"==typeof s[o].callback)try{s[o].callback(this,t,a)}catch(e){this.getConf("debug")&&console.error(e)}},checkExecUry:function(){var e=/#WkModal\((.*)\)$/.exec(decodeURIComponent(window.location.hash));if(e&&e[1]){var t=e[1].split(",");if(void 0!==t[1]){try{t[1]=JSON.parse(t[1])}catch(e){t[1]={value:t[1]}}setTimeout(function(){wk.modal(t[0],"object"==typeof t[1]?t[1]:null)},500),window.location.hash=""}}}};e.wk={init:function(e){if("object"!=typeof e)throw new Error("wallkit is not configured");return n=e,t=this,d.dispatchEvent("init"),t},isAuth:function(){return void 0!==d.getCookie("wk-token")},sendEvent:function(e,t,o){document.getElementById(a.iframeId).contentWindow.postMessage({name:e,value:t,params:o},a.authOrigin)},modal:function(e,t){"boolean"!=typeof e||e?(d.createIframe(e),d.addClassSlug(e),d.dispatchEvent("modal",e,t),this.sendEvent("wk-event-modal",e,t),o||i.push({task:{name:"modal",value:e,params:t}}),d.display(!0),r=e):d.closeModal()},logout:function(){this.isAuth()&&(this.sendEvent("wk-event-logout",!0),d.display(!1),d.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),d.dispatchEvent("logout"),i.length&&setTimeout(function(){location.reload()},2e3))},on:function(e,t){s.push({event:e,callback:t})},off:function(e,t){for(var a=0;a<s.length;a++)s[a].event===e&&s[a].callback===t&&s.splice(a,1)}},window.addEventListener("message",function(e){if(e&&-1!=a.origin.indexOf(e.origin)&&"object"==typeof e&&"object"==typeof e.data&&void 0!==e.data.name&&void 0!==e.data.value)switch(d.log(" <<< ",e.data),e.data.name){case"wk-event-token":e.data.value&&e.data.value.length&&(d.setCookie("wk-token",e.data.value,{expires:31104e3,path:"/",domain:document.location.host}),d.dispatchEvent("token"));break;case"wk-event-auth":case"wk-event-registration":if(void 0!==e.data.value.token){var t=new Date;t.setTime(1e3*e.data.value.expires),d.setCookie("wk-token",e.data.value.token,{expires:t,path:"/",domain:document.location.host}),i.push({task:{name:"reload",value:!0}}),"wk-event-auth"===e.data.name&&d.dispatchEvent("auth"),"wk-event-registration"===e.data.name&&d.dispatchEvent("registration")}break;case"wk-event-logout":d.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),d.dispatchEvent("logout");break;case"wk-event-transaction":i.push({task:{name:"reload",value:!0}}),d.dispatchEvent("transaction");break;case"wk-event-resize":o=!0;var n=e.data.value.width;n<500&&(n=500);var s=e.data.value.height;s<250&&(s=250);var l=document.getElementById(a.iframeId);l.setAttribute("style","-webkit-transition: all 0.3s linear"),l.style.maxWidth="100%",l.style.height=s+"px",l.style.width=n+"px",l.style.border="0";var c=document.getElementById("wk-iframe-wrapper");c.setAttribute("style","-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);"),c.style.transform="scale(1.0, 1.0)",c.style.height=s+"px",c.style.width=n+"px";break;case"wk-event-close-modal":d.display(!1);break;case"wk-event-modal":e.data.value||d.display(!1);break;case"wk-event-reload-page":d.display(!1),location.reload();break;case"wk-event-route-change":e.data.value&&(r=e.data.value,d.dispatchEvent("modal-change",e.data.value));break;case"wk-event-modals-ready":o=!0;try{window.ApplePaySession?wk.sendEvent("wk-event-applepay-ready",window.ApplePaySession.canMakePayments()):wk.sendEvent("wk-event-applepay-ready",!1)}catch(e){console.error("AP. e.",e)}wk.isAuth()||wk.sendEvent("wk-event-get-token",d.getConf("public_key")),d.dispatchEvent("wk-ready"),d.checkQueue()}}),"complete"===document.readyState||"interactive"===document.readyState?(d.createIframe(null),d.addToTopCss(),d.getConf("send_events")&&d.sendPageView(window.location.pathname)):document.addEventListener("DOMContentLoaded",function(e){d.createIframe(null),d.addToTopCss(),d.getConf("send_events")&&d.sendPageView(window.location.pathname)}),"undefined"!=typeof wallkitSettings?wk.init(wallkitSettings):setTimeout(function(){wk.init(wallkitSettings)},1e3),d.checkExecUry()}(this); -
wallkit/trunk/vendor/wallkit-php-sdk/src/WallkitClient.php
r2166257 r2233903 63 63 { 64 64 $headers = array_merge([ 65 'token' => $this->getTokenValue(),65 'token' => $this->getTokenValue(), 66 66 'resource' => $this->resource, 67 67 ], $headers); … … 110 110 111 111 $options = [ 112 CURLOPT_CUSTOMREQUEST => $method,113 CURLOPT_URL => $url,112 CURLOPT_CUSTOMREQUEST => $method, 113 CURLOPT_URL => $url, 114 114 CURLOPT_CONNECTTIMEOUT => 8, 115 CURLOPT_TIMEOUT => 10,116 CURLOPT_HTTPHEADER => $this->compileHeaders($headers),115 CURLOPT_TIMEOUT => 10, 116 CURLOPT_HTTPHEADER => $this->compileHeaders($headers), 117 117 CURLOPT_RETURNTRANSFER => true, // Follow 301 redirects 118 118 CURLOPT_SSL_VERIFYPEER => false, … … 121 121 122 122 if($method !== "GET") { 123 try {124 $options[CURLOPT_POSTFIELDS] = json_encode($body, JSON_UNESCAPED_UNICODE);123 try { 124 $options[CURLOPT_POSTFIELDS] = json_encode($body, JSON_UNESCAPED_UNICODE); 125 125 } catch(\Exception $exception) { 126 throw new WallkitException("Json encode is failed");127 }126 throw new WallkitException("Json encode is failed"); 127 } 128 128 } 129 129 … … 156 156 */ 157 157 private function utf8ize($mixed) 158 {158 { 159 159 160 160 if(!function_exists("mb_convert_encoding")) { -
wallkit/trunk/wallkit-wp.php
r2166257 r2233903 10 10 * Plugin URI: https://wallkit.net 11 11 * Description: A Plug & Play paid-content system to manage subscribers, gather fees and drive additional content sales. 12 * Version: 1.1.3 612 * Version: 1.1.37 13 13 * Author: Wallkit <dev@wallkit.net> 14 14 * Author URI: https://wallkit.net/ … … 19 19 // If this file is called directly, abort 20 20 if ( ! defined( 'WPINC' ) ) { 21 die;21 die; 22 22 } 23 23 … … 27 27 * Rename this for your plugin and update it as you release new versions. 28 28 */ 29 define( 'WPWKP_VERSION', '1.1.3 6' );29 define( 'WPWKP_VERSION', '1.1.37' ); 30 30 31 31 /** … … 81 81 */ 82 82 function activate_wallkit_wp() { 83 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-activator.php';84 Wallkit_Wp_Activator::activate();83 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-activator.php'; 84 Wallkit_Wp_Activator::activate(); 85 85 } 86 86 … … 90 90 */ 91 91 function deactivate_wallkit_wp() { 92 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-deactivator.php';93 Wallkit_Wp_Deactivator::deactivate();92 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-deactivator.php'; 93 Wallkit_Wp_Deactivator::deactivate(); 94 94 } 95 95 … … 115 115 function run_wallkit_wp(&$WallkitPhpSdk) { 116 116 117 $plugin = new Wallkit_Wp();118 $plugin->run();117 $plugin = new Wallkit_Wp(); 118 $plugin->run(); 119 119 120 120 $WallkitPhpSdk = $plugin->get_wallkit_sdk();
Note: See TracChangeset
for help on using the changeset viewer.