@whop/checkout 0.0.37 → 0.0.39
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/README.md +2 -276
- package/dist/static/checkout/chunk-D7BU562Q.mjs +1 -0
- package/dist/static/checkout/index.cjs +1 -1
- package/dist/static/checkout/index.js +1 -1
- package/dist/static/checkout/index.mjs +1 -1
- package/dist/static/checkout/loader.cjs +1 -1
- package/dist/static/checkout/loader.js +1 -1
- package/dist/static/checkout/loader.mjs +1 -1
- package/dist/static/checkout/react/index.cjs +1 -0
- package/dist/static/checkout/react/index.d.mts +166 -0
- package/dist/static/checkout/react/index.d.ts +166 -0
- package/dist/static/checkout/react/index.js +1 -0
- package/dist/static/checkout/react/index.mjs +1 -0
- package/dist/static/checkout/util-B5tOGbpF.d.mts +130 -0
- package/dist/static/checkout/util-B5tOGbpF.d.ts +130 -0
- package/dist/static/checkout/util.cjs +1 -1
- package/dist/static/checkout/util.d.mts +1 -82
- package/dist/static/checkout/util.d.ts +1 -82
- package/dist/static/checkout/util.js +1 -1
- package/dist/static/checkout/util.mjs +1 -1
- package/package.json +19 -3
- package/dist/static/checkout/chunk-N2KVERZN.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function o(e,r,t,n,o,a,i){try{var u=e[a](i);var c=u.value}catch(e){t(e);return}if(u.done){r(c)}else{Promise.resolve(c).then(n,o)}}function a(e){return function(){var r=this,t=arguments;return new Promise(function(n,a){var i=e.apply(r,t);function u(e){o(i,n,a,u,c,"next",e)}function c(e){o(i,n,a,u,c,"throw",e)}u(undefined)})}}function i(e,r,t){r=s(r);return P(e,A()?Reflect.construct(r,t||[],s(e).constructor):r.apply(e,t))}function u(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function c(e,r,t){if(A()){c=Reflect.construct}else{c=function e(e,r,t){var n=[null];n.push.apply(n,r);var o=Function.bind.apply(e,n);var a=new o;if(t)E(a,t.prototype);return a}}return c.apply(null,arguments)}function l(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function s(e){s=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return s(e)}function f(e,r){if(typeof r!=="function"&&r!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:true,configurable:true}});if(r)E(e,r)}function d(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function v(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function p(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var o=true;var a=false;var i,u;try{for(t=t.call(e);!(o=(i=t.next()).done);o=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){a=true;u=e}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(a)throw u}}return n}function m(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function y(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}n.forEach(function(r){l(e,r,t[r])})}return e}function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function w(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{b(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function g(e,r){if(e==null)return{};var t=O(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function O(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function P(e,r){if(r&&(j(r)==="object"||typeof r==="function")){return r}return n(e)}function E(e,r){E=Object.setPrototypeOf||function e(e,r){e.__proto__=r;return e};return E(e,r)}function _(e,t){return r(e)||p(e,t)||C(e,t)||m()}function k(e){return t(e)||v(e)||C(e)||h()}function j(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function C(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}function S(e){var r=typeof Map==="function"?new Map:undefined;S=function e(e){if(e===null||!d(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof r!=="undefined"){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return c(e,arguments,s(this).constructor)}t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}});return E(t,e)};return S(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function x(e,r){var t,n,o,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=u(0),i["throw"]=u(1),i["return"]=u(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(e){return function(r){return c([e,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(a=0)),a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var R=Object.create;var W=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var L=function(e,r,t){return r in e?W(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t};var V=function(e,r){for(var t in r)W(e,t,{get:r[t],enumerable:!0})},D=function(e,r,t,n){var o=true,a=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":j(r))=="object"||typeof r=="function")try{var u=function(){var o=l.value;!M.call(e,o)&&o!==t&&W(e,o,{get:function(){return r[o]},enumerable:!(n=I(r,o))||n.enumerable})};for(var c=U(r)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)u()}catch(e){a=true;i=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(a){throw i}}}return e};var q=function(e,r,t){return t=e!=null?R(T(e)):{},D(r||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e)},N=function(e){return D(W({},"__esModule",{value:!0}),e)};var z=function(e,r,t){return L(e,(typeof r==="undefined"?"undefined":j(r))!="symbol"?r+"":r,t)};var B={};V(B,{WhopCheckoutEmbed:function(){return ek},accentColorValues:function(){return em},isAccentColor:function(){return eh},useCheckoutEmbedControls:function(){return eC}});module.exports=N(B);var F=q(require("react"));var G=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);z(e,"type","WhopCheckoutError");return e}return r}(S(Error));var $=/*#__PURE__*/function(e){f(r,e);function r(e){u(this,r);var t;t=i(this,r,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);z(t,"name","WhopCheckoutRpcTimeoutError");return t}return r}(G);var H=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);z(e,"name","WhopCheckoutSetEmailError");return e}return r}(G);var J=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);z(e,"name","WhopCheckoutSetAddressError");return e}return r}(G);var K=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);z(e,"name","WhopCheckoutGetAddressError");return e}return r}(G);var Q=["resize","center","complete","state","get-email-result","set-email-result","set-address-result","get-address-result","address-validation-error"];function X(e){return j(e.data)=="object"&&e.data!==null&&"event"in e.data&&Q.includes(e.data.event)}function Y(e,r){return X(e)&&e.data.event===r}var Z=[];function ee(e){return Z[e]||(Z[e]=(e+256).toString(16).slice(1))}function er(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":j(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var r=0;r<16;r++)e[r]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,ee(e[0])+ee(e[1])+ee(e[2])+ee(e[3])+"-"+ee(e[4])+ee(e[5])+"-"+ee(e[6])+ee(e[7])+"-"+ee(e[8])+ee(e[9])+"-"+ee(e[10])+ee(e[11])+ee(e[12])+ee(e[13])+ee(e[14])+ee(e[15])}function et(e,r,t,n){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var a;var i=new URL(e.src).origin,u=er();return(a=e.contentWindow)===null||a===void 0?void 0:a.postMessage(w(y({},r),{__scope:"whop-embedded-checkout",event_id:u}),i),new Promise(function(r,a){var i=setTimeout(function(){a(new $),window.removeEventListener("message",c)},o),c=function(o){if(o.source===e.contentWindow&&Y(o,t)&&o.data.event===t&&o.data.event_id===u){clearTimeout(i),window.removeEventListener("message",c);try{r(n(o.data))}catch(e){a(e)}}};window.addEventListener("message",c)})}function en(e,r){function t(t){t.source===e.contentWindow&&X(t)&&r(t.data)}return window.addEventListener("message",t),function(){window.removeEventListener("message",t)}}function eo(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return a(function(){return x(this,function(n){return[2,et(e,{event:"set-email",email:r},"set-email-result",function(e){if(!e.ok)throw new H(e.error)},t)]})})()}function ea(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return a(function(){return x(this,function(t){return[2,et(e,{event:"get-email"},"get-email-result",function(e){return e.email},r)]})})()}function ei(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return a(function(){return x(this,function(n){return[2,et(e,{event:"set-address",address:r},"set-address-result",function(e){if(!e.ok)throw new J(e.error)},t)]})})()}function eu(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return a(function(){return x(this,function(t){return[2,et(e,{event:"get-address"},"get-address-result",function(e){if(!e.ok)throw new K(e.error);return{address:e.address,isComplete:e.is_complete}},r)]})})()}function ec(e,r){var t;var n=new URL(e.src).origin;(t=e.contentWindow)===null||t===void 0?void 0:t.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)}function el(e,r,t,n,o,a,i,u,c,l,s,f,d,v,p,m){var h,y,b,w,g,O,P;var E=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(E.searchParams.set("h",window.location.origin),r&&E.searchParams.set("theme",r),t&&E.searchParams.set("session",t),o&&E.searchParams.set("hide_price","true"),a&&E.searchParams.set("skip_redirect","true"),s&&E.searchParams.set("hide_submit_button","true"),f&&E.searchParams.set("hide_tos","true"),d&&E.searchParams.set("email.hidden","1"),v&&E.searchParams.set("email.disabled","1"),p&&E.searchParams.set("address.hidden","1"),m&&E.searchParams.set("a",m),i){var k=true,j=false,C=undefined,S=true,A=false,x=undefined;try{for(var R=Object.entries(i).sort(function(e,r){return e[0].localeCompare(r[0])})[Symbol.iterator](),W;!(S=(W=R.next()).done);S=true){var I=_(W.value,2),U=I[0],T=I[1];if(U.startsWith("utm_"))if(Array.isArray(T))try{for(var M=T[Symbol.iterator](),L;!(k=(L=M.next()).done);k=true){var V=L.value;E.searchParams.append(U,V)}}catch(e){j=true;C=e}finally{try{if(!k&&M.return!=null){M.return()}}finally{if(j){throw C}}}else E.searchParams.set(U,T)}}catch(e){A=true;x=e}finally{try{if(!S&&R.return!=null){R.return()}}finally{if(A){throw x}}}}if(u){var D=true,q=false,N=undefined,z=true,B=false,F=undefined;try{for(var G=Object.entries(u)[Symbol.iterator](),$;!(z=($=G.next()).done);z=true){var H=_($.value,2),J=H[0],K=H[1];if(K)try{for(var Q=Object.entries(K)[Symbol.iterator](),X;!(D=(X=Q.next()).done);D=true){var Y=_(X.value,2),Z=Y[0],ee=Y[1];E.searchParams.set("style.".concat(J,".").concat(Z),ee.toString())}}catch(e){q=true;N=e}finally{try{if(!D&&Q.return!=null){Q.return()}}finally{if(q){throw N}}}}}catch(e){B=true;F=e}finally{try{if(!z&&G.return!=null){G.return()}}finally{if(B){throw F}}}}var er=true,et=false,en=undefined;if((c===null||c===void 0?void 0:c.email)&&E.searchParams.set("email",c.email),(c===null||c===void 0?void 0:(h=c.address)===null||h===void 0?void 0:h.name)&&E.searchParams.set("name",c.address.name),(c===null||c===void 0?void 0:(y=c.address)===null||y===void 0?void 0:y.line1)&&E.searchParams.set("address.line1",c.address.line1),(c===null||c===void 0?void 0:(b=c.address)===null||b===void 0?void 0:b.line2)&&E.searchParams.set("address.line2",c.address.line2),(c===null||c===void 0?void 0:(w=c.address)===null||w===void 0?void 0:w.city)&&E.searchParams.set("address.city",c.address.city),(c===null||c===void 0?void 0:(g=c.address)===null||g===void 0?void 0:g.country)&&E.searchParams.set("address.country",c.address.country),(c===null||c===void 0?void 0:(O=c.address)===null||O===void 0?void 0:O.state)&&E.searchParams.set("address.state",c.address.state),(c===null||c===void 0?void 0:(P=c.address)===null||P===void 0?void 0:P.postalCode)&&E.searchParams.set("address.postal_code",c.address.postalCode),l)try{for(var eo=Object.entries(l)[Symbol.iterator](),ea;!(er=(ea=eo.next()).done);er=true){var ei=_(ea.value,2),eu=ei[0],ec=ei[1];ec&&E.searchParams.set("theme.".concat(eu),ec)}}catch(e){et=true;en=e}finally{try{if(!er&&eo.return!=null){eo.return()}}finally{if(et){throw en}}}return E.toString()}var es=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],ef="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";var ed=require("react");function ev(){return function(){}}function ep(){return(0,ed.useSyncExternalStore)(ev,function(){return!0},function(){return!1})}var em=["tomato","red","ruby","crimson","pink","plum","purple","violet","iris","cyan","teal","jade","green","grass","brown","blue","orange","indigo","sky","mint","yellow","amber","lime","lemon","magenta","gold","bronze","gray"];function eh(e){return e?em.includes(e):!1}var ey=require("react"),eb=Symbol("none");function ew(e){var r=(0,ey.useRef)(eb);return r.current===eb&&(r.current=e()),r}var eg=require("react");function eO(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=ew(function(){return el.apply(void 0,k(r))}),o=n.current;return eP.apply(void 0,[o].concat(k(r))),o}function eP(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++){t[n-1]=arguments[n]}var o=_(t,16),a=o[0],i=o[1],u=o[2],c=o[3],l=o[4],s=o[5],f=o[6],d=o[7],v=o[8],p=o[9],m=o[10],h=o[11],y=o[12],b=o[13],w=o[14],g=o[15];var O=(0,eg.useMemo)(function(){return el(a,i,u,void 0,l,s,f,d,v,p,m,h,y,b,w,g)},[a,i,u,l,s,f,d,v,p,m,h,y,b,w,g]);(0,eg.useEffect)(function(){e!==O&&process.env.NODE_ENV==="development"&&console.warn("[WhopCheckoutEmbed] iframeUrl changed from ".concat(e," to ").concat(O,". Updating props on the checkout embed is not supported. Please rerender the component."))},[e,O])}var eE=es.join(" ");var e_=(0,F.forwardRef)(function(e,r){var t=e.planId,n=e.theme,o=e.sessionId,a=e.hidePrice,i=a===void 0?!1:a,u=e.skipRedirect,c=u===void 0?!1:u,l=e.onComplete,s=e.onStateChange,f=e.onAddressValidationError,d=e.utm,v=e.styles,p=e.prefill,m=e.themeOptions,h=e.hideSubmitButton,y=h===void 0?!1:h,b=e.hideTermsAndConditions,w=b===void 0?!1:b,g=e.hideEmail,O=g===void 0?!1:g,P=e.disableEmail,E=P===void 0?!1:P,k=e.hideAddressForm,j=k===void 0?!1:k,C=e.affiliateCode;var S=(0,F.useMemo)(function(){return{accentColor:eh(m===null||m===void 0?void 0:m.accentColor)?m.accentColor:void 0}},[m===null||m===void 0?void 0:m.accentColor]),A=eO(t,n,o,void 0,i,c||!!l,d,v,p,S,y,w,O,E,j,C),x=(0,F.useRef)(null),R=_((0,F.useState)(480),2),W=R[0],I=R[1];if((0,F.useEffect)(function(){var e=x.current;if(e)return en(e,function(r){switch(r.event){case"resize":{I(r.height);break}case"center":{e.scrollIntoView({block:"center",inline:"center"});break}case"complete":{l&&l(r.plan_id,r.receipt_id);break}case"state":{s&&s(r.state);break}case"address-validation-error":{f&&f({error_message:r.error_message,error_code:r.error_code});break}}})},[l,s,f]),r){var U={submit:function(e){x.current&&ec(x.current,e)},getEmail:function(e){if(!x.current)throw new Error("Whop embedded checkout frame not found");return ea(x.current,e)},setEmail:function(e,r){if(!x.current)throw new Error("Whop embedded checkout frame not found");return eo(x.current,e,r)},setAddress:function(e,r){if(!x.current)throw new Error("Whop embedded checkout frame not found");return ei(x.current,e,r)},getAddress:function(e){if(!x.current)throw new Error("Whop embedded checkout frame not found");return eu(x.current,e)}};typeof r=="function"?r(U):r.current=U}return F.default.createElement("iframe",{ref:x,allow:ef,sandbox:eE,title:"Whop Embedded Checkout",src:A!==null&&A!==void 0?A:void 0,style:{border:"none",height:"".concat(W,"px"),width:"100%",overflow:"hidden"}})});e_.displayName="WhopCheckoutEmbedInner";var ek=(0,F.forwardRef)(function(e,r){var t=e.fallback,n=g(e,["fallback"]);return ep()?F.default.createElement(e_,w(y({},n),{ref:r})):t!==null&&t!==void 0?t:null});ek.displayName="WhopCheckoutEmbed";var ej=require("react");function eC(){return(0,ej.useRef)(null)}0&&(module.exports={WhopCheckoutEmbed:WhopCheckoutEmbed,accentColorValues:accentColorValues,isAccentColor:isAccentColor,useCheckoutEmbedControls:useCheckoutEmbedControls});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { MutableRefObject, ReactNode } from 'react';
|
|
3
|
+
import { W as WhopCheckoutSubmitDetails, a as WhopCheckoutAddress, b as WhopCheckoutState, c as WhopEmbeddedCheckoutStyleOptions, d as WhopEmbeddedCheckoutPrefillOptions } from '../util-B5tOGbpF.mjs';
|
|
4
|
+
|
|
5
|
+
declare const accentColorValues: readonly ["tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "cyan", "teal", "jade", "green", "grass", "brown", "blue", "orange", "indigo", "sky", "mint", "yellow", "amber", "lime", "lemon", "magenta", "gold", "bronze", "gray"];
|
|
6
|
+
type AccentColor = (typeof accentColorValues)[number];
|
|
7
|
+
declare function isAccentColor(color?: string): color is AccentColor;
|
|
8
|
+
|
|
9
|
+
interface WhopCheckoutEmbedControls {
|
|
10
|
+
submit: (opts?: WhopCheckoutSubmitDetails) => void;
|
|
11
|
+
getEmail: (timeout?: number) => Promise<string>;
|
|
12
|
+
setEmail: (email: string, timeout?: number) => Promise<void>;
|
|
13
|
+
setAddress: (address: WhopCheckoutAddress, timeout?: number) => Promise<void>;
|
|
14
|
+
getAddress: (timeout?: number) => Promise<{
|
|
15
|
+
address: WhopCheckoutAddress;
|
|
16
|
+
isComplete: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface WhopCheckoutEmbedThemeOptions {
|
|
21
|
+
/**
|
|
22
|
+
* **Optional** - The accent color you want to use in the embed.
|
|
23
|
+
*
|
|
24
|
+
* defaults to `blue`
|
|
25
|
+
*/
|
|
26
|
+
accentColor?: AccentColor;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface WhopCheckoutEmbedProps {
|
|
30
|
+
/**
|
|
31
|
+
* **Required** - The plan id you want to checkout.
|
|
32
|
+
*/
|
|
33
|
+
planId: string;
|
|
34
|
+
/**
|
|
35
|
+
* **Optional** - A ref to the embed controls.
|
|
36
|
+
*
|
|
37
|
+
* This can be used to submit the checkout form.
|
|
38
|
+
*/
|
|
39
|
+
ref?: MutableRefObject<WhopCheckoutEmbedControls | null>;
|
|
40
|
+
/**
|
|
41
|
+
* **Optional** - The theme you want to use for the checkout.
|
|
42
|
+
*
|
|
43
|
+
* Possible values are `light`, `dark` or `system`.
|
|
44
|
+
*
|
|
45
|
+
* @default "system"
|
|
46
|
+
*/
|
|
47
|
+
theme?: "light" | "dark" | "system";
|
|
48
|
+
/**
|
|
49
|
+
* **Optional** - The session id to use for the checkout.
|
|
50
|
+
*
|
|
51
|
+
* This can be used to attach metadata to a checkout by first creating a session through the API and then passing the session id to the checkout element.
|
|
52
|
+
*/
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* **Optional** - Turn on to hide the price in the embedded checkout form.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
hidePrice?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* **Optional** - Set to `true` to skip the final redirect and keep the top frame loaded.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
skipRedirect?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* **Optional** - A callback function that will be called when the checkout is complete.
|
|
68
|
+
*/
|
|
69
|
+
onComplete?: (
|
|
70
|
+
/** The plan id of the plan that was purchased. */
|
|
71
|
+
plan_id: string,
|
|
72
|
+
/** The receipt id of the purchase. */
|
|
73
|
+
receipt_id?: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* **Optional** - A callback function that will be called when the checkout state changes.
|
|
76
|
+
*/
|
|
77
|
+
onStateChange?: (
|
|
78
|
+
/** The new state of the checkout. */
|
|
79
|
+
state: WhopCheckoutState) => void;
|
|
80
|
+
/**
|
|
81
|
+
* **Optional** - A callback function that will be called when the address validation error occurs.
|
|
82
|
+
*/
|
|
83
|
+
onAddressValidationError?: (error: {
|
|
84
|
+
/** The error message of the address validation error. */
|
|
85
|
+
error_message: string;
|
|
86
|
+
/** The error code of the address validation error. */
|
|
87
|
+
error_code: string;
|
|
88
|
+
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* **Optional** - The UTM parameters to add to the checkout URL.
|
|
91
|
+
*
|
|
92
|
+
* **Note** - The keys must start with `utm_`
|
|
93
|
+
*/
|
|
94
|
+
utm?: Record<string, string | string[]>;
|
|
95
|
+
/**
|
|
96
|
+
* **Optional** - The styles to apply to the checkout embed.
|
|
97
|
+
*/
|
|
98
|
+
styles?: WhopEmbeddedCheckoutStyleOptions;
|
|
99
|
+
/**
|
|
100
|
+
* **Optional** - The prefill options to apply to the checkout embed.
|
|
101
|
+
*
|
|
102
|
+
* Used to prefill the email in the embedded checkout form.
|
|
103
|
+
* This setting can be helpful when integrating the embed into a funnel that collects the email prior to payment already.
|
|
104
|
+
*/
|
|
105
|
+
prefill?: WhopEmbeddedCheckoutPrefillOptions;
|
|
106
|
+
/**
|
|
107
|
+
* **Optional** - The theme options to apply to the checkout embed.
|
|
108
|
+
*/
|
|
109
|
+
themeOptions?: WhopCheckoutEmbedThemeOptions;
|
|
110
|
+
/**
|
|
111
|
+
* **Optional** - Set to `true` to hide the submit button in the embedded checkout form.
|
|
112
|
+
*
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
hideSubmitButton?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* **Optional** - Set to `true` to hide the terms and conditions in the embedded checkout form.
|
|
118
|
+
*
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
hideTermsAndConditions?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* **Optional** - Set to `true` to hide the email input in the embedded checkout form.
|
|
124
|
+
*
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
hideEmail?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* **Optional** - Set to `true` to disable the email input in the embedded checkout form.
|
|
130
|
+
*
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
disableEmail?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* **Optional** - Set to `true` to hide the address form in the embedded checkout form.
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
hideAddressForm?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* **Optional** - The affiliate code to use for the checkout.
|
|
142
|
+
*/
|
|
143
|
+
affiliateCode?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* This component can be used to embed whop checkout in your react app:
|
|
148
|
+
*
|
|
149
|
+
* ```tsx
|
|
150
|
+
* import { WhopCheckoutEmbed } from "@whop/react/checkout";
|
|
151
|
+
*
|
|
152
|
+
* export default function Home() {
|
|
153
|
+
* return <WhopCheckoutEmbed planId="plan_XXXXXXXXX" />;
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare const WhopCheckoutEmbed: React__default.ForwardRefExoticComponent<Omit<WhopCheckoutEmbedProps & {
|
|
158
|
+
/**
|
|
159
|
+
* **Optional** - The fallback content to show while the checkout is loading.
|
|
160
|
+
*/
|
|
161
|
+
fallback?: ReactNode;
|
|
162
|
+
}, "ref"> & React__default.RefAttributes<WhopCheckoutEmbedControls>>;
|
|
163
|
+
|
|
164
|
+
declare function useCheckoutEmbedControls(): React.RefObject<WhopCheckoutEmbedControls>;
|
|
165
|
+
|
|
166
|
+
export { type AccentColor, WhopCheckoutEmbed, type WhopCheckoutEmbedProps, type WhopCheckoutEmbedThemeOptions, WhopEmbeddedCheckoutPrefillOptions, WhopEmbeddedCheckoutStyleOptions, accentColorValues, isAccentColor, useCheckoutEmbedControls };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { MutableRefObject, ReactNode } from 'react';
|
|
3
|
+
import { W as WhopCheckoutSubmitDetails, a as WhopCheckoutAddress, b as WhopCheckoutState, c as WhopEmbeddedCheckoutStyleOptions, d as WhopEmbeddedCheckoutPrefillOptions } from '../util-B5tOGbpF.js';
|
|
4
|
+
|
|
5
|
+
declare const accentColorValues: readonly ["tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "cyan", "teal", "jade", "green", "grass", "brown", "blue", "orange", "indigo", "sky", "mint", "yellow", "amber", "lime", "lemon", "magenta", "gold", "bronze", "gray"];
|
|
6
|
+
type AccentColor = (typeof accentColorValues)[number];
|
|
7
|
+
declare function isAccentColor(color?: string): color is AccentColor;
|
|
8
|
+
|
|
9
|
+
interface WhopCheckoutEmbedControls {
|
|
10
|
+
submit: (opts?: WhopCheckoutSubmitDetails) => void;
|
|
11
|
+
getEmail: (timeout?: number) => Promise<string>;
|
|
12
|
+
setEmail: (email: string, timeout?: number) => Promise<void>;
|
|
13
|
+
setAddress: (address: WhopCheckoutAddress, timeout?: number) => Promise<void>;
|
|
14
|
+
getAddress: (timeout?: number) => Promise<{
|
|
15
|
+
address: WhopCheckoutAddress;
|
|
16
|
+
isComplete: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface WhopCheckoutEmbedThemeOptions {
|
|
21
|
+
/**
|
|
22
|
+
* **Optional** - The accent color you want to use in the embed.
|
|
23
|
+
*
|
|
24
|
+
* defaults to `blue`
|
|
25
|
+
*/
|
|
26
|
+
accentColor?: AccentColor;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface WhopCheckoutEmbedProps {
|
|
30
|
+
/**
|
|
31
|
+
* **Required** - The plan id you want to checkout.
|
|
32
|
+
*/
|
|
33
|
+
planId: string;
|
|
34
|
+
/**
|
|
35
|
+
* **Optional** - A ref to the embed controls.
|
|
36
|
+
*
|
|
37
|
+
* This can be used to submit the checkout form.
|
|
38
|
+
*/
|
|
39
|
+
ref?: MutableRefObject<WhopCheckoutEmbedControls | null>;
|
|
40
|
+
/**
|
|
41
|
+
* **Optional** - The theme you want to use for the checkout.
|
|
42
|
+
*
|
|
43
|
+
* Possible values are `light`, `dark` or `system`.
|
|
44
|
+
*
|
|
45
|
+
* @default "system"
|
|
46
|
+
*/
|
|
47
|
+
theme?: "light" | "dark" | "system";
|
|
48
|
+
/**
|
|
49
|
+
* **Optional** - The session id to use for the checkout.
|
|
50
|
+
*
|
|
51
|
+
* This can be used to attach metadata to a checkout by first creating a session through the API and then passing the session id to the checkout element.
|
|
52
|
+
*/
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* **Optional** - Turn on to hide the price in the embedded checkout form.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
hidePrice?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* **Optional** - Set to `true` to skip the final redirect and keep the top frame loaded.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
skipRedirect?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* **Optional** - A callback function that will be called when the checkout is complete.
|
|
68
|
+
*/
|
|
69
|
+
onComplete?: (
|
|
70
|
+
/** The plan id of the plan that was purchased. */
|
|
71
|
+
plan_id: string,
|
|
72
|
+
/** The receipt id of the purchase. */
|
|
73
|
+
receipt_id?: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* **Optional** - A callback function that will be called when the checkout state changes.
|
|
76
|
+
*/
|
|
77
|
+
onStateChange?: (
|
|
78
|
+
/** The new state of the checkout. */
|
|
79
|
+
state: WhopCheckoutState) => void;
|
|
80
|
+
/**
|
|
81
|
+
* **Optional** - A callback function that will be called when the address validation error occurs.
|
|
82
|
+
*/
|
|
83
|
+
onAddressValidationError?: (error: {
|
|
84
|
+
/** The error message of the address validation error. */
|
|
85
|
+
error_message: string;
|
|
86
|
+
/** The error code of the address validation error. */
|
|
87
|
+
error_code: string;
|
|
88
|
+
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* **Optional** - The UTM parameters to add to the checkout URL.
|
|
91
|
+
*
|
|
92
|
+
* **Note** - The keys must start with `utm_`
|
|
93
|
+
*/
|
|
94
|
+
utm?: Record<string, string | string[]>;
|
|
95
|
+
/**
|
|
96
|
+
* **Optional** - The styles to apply to the checkout embed.
|
|
97
|
+
*/
|
|
98
|
+
styles?: WhopEmbeddedCheckoutStyleOptions;
|
|
99
|
+
/**
|
|
100
|
+
* **Optional** - The prefill options to apply to the checkout embed.
|
|
101
|
+
*
|
|
102
|
+
* Used to prefill the email in the embedded checkout form.
|
|
103
|
+
* This setting can be helpful when integrating the embed into a funnel that collects the email prior to payment already.
|
|
104
|
+
*/
|
|
105
|
+
prefill?: WhopEmbeddedCheckoutPrefillOptions;
|
|
106
|
+
/**
|
|
107
|
+
* **Optional** - The theme options to apply to the checkout embed.
|
|
108
|
+
*/
|
|
109
|
+
themeOptions?: WhopCheckoutEmbedThemeOptions;
|
|
110
|
+
/**
|
|
111
|
+
* **Optional** - Set to `true` to hide the submit button in the embedded checkout form.
|
|
112
|
+
*
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
hideSubmitButton?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* **Optional** - Set to `true` to hide the terms and conditions in the embedded checkout form.
|
|
118
|
+
*
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
hideTermsAndConditions?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* **Optional** - Set to `true` to hide the email input in the embedded checkout form.
|
|
124
|
+
*
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
hideEmail?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* **Optional** - Set to `true` to disable the email input in the embedded checkout form.
|
|
130
|
+
*
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
disableEmail?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* **Optional** - Set to `true` to hide the address form in the embedded checkout form.
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
hideAddressForm?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* **Optional** - The affiliate code to use for the checkout.
|
|
142
|
+
*/
|
|
143
|
+
affiliateCode?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* This component can be used to embed whop checkout in your react app:
|
|
148
|
+
*
|
|
149
|
+
* ```tsx
|
|
150
|
+
* import { WhopCheckoutEmbed } from "@whop/react/checkout";
|
|
151
|
+
*
|
|
152
|
+
* export default function Home() {
|
|
153
|
+
* return <WhopCheckoutEmbed planId="plan_XXXXXXXXX" />;
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare const WhopCheckoutEmbed: React__default.ForwardRefExoticComponent<Omit<WhopCheckoutEmbedProps & {
|
|
158
|
+
/**
|
|
159
|
+
* **Optional** - The fallback content to show while the checkout is loading.
|
|
160
|
+
*/
|
|
161
|
+
fallback?: ReactNode;
|
|
162
|
+
}, "ref"> & React__default.RefAttributes<WhopCheckoutEmbedControls>>;
|
|
163
|
+
|
|
164
|
+
declare function useCheckoutEmbedControls(): React.RefObject<WhopCheckoutEmbedControls>;
|
|
165
|
+
|
|
166
|
+
export { type AccentColor, WhopCheckoutEmbed, type WhopCheckoutEmbedProps, type WhopCheckoutEmbedThemeOptions, WhopEmbeddedCheckoutPrefillOptions, WhopEmbeddedCheckoutStyleOptions, accentColorValues, isAccentColor, useCheckoutEmbedControls };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function o(e,r,t,n,o,a,i){try{var u=e[a](i);var c=u.value}catch(e){t(e);return}if(u.done){r(c)}else{Promise.resolve(c).then(n,o)}}function a(e){return function(){var r=this,t=arguments;return new Promise(function(n,a){var i=e.apply(r,t);function u(e){o(i,n,a,u,c,"next",e)}function c(e){o(i,n,a,u,c,"throw",e)}u(undefined)})}}function i(e,r,t){r=s(r);return P(e,C()?Reflect.construct(r,t||[],s(e).constructor):r.apply(e,t))}function u(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function c(e,r,t){if(C()){c=Reflect.construct}else{c=function e(e,r,t){var n=[null];n.push.apply(n,r);var o=Function.bind.apply(e,n);var a=new o;if(t)_(a,t.prototype);return a}}return c.apply(null,arguments)}function l(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function s(e){s=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return s(e)}function f(e,r){if(typeof r!=="function"&&r!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:true,configurable:true}});if(r)_(e,r)}function d(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function v(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function p(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var o=true;var a=false;var i,u;try{for(t=t.call(e);!(o=(i=t.next()).done);o=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){a=true;u=e}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(a)throw u}}return n}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}n.forEach(function(r){l(e,r,t[r])})}return e}function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function w(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{b(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function g(e,r){if(e==null)return{};var t=O(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function O(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function P(e,r){if(r&&(k(r)==="object"||typeof r==="function")){return r}return n(e)}function _(e,r){_=Object.setPrototypeOf||function e(e,r){e.__proto__=r;return e};return _(e,r)}function E(e,t){return r(e)||p(e,t)||S(e,t)||y()}function j(e){return t(e)||v(e)||S(e)||h()}function k(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function S(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}function x(e){var r=typeof Map==="function"?new Map:undefined;x=function e(e){if(e===null||!d(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof r!=="undefined"){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return c(e,arguments,s(this).constructor)}t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}});return _(t,e)};return x(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}function R(e,r){var t,n,o,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=u(0),i["throw"]=u(1),i["return"]=u(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(e){return function(r){return c([e,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(a=0)),a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}(function(){var e=function e(e){return k(e.data)=="object"&&e.data!==null&&"event"in e.data&&J.includes(e.data.event)};var r=function r(r,t){return e(r)&&r.data.event===t};var t=function e(e){return K[e]||(K[e]=(e+256).toString(16).slice(1))};var n=function e(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":k(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var r=0;r<16;r++)e[r]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,t(e[0])+t(e[1])+t(e[2])+t(e[3])+"-"+t(e[4])+t(e[5])+"-"+t(e[6])+t(e[7])+"-"+t(e[8])+t(e[9])+"-"+t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15])};var o=function e(e,t,o,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var u;var c=new URL(e.src).origin,l=n();return(u=e.contentWindow)===null||u===void 0?void 0:u.postMessage(w(m({},t),{__scope:"whop-embedded-checkout",event_id:l}),c),new Promise(function(t,n){var u=setTimeout(function(){n(new F),window.removeEventListener("message",c)},i),c=function(i){if(i.source===e.contentWindow&&r(i,o)&&i.data.event===o&&i.data.event_id===l){clearTimeout(u),window.removeEventListener("message",c);try{t(a(i.data))}catch(e){n(e)}}};window.addEventListener("message",c)})};var c=function r(r,t){function n(n){n.source===r.contentWindow&&e(n)&&t(n.data)}return window.addEventListener("message",n),function(){window.removeEventListener("message",n)}};var l=function e(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return a(function(){return R(this,function(n){return[2,o(e,{event:"set-email",email:r},"set-email-result",function(e){if(!e.ok)throw new G(e.error)},t)]})})()};var s=function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return a(function(){return R(this,function(t){return[2,o(e,{event:"get-email"},"get-email-result",function(e){return e.email},r)]})})()};var d=function e(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return a(function(){return R(this,function(n){return[2,o(e,{event:"set-address",address:r},"set-address-result",function(e){if(!e.ok)throw new $(e.error)},t)]})})()};var v=function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return a(function(){return R(this,function(t){return[2,o(e,{event:"get-address"},"get-address-result",function(e){if(!e.ok)throw new H(e.error);return{address:e.address,isComplete:e.is_complete}},r)]})})()};var p=function e(e,r){var t;var n=new URL(e.src).origin;(t=e.contentWindow)===null||t===void 0?void 0:t.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)};var y=function e(e,r,t,n,o,a,i,u,c,l,s,f,d,v,p,y){var h,m,b,w,g,O,P;var _=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(_.searchParams.set("h",window.location.origin),r&&_.searchParams.set("theme",r),t&&_.searchParams.set("session",t),o&&_.searchParams.set("hide_price","true"),a&&_.searchParams.set("skip_redirect","true"),s&&_.searchParams.set("hide_submit_button","true"),f&&_.searchParams.set("hide_tos","true"),d&&_.searchParams.set("email.hidden","1"),v&&_.searchParams.set("email.disabled","1"),p&&_.searchParams.set("address.hidden","1"),y&&_.searchParams.set("a",y),i){var j=true,k=false,S=undefined,x=true,C=false,R=undefined;try{for(var A=Object.entries(i).sort(function(e,r){return e[0].localeCompare(r[0])})[Symbol.iterator](),W;!(x=(W=A.next()).done);x=true){var I=E(W.value,2),U=I[0],q=I[1];if(U.startsWith("utm_"))if(Array.isArray(q))try{for(var T=q[Symbol.iterator](),M;!(j=(M=T.next()).done);j=true){var D=M.value;_.searchParams.append(U,D)}}catch(e){k=true;S=e}finally{try{if(!j&&T.return!=null){T.return()}}finally{if(k){throw S}}}else _.searchParams.set(U,q)}}catch(e){C=true;R=e}finally{try{if(!x&&A.return!=null){A.return()}}finally{if(C){throw R}}}}if(u){var L=true,N=false,V=undefined,z=true,B=false,F=undefined;try{for(var G=Object.entries(u)[Symbol.iterator](),$;!(z=($=G.next()).done);z=true){var H=E($.value,2),J=H[0],K=H[1];if(K)try{for(var Q=Object.entries(K)[Symbol.iterator](),X;!(L=(X=Q.next()).done);L=true){var Y=E(X.value,2),Z=Y[0],ee=Y[1];_.searchParams.set("style.".concat(J,".").concat(Z),ee.toString())}}catch(e){N=true;V=e}finally{try{if(!L&&Q.return!=null){Q.return()}}finally{if(N){throw V}}}}}catch(e){B=true;F=e}finally{try{if(!z&&G.return!=null){G.return()}}finally{if(B){throw F}}}}var er=true,et=false,en=undefined;if((c===null||c===void 0?void 0:c.email)&&_.searchParams.set("email",c.email),(c===null||c===void 0?void 0:(h=c.address)===null||h===void 0?void 0:h.name)&&_.searchParams.set("name",c.address.name),(c===null||c===void 0?void 0:(m=c.address)===null||m===void 0?void 0:m.line1)&&_.searchParams.set("address.line1",c.address.line1),(c===null||c===void 0?void 0:(b=c.address)===null||b===void 0?void 0:b.line2)&&_.searchParams.set("address.line2",c.address.line2),(c===null||c===void 0?void 0:(w=c.address)===null||w===void 0?void 0:w.city)&&_.searchParams.set("address.city",c.address.city),(c===null||c===void 0?void 0:(g=c.address)===null||g===void 0?void 0:g.country)&&_.searchParams.set("address.country",c.address.country),(c===null||c===void 0?void 0:(O=c.address)===null||O===void 0?void 0:O.state)&&_.searchParams.set("address.state",c.address.state),(c===null||c===void 0?void 0:(P=c.address)===null||P===void 0?void 0:P.postalCode)&&_.searchParams.set("address.postal_code",c.address.postalCode),l)try{for(var eo=Object.entries(l)[Symbol.iterator](),ea;!(er=(ea=eo.next()).done);er=true){var ei=E(ea.value,2),eu=ei[0],ec=ei[1];ec&&_.searchParams.set("theme.".concat(eu),ec)}}catch(e){et=true;en=e}finally{try{if(!er&&eo.return!=null){eo.return()}}finally{if(et){throw en}}}return _.toString()};var h=function e(){return function(){}};var b=function e(){return(0,Y.useSyncExternalStore)(h,function(){return!0},function(){return!1})};var O=function e(e){return e?Z.includes(e):!1};var P=function e(e){var r=(0,ee.useRef)(er);return r.current===er&&(r.current=e()),r};var _=function e(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=P(function(){return y.apply(void 0,j(r))}),o=n.current;return S.apply(void 0,[o].concat(j(r))),o};var S=function e(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++){t[n-1]=arguments[n]}var o=E(t,16),a=o[0],i=o[1],u=o[2],c=o[3],l=o[4],s=o[5],f=o[6],d=o[7],v=o[8],p=o[9],h=o[10],m=o[11],b=o[12],w=o[13],g=o[14],O=o[15];var P=(0,et.useMemo)(function(){return y(a,i,u,void 0,l,s,f,d,v,p,h,m,b,w,g,O)},[a,i,u,l,s,f,d,v,p,h,m,b,w,g,O]);(0,et.useEffect)(function(){e!==P&&process.env.NODE_ENV==="development"&&console.warn("[WhopCheckoutEmbed] iframeUrl changed from ".concat(e," to ").concat(P,". Updating props on the checkout embed is not supported. Please rerender the component."))},[e,P])};var C=function e(){return(0,ei.useRef)(null)};var A=Object.create;var W=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var M=function(e,r,t){return r in e?W(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t};var D=function(e){return(typeof require==="undefined"?"undefined":k(require))<"u"?require:(typeof Proxy==="undefined"?"undefined":k(Proxy))<"u"?new Proxy(e,{get:function(e,r){return((typeof require==="undefined"?"undefined":k(require))<"u"?require:e)[r]}}):e}(function(e){if((typeof require==="undefined"?"undefined":k(require))<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var L=function(e,r,t,n){var o=true,a=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":k(r))=="object"||typeof r=="function")try{var u=function(){var o=l.value;!T.call(e,o)&&o!==t&&W(e,o,{get:function(){return r[o]},enumerable:!(n=I(r,o))||n.enumerable})};for(var c=U(r)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)u()}catch(e){a=true;i=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(a){throw i}}}return e};var N=function(e,r,t){return t=e!=null?A(q(e)):{},L(r||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e)};var V=function(e,r,t){return M(e,(typeof r==="undefined"?"undefined":k(r))!="symbol"?r+"":r,t)};var z=N(D("react"));var B=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);V(e,"type","WhopCheckoutError");return e}return r}(x(Error));var F=/*#__PURE__*/function(e){f(r,e);function r(e){u(this,r);var t;t=i(this,r,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);V(t,"name","WhopCheckoutRpcTimeoutError");return t}return r}(B);var G=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);V(e,"name","WhopCheckoutSetEmailError");return e}return r}(B);var $=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);V(e,"name","WhopCheckoutSetAddressError");return e}return r}(B);var H=/*#__PURE__*/function(e){f(r,e);function r(){u(this,r);var e;e=i(this,r,arguments);V(e,"name","WhopCheckoutGetAddressError");return e}return r}(B);var J=["resize","center","complete","state","get-email-result","set-email-result","set-address-result","get-address-result","address-validation-error"];var K=[];var Q=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],X="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";var Y=D("react");var Z=["tomato","red","ruby","crimson","pink","plum","purple","violet","iris","cyan","teal","jade","green","grass","brown","blue","orange","indigo","sky","mint","yellow","amber","lime","lemon","magenta","gold","bronze","gray"];var ee=D("react"),er=Symbol("none");var et=D("react");var en=Q.join(" ");var eo=(0,z.forwardRef)(function(e,r){var t=e.planId,n=e.theme,o=e.sessionId,a=e.hidePrice,i=a===void 0?!1:a,u=e.skipRedirect,f=u===void 0?!1:u,y=e.onComplete,h=e.onStateChange,m=e.onAddressValidationError,b=e.utm,w=e.styles,g=e.prefill,P=e.themeOptions,j=e.hideSubmitButton,k=j===void 0?!1:j,S=e.hideTermsAndConditions,x=S===void 0?!1:S,C=e.hideEmail,R=C===void 0?!1:C,A=e.disableEmail,W=A===void 0?!1:A,I=e.hideAddressForm,U=I===void 0?!1:I,q=e.affiliateCode;var T=(0,z.useMemo)(function(){return{accentColor:O(P===null||P===void 0?void 0:P.accentColor)?P.accentColor:void 0}},[P===null||P===void 0?void 0:P.accentColor]),M=_(t,n,o,void 0,i,f||!!y,b,w,g,T,k,x,R,W,U,q),D=(0,z.useRef)(null),L=E((0,z.useState)(480),2),N=L[0],V=L[1];if((0,z.useEffect)(function(){var e=D.current;if(e)return c(e,function(r){switch(r.event){case"resize":{V(r.height);break}case"center":{e.scrollIntoView({block:"center",inline:"center"});break}case"complete":{y&&y(r.plan_id,r.receipt_id);break}case"state":{h&&h(r.state);break}case"address-validation-error":{m&&m({error_message:r.error_message,error_code:r.error_code});break}}})},[y,h,m]),r){var B={submit:function(e){D.current&&p(D.current,e)},getEmail:function(e){if(!D.current)throw new Error("Whop embedded checkout frame not found");return s(D.current,e)},setEmail:function(e,r){if(!D.current)throw new Error("Whop embedded checkout frame not found");return l(D.current,e,r)},setAddress:function(e,r){if(!D.current)throw new Error("Whop embedded checkout frame not found");return d(D.current,e,r)},getAddress:function(e){if(!D.current)throw new Error("Whop embedded checkout frame not found");return v(D.current,e)}};typeof r=="function"?r(B):r.current=B}return z.default.createElement("iframe",{ref:D,allow:X,sandbox:en,title:"Whop Embedded Checkout",src:M!==null&&M!==void 0?M:void 0,style:{border:"none",height:"".concat(N,"px"),width:"100%",overflow:"hidden"}})});eo.displayName="WhopCheckoutEmbedInner";var ea=(0,z.forwardRef)(function(e,r){var t=e.fallback,n=g(e,["fallback"]);return b()?z.default.createElement(eo,w(m({},n),{ref:r})):t!==null&&t!==void 0?t:null});ea.displayName="WhopCheckoutEmbed";var ei=D("react")})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function o(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var o=true;var i=false;var a,c;try{for(t=t.call(e);!(o=(a=t.next()).done);o=true){n.push(a.value);if(r&&n.length===r)break}}catch(e){i=true;c=e}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(i)throw c}}return n}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var o=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}o.forEach(function(r){n(e,r,t[r])})}return e}function l(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function f(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{l(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,r){if(e==null)return{};var t=d(e,r);var n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++){n=i[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function d(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function m(e,t){return r(e)||i(e,t)||b(e,t)||a()}function p(e){return t(e)||o(e)||b(e)||c()}function b(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}import{b as y,c as v,d as h,e as g,f as w,g as O,h as j,i as k,j as E}from"../chunk-D7BU562Q.mjs";import S,{forwardRef as C,useEffect as A,useMemo as P,useRef as I,useState as W}from"react";import{useSyncExternalStore as x}from"react";function D(){return function(){}}function _(){return x(D,function(){return!0},function(){return!1})}var R=["tomato","red","ruby","crimson","pink","plum","purple","violet","iris","cyan","teal","jade","green","grass","brown","blue","orange","indigo","sky","mint","yellow","amber","lime","lemon","magenta","gold","bronze","gray"];function U(e){return e?R.includes(e):!1}import{useRef as N}from"react";var V=Symbol("none");function M(e){var r=N(V);return r.current===V&&(r.current=e()),r}import{useEffect as T,useMemo as z}from"react";function B(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=M(function(){return j.apply(void 0,p(r))}),o=n.current;return F.apply(void 0,[o].concat(p(r))),o}function F(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++){t[n-1]=arguments[n]}var o=m(t,16),i=o[0],a=o[1],c=o[2],u=o[3],l=o[4],f=o[5],s=o[6],d=o[7],p=o[8],b=o[9],y=o[10],v=o[11],h=o[12],g=o[13],w=o[14],O=o[15];var k=z(function(){return j(i,a,c,void 0,l,f,s,d,p,b,y,v,h,g,w,O)},[i,a,c,l,f,s,d,p,b,y,v,h,g,w,O]);T(function(){e!==k&&process.env.NODE_ENV==="development"&&console.warn("[WhopCheckoutEmbed] iframeUrl changed from ".concat(e," to ").concat(k,". Updating props on the checkout embed is not supported. Please rerender the component."))},[e,k])}var Q=k.join(" ");var $=C(function(e,r){var t=e.planId,n=e.theme,o=e.sessionId,i=e.hidePrice,a=i===void 0?!1:i,c=e.skipRedirect,u=c===void 0?!1:c,l=e.onComplete,f=e.onStateChange,s=e.onAddressValidationError,d=e.utm,p=e.styles,b=e.prefill,j=e.themeOptions,k=e.hideSubmitButton,C=k===void 0?!1:k,x=e.hideTermsAndConditions,D=x===void 0?!1:x,_=e.hideEmail,R=_===void 0?!1:_,N=e.disableEmail,V=N===void 0?!1:N,M=e.hideAddressForm,T=M===void 0?!1:M,z=e.affiliateCode;var F=P(function(){return{accentColor:U(j===null||j===void 0?void 0:j.accentColor)?j.accentColor:void 0}},[j===null||j===void 0?void 0:j.accentColor]),$=B(t,n,o,void 0,a,u||!!l,d,p,b,F,C,D,R,V,T,z),q=I(null),G=m(W(480),2),H=G[0],J=G[1];if(A(function(){var e=q.current;if(e)return y(e,function(r){switch(r.event){case"resize":{J(r.height);break}case"center":{e.scrollIntoView({block:"center",inline:"center"});break}case"complete":{l&&l(r.plan_id,r.receipt_id);break}case"state":{f&&f(r.state);break}case"address-validation-error":{s&&s({error_message:r.error_message,error_code:r.error_code});break}}})},[l,f,s]),r){var K={submit:function(e){q.current&&O(q.current,e)},getEmail:function(e){if(!q.current)throw new Error("Whop embedded checkout frame not found");return h(q.current,e)},setEmail:function(e,r){if(!q.current)throw new Error("Whop embedded checkout frame not found");return v(q.current,e,r)},setAddress:function(e,r){if(!q.current)throw new Error("Whop embedded checkout frame not found");return g(q.current,e,r)},getAddress:function(e){if(!q.current)throw new Error("Whop embedded checkout frame not found");return w(q.current,e)}};typeof r=="function"?r(K):r.current=K}return S.createElement("iframe",{ref:q,allow:E,sandbox:Q,title:"Whop Embedded Checkout",src:$!==null&&$!==void 0?$:void 0,style:{border:"none",height:"".concat(H,"px"),width:"100%",overflow:"hidden"}})});$.displayName="WhopCheckoutEmbedInner";var q=C(function(e,r){var t=e.fallback,n=s(e,["fallback"]);return _()?S.createElement($,f(u({},n),{ref:r})):t!==null&&t!==void 0?t:null});q.displayName="WhopCheckoutEmbed";import{useRef as G}from"react";function H(){return G(null)}export{q as WhopCheckoutEmbed,R as accentColorValues,U as isAccentColor,H as useCheckoutEmbedControls};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
wco?: {
|
|
4
|
+
injected: true;
|
|
5
|
+
listening: boolean;
|
|
6
|
+
frames: Map<HTMLIFrameElement, () => void>;
|
|
7
|
+
identifiedFrames: Map<string, HTMLIFrameElement>;
|
|
8
|
+
submit: (identifier: string, data?: WhopCheckoutSubmitDetails) => void;
|
|
9
|
+
getEmail: (identifier: string, timeout?: number) => Promise<string>;
|
|
10
|
+
setEmail: (
|
|
11
|
+
identifier: string,
|
|
12
|
+
email: string,
|
|
13
|
+
timeout?: number,
|
|
14
|
+
) => Promise<void>;
|
|
15
|
+
getAddress: (
|
|
16
|
+
identifier: string,
|
|
17
|
+
timeout?: number,
|
|
18
|
+
) => Promise<{
|
|
19
|
+
address: WhopCheckoutAddress;
|
|
20
|
+
isComplete: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
setAddress: (
|
|
23
|
+
identifier: string,
|
|
24
|
+
address: WhopCheckoutAddress,
|
|
25
|
+
timeout?: number,
|
|
26
|
+
) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface HTMLElementEventMap {
|
|
31
|
+
"checkout:submit": CustomEvent<WhopCheckoutSubmitDetails>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type WhopCheckoutSubmitDetails = Record<never, never>;
|
|
36
|
+
|
|
37
|
+
type WhopCheckoutAddress = {
|
|
38
|
+
name: string;
|
|
39
|
+
country: string;
|
|
40
|
+
line1: string;
|
|
41
|
+
line2?: string;
|
|
42
|
+
city: string;
|
|
43
|
+
state: string;
|
|
44
|
+
postalCode: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type WhopCheckoutState = "loading" | "ready" | "disabled";
|
|
48
|
+
type WhopCheckoutMessage = {
|
|
49
|
+
event: "resize";
|
|
50
|
+
height: number;
|
|
51
|
+
} | {
|
|
52
|
+
event: "center";
|
|
53
|
+
} | {
|
|
54
|
+
event: "complete";
|
|
55
|
+
receipt_id?: string;
|
|
56
|
+
plan_id: string;
|
|
57
|
+
} | {
|
|
58
|
+
event: "state";
|
|
59
|
+
state: WhopCheckoutState;
|
|
60
|
+
} | {
|
|
61
|
+
event: "get-email-result";
|
|
62
|
+
email: string;
|
|
63
|
+
event_id: string;
|
|
64
|
+
} | {
|
|
65
|
+
event: "set-email-result";
|
|
66
|
+
ok: true;
|
|
67
|
+
error?: never;
|
|
68
|
+
event_id: string;
|
|
69
|
+
} | {
|
|
70
|
+
event: "set-email-result";
|
|
71
|
+
ok: false;
|
|
72
|
+
error: string;
|
|
73
|
+
event_id: string;
|
|
74
|
+
} | {
|
|
75
|
+
event: "set-address-result";
|
|
76
|
+
ok: true;
|
|
77
|
+
error?: never;
|
|
78
|
+
event_id: string;
|
|
79
|
+
} | {
|
|
80
|
+
event: "set-address-result";
|
|
81
|
+
ok: false;
|
|
82
|
+
error: string;
|
|
83
|
+
event_id: string;
|
|
84
|
+
} | {
|
|
85
|
+
event: "get-address-result";
|
|
86
|
+
ok: true;
|
|
87
|
+
address: WhopCheckoutAddress;
|
|
88
|
+
is_complete: boolean;
|
|
89
|
+
event_id: string;
|
|
90
|
+
} | {
|
|
91
|
+
event: "get-address-result";
|
|
92
|
+
ok: false;
|
|
93
|
+
error: string;
|
|
94
|
+
event_id: string;
|
|
95
|
+
} | {
|
|
96
|
+
event: "address-validation-error";
|
|
97
|
+
error_message: string;
|
|
98
|
+
error_code: string;
|
|
99
|
+
};
|
|
100
|
+
declare function isWhopCheckoutMessage(event: MessageEvent<unknown>): event is MessageEvent<WhopCheckoutMessage>;
|
|
101
|
+
|
|
102
|
+
declare function onWhopCheckoutMessage(iframe: HTMLIFrameElement, callback: (message: WhopCheckoutMessage) => void): () => void;
|
|
103
|
+
declare function setEmail(frame: HTMLIFrameElement, email: string, timeout?: number): Promise<void>;
|
|
104
|
+
declare function getEmail(frame: HTMLIFrameElement, timeout?: number): Promise<string>;
|
|
105
|
+
declare function setAddress(frame: HTMLIFrameElement, address: WhopCheckoutAddress, timeout?: number): Promise<void>;
|
|
106
|
+
declare function getAddress(frame: HTMLIFrameElement, timeout?: number): Promise<{
|
|
107
|
+
address: WhopCheckoutAddress;
|
|
108
|
+
isComplete: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
declare function submitCheckoutFrame(frame: HTMLIFrameElement, _data?: WhopCheckoutSubmitDetails): void;
|
|
111
|
+
|
|
112
|
+
interface WhopEmbeddedCheckoutStyleOptions {
|
|
113
|
+
container?: {
|
|
114
|
+
paddingTop?: number | string;
|
|
115
|
+
paddingBottom?: number | string;
|
|
116
|
+
paddingY?: number | string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface WhopEmbeddedCheckoutPrefillOptions {
|
|
120
|
+
email?: string;
|
|
121
|
+
address?: Partial<WhopCheckoutAddress>;
|
|
122
|
+
}
|
|
123
|
+
interface WhopEmbeddedCheckoutThemeOptions {
|
|
124
|
+
accentColor?: string;
|
|
125
|
+
}
|
|
126
|
+
declare function getEmbeddedCheckoutIframeUrl(planId: string, theme?: "light" | "dark" | "system", sessionId?: string, origin?: string, hidePrice?: boolean, skipRedirect?: boolean, utm?: Record<string, string | string[]>, styles?: WhopEmbeddedCheckoutStyleOptions, prefill?: WhopEmbeddedCheckoutPrefillOptions, themeOptions?: WhopEmbeddedCheckoutThemeOptions, hideSubmitButton?: boolean, hideTermsAndConditions?: boolean, hideEmail?: boolean, disableEmail?: boolean, hideAddressForm?: boolean, affiliateCode?: string): string;
|
|
127
|
+
declare const EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST: string[];
|
|
128
|
+
declare const EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING = "document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";
|
|
129
|
+
|
|
130
|
+
export { EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST as E, type WhopCheckoutSubmitDetails as W, type WhopCheckoutAddress as a, type WhopCheckoutState as b, type WhopEmbeddedCheckoutStyleOptions as c, type WhopEmbeddedCheckoutPrefillOptions as d, type WhopCheckoutMessage as e, setAddress as f, getEmail as g, getAddress as h, isWhopCheckoutMessage as i, submitCheckoutFrame as j, type WhopEmbeddedCheckoutThemeOptions as k, getEmbeddedCheckoutIframeUrl as l, EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING as m, onWhopCheckoutMessage as o, setEmail as s };
|