@paynext/sdk 0.0.30 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -8
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -342,5 +342,5 @@
|
|
|
342
342
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
343
343
|
* See the License for the specific language governing permissions and
|
|
344
344
|
* limitations under the License.
|
|
345
|
-
*/function Oc(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}typeof SuppressedError=="function"&&SuppressedError;function Rc(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(r===null)return null;var n=Ci(t,e),i=r.cloneNode();if(delete i.dataset.uidAuto,Object.keys(i.dataset).length!==Object.keys(n.dataset).length)return null;var a=!0;return Object.keys(i.dataset).forEach(function(s){i.dataset[s]!==n.dataset[s]&&(a=!1)}),a?r:null}function qc(t){var e=t.url,r=t.attributes,n=t.onSuccess,i=t.onError,a=Ci(e,r);a.onerror=i,a.onload=n,document.head.insertBefore(a,document.head.firstElementChild)}function Kc(t){var e=t.sdkBaseUrl,r=t.environment,n=Oc(t,["sdkBaseUrl","environment"]),i=e||Fc(r),a=n,s=Object.keys(a).filter(function(u){return typeof a[u]!="undefined"&&a[u]!==null&&a[u]!==""}).reduce(function(u,d){var p=a[d].toString();return d=Bc(d),d.substring(0,4)==="data"||d==="crossorigin"?u.attributes[d]=p:u.queryParams[d]=p,u},{queryParams:{},attributes:{}}),o=s.queryParams,c=s.attributes;return o["merchant-id"]&&o["merchant-id"].indexOf(",")!==-1&&(c["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(i,"?").concat(zc(o)),attributes:c}}function Bc(t){var e=function(r,n){return(n?"-":"")+r.toLowerCase()};return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function zc(t){var e="";return Object.keys(t).forEach(function(r){e.length!==0&&(e+="&"),e+=r+"="+t[r]}),e}function Fc(t){return t==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function Ci(t,e){e===void 0&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach(function(n){r.setAttribute(n,e[n]),n==="data-csp-nonce"&&r.setAttribute("nonce",e["data-csp-nonce"])}),r}function $c(t,e){if(e===void 0&&(e=Promise),ki(t,e),typeof document=="undefined")return e.resolve(null);var r=Kc(t),n=r.url,i=r.attributes,a=i["data-namespace"]||"paypal",s=_i(a);return i["data-js-sdk-library"]||(i["data-js-sdk-library"]="paypal-js"),Rc(n,i)&&s?e.resolve(s):Gc({url:n,attributes:i},e).then(function(){var o=_i(a);if(o)return o;throw new Error("The window.".concat(a," global variable is not available."))})}function Gc(t,e){e===void 0&&(e=Promise),ki(t,e);var r=t.url,n=t.attributes;if(typeof r!="string"||r.length===0)throw new Error("Invalid url.");if(typeof n!="undefined"&&typeof n!="object")throw new Error("Expected attributes to be an object.");return new e(function(i,a){if(typeof document=="undefined")return i();qc({url:r,attributes:n,onSuccess:function(){return i()},onError:function(){var s=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return a(s)}})})}function _i(t){return window[t]}function ki(t,e){if(typeof t!="object"||t===null)throw new Error("Expected an options object.");var r=t.environment;if(r&&r!=="production"&&r!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(typeof e!="undefined"&&typeof e!="function")throw new Error("Expected PromisePonyfill to be a function.")}const Uc={layout:"vertical",tagline:!1,height:40,borderRadius:12};class Hc{constructor(){l(this,"paypal",null)}init(e){return b(this,null,function*(){try{this.paypal=yield $c(e)}catch(r){console.error("failed to load the PayPal JS SDK script",r)}})}render(e,r){return b(this,null,function*(){var n,i;this.paypal&&(yield(i=(n=this.paypal).Buttons)==null?void 0:i.call(n,E({fundingSource:"paypal",style:Uc},r)).render(e))})}}class Ei{constructor(){l(this,"ev",new Sa);l(this,"paypal",new Hc);l(this,"state",{translate:new Nc,checkout:new Mc,transaction:new Dc,styles:new jc});l(this,"checkout",new Vc({state:this.state,service:{ev:this.ev,paypal:this.paypal}}))}clearState(){Object.values(this.state).forEach(e=>e.clearState())}}class Yc{constructor(e){l(this,"parent");l(this,"core",new Ei);this.parent=e}mount(e){return b(this,null,function*(){const r=yield this.core.checkout.mount();this.parent.innerHTML="",this.parent.appendChild(r),this.core.state.checkout.setState(e)})}unmount(){return b(this,null,function*(){this.parent.innerHTML="",this.core.clearState()})}}S.
|
|
345
|
+
*/function Oc(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}typeof SuppressedError=="function"&&SuppressedError;function Rc(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(r===null)return null;var n=Ci(t,e),i=r.cloneNode();if(delete i.dataset.uidAuto,Object.keys(i.dataset).length!==Object.keys(n.dataset).length)return null;var a=!0;return Object.keys(i.dataset).forEach(function(s){i.dataset[s]!==n.dataset[s]&&(a=!1)}),a?r:null}function qc(t){var e=t.url,r=t.attributes,n=t.onSuccess,i=t.onError,a=Ci(e,r);a.onerror=i,a.onload=n,document.head.insertBefore(a,document.head.firstElementChild)}function Kc(t){var e=t.sdkBaseUrl,r=t.environment,n=Oc(t,["sdkBaseUrl","environment"]),i=e||Fc(r),a=n,s=Object.keys(a).filter(function(u){return typeof a[u]!="undefined"&&a[u]!==null&&a[u]!==""}).reduce(function(u,d){var p=a[d].toString();return d=Bc(d),d.substring(0,4)==="data"||d==="crossorigin"?u.attributes[d]=p:u.queryParams[d]=p,u},{queryParams:{},attributes:{}}),o=s.queryParams,c=s.attributes;return o["merchant-id"]&&o["merchant-id"].indexOf(",")!==-1&&(c["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(i,"?").concat(zc(o)),attributes:c}}function Bc(t){var e=function(r,n){return(n?"-":"")+r.toLowerCase()};return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function zc(t){var e="";return Object.keys(t).forEach(function(r){e.length!==0&&(e+="&"),e+=r+"="+t[r]}),e}function Fc(t){return t==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function Ci(t,e){e===void 0&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach(function(n){r.setAttribute(n,e[n]),n==="data-csp-nonce"&&r.setAttribute("nonce",e["data-csp-nonce"])}),r}function $c(t,e){if(e===void 0&&(e=Promise),ki(t,e),typeof document=="undefined")return e.resolve(null);var r=Kc(t),n=r.url,i=r.attributes,a=i["data-namespace"]||"paypal",s=_i(a);return i["data-js-sdk-library"]||(i["data-js-sdk-library"]="paypal-js"),Rc(n,i)&&s?e.resolve(s):Gc({url:n,attributes:i},e).then(function(){var o=_i(a);if(o)return o;throw new Error("The window.".concat(a," global variable is not available."))})}function Gc(t,e){e===void 0&&(e=Promise),ki(t,e);var r=t.url,n=t.attributes;if(typeof r!="string"||r.length===0)throw new Error("Invalid url.");if(typeof n!="undefined"&&typeof n!="object")throw new Error("Expected attributes to be an object.");return new e(function(i,a){if(typeof document=="undefined")return i();qc({url:r,attributes:n,onSuccess:function(){return i()},onError:function(){var s=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return a(s)}})})}function _i(t){return window[t]}function ki(t,e){if(typeof t!="object"||t===null)throw new Error("Expected an options object.");var r=t.environment;if(r&&r!=="production"&&r!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(typeof e!="undefined"&&typeof e!="function")throw new Error("Expected PromisePonyfill to be a function.")}const Uc={layout:"vertical",tagline:!1,height:40,borderRadius:12};class Hc{constructor(){l(this,"paypal",null)}init(e){return b(this,null,function*(){try{this.paypal=yield $c(e)}catch(r){console.error("failed to load the PayPal JS SDK script",r)}})}render(e,r){return b(this,null,function*(){var n,i;this.paypal&&(yield(i=(n=this.paypal).Buttons)==null?void 0:i.call(n,E({fundingSource:"paypal",style:Uc},r)).render(e))})}}class Ei{constructor(){l(this,"ev",new Sa);l(this,"paypal",new Hc);l(this,"state",{translate:new Nc,checkout:new Mc,transaction:new Dc,styles:new jc});l(this,"checkout",new Vc({state:this.state,service:{ev:this.ev,paypal:this.paypal}}))}clearState(){Object.values(this.state).forEach(e=>e.clearState())}}class Yc{constructor(e){l(this,"parent");l(this,"core",new Ei);this.parent=e}mount(e){return b(this,null,function*(){const r=yield this.core.checkout.mount();this.parent.innerHTML="",this.parent.appendChild(r),this.core.state.checkout.setState(e)})}unmount(){return b(this,null,function*(){this.parent.innerHTML="",this.core.clearState()})}}S.Core=Ei,S.PayNextCheckout=Yc,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
346
346
|
//# sourceMappingURL=index.umd.js.map
|