@tonder.io/ionic-lite-sdk 0.0.35-beta.10 → 0.0.35-beta.12
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/.idea/workspace.xml +12 -1
- package/dist/classes/BaseInlineCheckout.d.ts +4 -13
- package/dist/index.js +1 -1
- package/dist/types/checkout.d.ts +1 -0
- package/dist/types/commons.d.ts +4 -2
- package/package.json +3 -1
- package/src/classes/BaseInlineCheckout.ts +9 -30
- package/src/types/checkout.ts +1 -0
- package/src/types/commons.ts +98 -99
package/.idea/workspace.xml
CHANGED
|
@@ -106,7 +106,8 @@
|
|
|
106
106
|
<workItem from="1724776430626" duration="1847000" />
|
|
107
107
|
<workItem from="1724790840744" duration="239000" />
|
|
108
108
|
<workItem from="1725305433705" duration="21026000" />
|
|
109
|
-
<workItem from="1725333899382" duration="
|
|
109
|
+
<workItem from="1725333899382" duration="2939000" />
|
|
110
|
+
<workItem from="1725337022494" duration="626000" />
|
|
110
111
|
</task>
|
|
111
112
|
<servers />
|
|
112
113
|
</component>
|
|
@@ -132,6 +133,16 @@
|
|
|
132
133
|
<line>229</line>
|
|
133
134
|
<option name="timeStamp" value="16" />
|
|
134
135
|
</line-breakpoint>
|
|
136
|
+
<line-breakpoint enabled="true" type="javascript">
|
|
137
|
+
<url>file://$PROJECT_DIR$/src/types/commons.ts</url>
|
|
138
|
+
<line>106</line>
|
|
139
|
+
<option name="timeStamp" value="17" />
|
|
140
|
+
</line-breakpoint>
|
|
141
|
+
<line-breakpoint enabled="true" type="javascript">
|
|
142
|
+
<url>file://$PROJECT_DIR$/src/classes/liteCheckout.ts</url>
|
|
143
|
+
<line>233</line>
|
|
144
|
+
<option name="timeStamp" value="18" />
|
|
145
|
+
</line-breakpoint>
|
|
135
146
|
</breakpoints>
|
|
136
147
|
</breakpoint-manager>
|
|
137
148
|
</component>
|
|
@@ -8,22 +8,13 @@ export declare class BaseInlineCheckout {
|
|
|
8
8
|
process3ds: ThreeDSHandler;
|
|
9
9
|
mode?: "production" | "sandbox" | "stage" | "development" | undefined;
|
|
10
10
|
apiKeyTonder: string;
|
|
11
|
-
returnUrl
|
|
11
|
+
returnUrl?: string;
|
|
12
12
|
callBack?: ((response: any) => void) | undefined;
|
|
13
13
|
merchantData?: Business;
|
|
14
14
|
abortController: AbortController;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
lastName?: string;
|
|
19
|
-
country?: string;
|
|
20
|
-
address?: string;
|
|
21
|
-
city?: string;
|
|
22
|
-
state?: string;
|
|
23
|
-
postCode?: string;
|
|
24
|
-
email?: string;
|
|
25
|
-
phone?: string;
|
|
26
|
-
customer?: ICustomer;
|
|
15
|
+
customer?: ICustomer | {
|
|
16
|
+
email: string;
|
|
17
|
+
};
|
|
27
18
|
cartItems?: IItem[];
|
|
28
19
|
metadata: {};
|
|
29
20
|
card?: {} | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"skyflow-js";function e(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{d(o.next(t))}catch(t){i(t)}}function a(t){try{d(o.throw(t))}catch(t){i(t)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}d((o=o.apply(t,e||[])).next())}))}function n(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function o(t,n,o){return e(this,void 0,void 0,(function*(){const e=yield fetch(`${t}/api/v1/payments/business/${n}`,{headers:{Authorization:`Token ${n}`},signal:o});return yield e.json()}))}"function"==typeof SuppressedError&&SuppressedError;class r{constructor({code:t,body:e,name:n,message:o,stack:r}){this.code=t,this.body=e,this.name=n,this.message=o,this.stack=r}}const i=()=>({javascript_enabled:!0,time_zone:(new Date).getTimezoneOffset(),language:navigator.language||"en-US",color_depth:window.screen?window.screen.colorDepth:null,screen_width:window.screen?window.screen.width*window.devicePixelRatio||window.screen.width:null,screen_height:window.screen?window.screen.height*window.devicePixelRatio||window.screen.height:null,user_agent:navigator.userAgent}),s=t=>{var e;return t&&"business"in t?null===(e=null==t?void 0:t.business)||void 0===e?void 0:e.pk:""},a=t=>new r({code:(null==t?void 0:t.status)?t.status:t.code,body:null==t?void 0:t.body,name:t?"string"==typeof t?"catch":t.name:"Error",message:t?"string"==typeof t?t:t.message:"Error",stack:"string"==typeof t?void 0:t.stack}),d=(t,n=void 0)=>e(void 0,void 0,void 0,(function*(){let e,o,i="Error";t&&"json"in t&&(e=yield null==t?void 0:t.json()),t&&"status"in t&&(o=t.status.toString()),!e&&t&&"text"in t&&(i=yield t.text()),(null==e?void 0:e.detail)&&(i=e.detail);return new r({code:o,body:e,name:o,message:i,stack:n})}));function l(t,e){var n,o;let r=200;try{r=Number((null==e?void 0:e.code)||200)}catch(t){}const i={status:"error",code:r,message:"",detail:(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.detail)||(null===(o=null==e?void 0:e.body)||void 0===o?void 0:o.error)||e.body||"Ocurrio un error inesperado."};return Object.assign(Object.assign({},i),t)}class c{constructor({payload:t=null,apiKey:e,baseUrl:n}){this.localStorageKey="verify_transaction_status_url",this.setPayload=t=>{this.payload=t},this.baseUrl=n,this.apiKey=e,this.payload=t}setStorageItem(t){return localStorage.setItem(this.localStorageKey,JSON.stringify(t))}getStorageItem(){return localStorage.getItem(this.localStorageKey)}removeStorageItem(){return localStorage.removeItem(this.localStorageKey)}saveVerifyTransactionUrl(){var t,e,n,o,r,i;const s=null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.redirect_to_url)||void 0===n?void 0:n.verify_transaction_status_url;if(s)this.saveUrlWithExpiration(s);else{const t=null===(i=null===(r=null===(o=this.payload)||void 0===o?void 0:o.next_action)||void 0===r?void 0:r.iframe_resources)||void 0===i?void 0:i.verify_transaction_status_url;t?this.saveUrlWithExpiration(t):console.log("No verify_transaction_status_url found")}}saveUrlWithExpiration(t){try{const e={url:t,expires:(new Date).getTime()+12e5};this.setStorageItem(e)}catch(t){console.log("error: ",t)}}getUrlWithExpiration(){const t=this.getStorageItem();if(t){const e=JSON.parse(t);if(!e)return;return(new Date).getTime()>e.expires?(this.removeVerifyTransactionUrl(),null):e.url}return null}removeVerifyTransactionUrl(){return this.removeStorageItem()}getVerifyTransactionUrl(){return this.getStorageItem()}loadIframe(){var t,e,n;if(null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===n?void 0:n.iframe)return new Promise(((t,e)=>{var n,o,r;const i=null===(r=null===(o=null===(n=this.payload)||void 0===n?void 0:n.next_action)||void 0===o?void 0:o.iframe_resources)||void 0===r?void 0:r.iframe;if(i){this.saveVerifyTransactionUrl();const n=document.createElement("div");n.innerHTML=i,document.body.appendChild(n);const o=document.createElement("script");o.textContent='document.getElementById("tdsMmethodForm").submit();',n.appendChild(o);const r=document.getElementById("tdsMmethodTgtFrame");r?r.onload=()=>t(!0):(console.log("No redirection found"),e(!1))}else console.log("No redirection found"),e(!1)}))}getRedirectUrl(){var t,e,n;return null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.redirect_to_url)||void 0===n?void 0:n.url}redirectToChallenge(){const t=this.getRedirectUrl();t?(this.saveVerifyTransactionUrl(),window.location=t):console.log("No redirection found")}getURLParameters(){const t={},e=new URLSearchParams(window.location.search);for(const[n,o]of e)t[n]=o;return t}handleSuccessTransaction(t){return this.removeVerifyTransactionUrl(),console.log("Transacción autorizada."),t}handleDeclinedTransaction(t){return this.removeVerifyTransactionUrl(),t}handle3dsChallenge(t){return e(this,void 0,void 0,(function*(){const e=document.createElement("form");e.name="frm",e.method="POST",e.action=t.redirect_post_url;const n=document.createElement("input");n.type="hidden",n.name=t.creq,n.value=t.creq,e.appendChild(n);const o=document.createElement("input");o.type="hidden",o.name=t.term_url,o.value=t.TermUrl,e.appendChild(o),document.body.appendChild(e),e.submit(),yield this.verifyTransactionStatus()}))}handleTransactionResponse(t){return e(this,void 0,void 0,(function*(){const e=yield t.json();return"Pending"===e.status&&e.redirect_post_url?yield this.handle3dsChallenge(e):["Success","Authorized"].includes(e.status)?this.handleSuccessTransaction(e):(this.handleDeclinedTransaction(t),e)}))}verifyTransactionStatus(){return e(this,void 0,void 0,(function*(){const t=this.getUrlWithExpiration();if(t){const e=`${this.baseUrl}${t}`;try{const t=yield fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKey}`}});return 200!==t.status?(console.error("La verificación de la transacción falló."),this.removeVerifyTransactionUrl(),t):yield this.handleTransactionResponse(t)}catch(t){console.error("Error al verificar la transacción:",t),this.removeVerifyTransactionUrl()}}else console.log("No verify_transaction_status_url found")}))}}const u=Object.freeze({production:"https://app.tonder.io",sandbox:"https://sandbox.tonder.io",stage:"https://stage.tonder.io",development:"http://localhost:8000"});function h(t,n,o){return e(this,void 0,void 0,(function*(){try{const e=`${t}/api/v1/checkout-router/`,r=o,i=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${n}`},body:JSON.stringify(Object.assign(Object.assign({},r),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}))});if(i.status>=200&&i.status<=299)return yield i.json();{const t=yield i.json(),e=new Error("Failed to start checkout router");throw e.details=t,e}}catch(t){throw t}}))}function p(t,n,o=!0,r=null){return e(this,void 0,void 0,(function*(){let e=yield window.OpenPay;return e.setId(t),e.setApiKey(n),e.setSandboxMode(o),yield e.deviceData.setup({signal:r})}))}var m,y,f,g,v,A,_,b;class E{constructor({mode:t="stage",apiKey:e,apiKeyTonder:n,returnUrl:o,callBack:r=(()=>{})}){m.add(this),this.baseUrl="",this.cartTotal="0",this.metadata={},this.card={},this.currency="",y.set(this,void 0),this.apiKeyTonder=e||n||"",this.returnUrl=o,this.callBack=r,this.mode=t,this.baseUrl=u[this.mode]||u.stage,this.abortController=new AbortController,this.process3ds=new c({apiKey:e,baseUrl:this.baseUrl})}configureCheckout(t){"customer"in t&&n(this,m,"m",f).call(this,t.customer)}verify3dsTransaction(){return e(this,void 0,void 0,(function*(){const t=yield this.process3ds.verifyTransactionStatus(),e=yield n(this,m,"m",b).call(this,t);return this.process3ds.setPayload(e),this._handle3dsRedirect(e)}))}payment(t){return new Promise(((o,r)=>e(this,void 0,void 0,(function*(){var e,i;try{n(this,m,"m",f).call(this,t.customer),this._setCartTotal(null===(e=t.cart)||void 0===e?void 0:e.total),n(this,m,"m",g).call(this,null===(i=t.cart)||void 0===i?void 0:i.items),n(this,m,"m",v).call(this,t),n(this,m,"m",A).call(this,t),n(this,m,"m",_).call(this,t);const r=yield this._checkout(t);this.process3ds.setPayload(r),this.callBack&&this.callBack(r);(yield this._handle3dsRedirect(r))&&o(r)}catch(t){r(t)}}))))}_initializeCheckout(){return e(this,void 0,void 0,(function*(){const t=yield this._fetchMerchantData();t&&t.mercado_pago&&t.mercado_pago.active&&function(){try{const t=document.createElement("script");t.src="https://www.mercadopago.com/v2/security.js",t.setAttribute("view",""),t.onload=()=>{console.log("Mercado Pago script loaded successfully.")},t.onerror=t=>{console.error("Error loading Mercado Pago script:",t)},document.head.appendChild(t)}catch(t){console.error("Error attempting to inject Mercado Pago script:",t)}}()}))}_checkout(t){return e(this,void 0,void 0,(function*(){throw new Error("The #checkout method should be implement in child classes.")}))}_setCartTotal(t){throw new Error("The #setCartTotal method should be implement in child classes.")}_getCustomer(t=null){return e(this,void 0,void 0,(function*(){return n(this,y,"f")||function(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?r.call(t,n):r?r.value=n:e.set(t,n)}(this,y,yield function(t,n,o,r=null){return e(this,void 0,void 0,(function*(){const e=`${t}/api/v1/customer/`,i={email:o.email,first_name:null==o?void 0:o.firstName,last_name:null==o?void 0:o.lastName,phone:null==o?void 0:o.phone},s=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${n}`},signal:r,body:JSON.stringify(i)});if(201===s.status)return yield s.json();throw new Error(`Error: ${s.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,this.customer,t),"f"),n(this,y,"f")}))}_handleCheckout({card:t,payment_method:n,customer:o,isSandbox:r}){return e(this,void 0,void 0,(function*(){const{openpay_keys:s,reference:a,business:d}=this.merchantData,l=Number(this.cartTotal);try{let c;!c&&s.merchant_id&&s.public_key&&(c=yield p(s.merchant_id,s.public_key,r,this.abortController.signal));const{id:u,auth_token:m}=o,y={business:this.apiKeyTonder,client:m,billing_address_id:null,shipping_address_id:null,amount:l,status:"A",reference:a,is_oneclick:!0,items:this.cartItems},f=yield function(t,n,o){return e(this,void 0,void 0,(function*(){const e=`${t}/api/v1/orders/`,r=o,i=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${n}`},body:JSON.stringify(r)});if(201===i.status)return yield i.json();throw new Error(`Error: ${i.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,y),g=(new Date).toISOString(),v={business_pk:d.pk,client_id:u,amount:l,date:g,order_id:f.id},A=yield function(t,n,o){return e(this,void 0,void 0,(function*(){const e=`${t}/api/v1/business/${o.business_pk}/payments/`,r=o,i=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${n}`},body:JSON.stringify(r)});if(i.status>=200&&i.status<=299)return yield i.json();throw new Error(`Error: ${i.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,v),_=Object.assign({name:this.firstName||this.name||"",last_name:this.lastName||this.lastname||"",email_client:this.email,phone_number:this.phone,return_url:this.returnUrl,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:l,title_ship:"shipping",description:"transaction",device_session_id:c||null,token_id:"",order_id:f.id,business_id:d.pk,payment_id:A.pk,source:"sdk",metadata:this.metadata,browser_info:i(),currency:this.currency},n?{payment_method:n}:{card:t}),b=yield h(this.baseUrl,this.apiKeyTonder,_);return b||!1}catch(t){throw console.log(t),t}}))}_fetchMerchantData(){return e(this,void 0,void 0,(function*(){try{return this.merchantData||(this.merchantData=yield o(this.baseUrl,this.apiKeyTonder,this.abortController.signal)),this.merchantData}catch(t){return this.merchantData}}))}_handle3dsRedirect(t){var n,o;return e(this,void 0,void 0,(function*(){if(t&&"next_action"in t?null===(o=null===(n=null==t?void 0:t.next_action)||void 0===n?void 0:n.iframe_resources)||void 0===o?void 0:o.iframe:null)this.process3ds.loadIframe().then((()=>{this.process3ds.verifyTransactionStatus()})).catch((t=>{console.log("Error loading iframe:",t)}));else{if(!this.process3ds.getRedirectUrl())return t;this.process3ds.redirectToChallenge()}}))}}y=new WeakMap,m=new WeakSet,f=function(t){t&&(this.firstName=null==t?void 0:t.firstName,this.lastName=null==t?void 0:t.lastName,this.country=null==t?void 0:t.country,this.address=null==t?void 0:t.street,this.city=null==t?void 0:t.city,this.state=null==t?void 0:t.state,this.postCode=null==t?void 0:t.postCode,this.email=null==t?void 0:t.email,this.phone=null==t?void 0:t.phone,this.customer=t)},g=function(t){this.cartItems=t},v=function(t){this.metadata=null==t?void 0:t.metadata},A=function(t){this.currency=null==t?void 0:t.currency},_=function(t){this.card=null==t?void 0:t.card},b=function(t){var n,o;return e(this,void 0,void 0,(function*(){if("Hard"===(null===(n=null==t?void 0:t.decline)||void 0===n?void 0:n.error_type))return t;if(["Success","Authorized"].includes(null==t?void 0:t.transaction_status))return t;if(t){const e={checkout_id:null===(o=t.checkout)||void 0===o?void 0:o.id};try{return yield h(this.baseUrl,this.apiKeyTonder,e)}catch(t){}return t}}))};const T=Object.freeze({saveCardError:"Ha ocurrido un error guardando la tarjeta. Inténtalo nuevamente.",removeCardError:"Ha ocurrido un error eliminado la tarjeta. Inténtalo nuevamente.",getCardsError:"Ha ocurrido un error obteniendo las tarjetas del customer. Inténtalo nuevamente.",cardExist:"La tarjeta fue registrada previamente.",removedCard:"Card deleted successfully",errorCheckout:"No se ha podido procesar el pago",cardSaved:"Tarjeta registrada con éxito.",getPaymentMethodsError:"Ha ocurrido un error obteniendo las métodos de pago del customer. Inténtalo nuevamente.",getBusinessError:"Ha ocurrido un error obteniendo los datos del comercio. Inténtalo nuevamente."});function O({baseUrl:n,apiKey:o,vault_id:r,vault_url:i,data:s}){return e(this,void 0,void 0,(function*(){const d=t.init({vaultID:r,vaultURL:i,getBearerToken:()=>e(this,void 0,void 0,(function*(){return yield function(t,n,o=null){return e(this,void 0,void 0,(function*(){const e=yield fetch(`${t}/api/v1/vault-token/`,{method:"GET",headers:{Authorization:`Token ${n}`},signal:o});if(e.ok)return(yield e.json()).token;throw new Error("Failed to retrieve bearer token")}))}(n,o)})),options:{logLevel:t.LogLevel.ERROR,env:t.Env.DEV}}),l=d.container(t.ContainerType.COLLECT),c=yield function(n,o){return e(this,void 0,void 0,(function*(){const r=yield function(n,o){return e(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(n).map((n=>e(this,void 0,void 0,(function*(){return{element:yield o.create({table:"cards",column:n,type:t.ElementType.INPUT_FIELD}),key:n}})))))}))}(n,o);return r?r.map((t=>new Promise((e=>{var o;const r=document.createElement("div");r.hidden=!0,r.id=`id-${t.key}`,null===(o=document.querySelector("body"))||void 0===o||o.appendChild(r),setTimeout((()=>{t.element.mount(`#id-${t.key}`),setInterval((()=>{if(t.element.isMounted()){const o=n[t.key];return t.element.update({value:o}),e(t.element.isMounted())}}),120)}),120)})))):[]}))}(s,l);if((yield Promise.all(c)).some((t=>!t)))throw a(Error("Ocurrió un error al montar los campos de la tarjeta"));try{const t=yield l.collect();if(t)return t.records[0].fields;throw a(Error("Por favor, verifica todos los campos de tu tarjeta"))}catch(t){throw a(t)}}))}const S=Object.freeze({SORIANA:"SORIANA",OXXO:"OXXO",SPEI:"SPEI",CODI:"CODI",MERCADOPAGO:"MERCADOPAGO",PAYPAL:"PAYPAL",COMERCIALMEXICANA:"COMERCIALMEXICANA",BANCOMER:"BANCOMER",WALMART:"WALMART",BODEGA:"BODEGA",SAMSCLUB:"SAMSCLUB",SUPERAMA:"SUPERAMA",CALIMAX:"CALIMAX",EXTRA:"EXTRA",CIRCULOK:"CIRCULOK",SEVEN11:"7ELEVEN",TELECOMM:"TELECOMM",BANORTE:"BANORTE",BENAVIDES:"BENAVIDES",DELAHORRO:"DELAHORRO",ELASTURIANO:"ELASTURIANO",WALDOS:"WALDOS",ALSUPER:"ALSUPER",KIOSKO:"KIOSKO",STAMARIA:"STAMARIA",LAMASBARATA:"LAMASBARATA",FARMROMA:"FARMROMA",FARMUNION:"FARMUNION",FARMATODO:"FARMATODO",SFDEASIS:"SFDEASIS",FARM911:"FARM911",FARMECONOMICAS:"FARMECONOMICAS",FARMMEDICITY:"FARMMEDICITY",RIANXEIRA:"RIANXEIRA",WESTERNUNION:"WESTERNUNION",ZONAPAGO:"ZONAPAGO",CAJALOSANDES:"CAJALOSANDES",CAJAPAITA:"CAJAPAITA",CAJASANTA:"CAJASANTA",CAJASULLANA:"CAJASULLANA",CAJATRUJILLO:"CAJATRUJILLO",EDPYME:"EDPYME",KASNET:"KASNET",NORANDINO:"NORANDINO",QAPAQ:"QAPAQ",RAIZ:"RAIZ",PAYSER:"PAYSER",WUNION:"WUNION",BANCOCONTINENTAL:"BANCOCONTINENTAL",GMONEY:"GMONEY",GOPAY:"GOPAY",WU:"WU",PUNTOSHEY:"PUNTOSHEY",AMPM:"AMPM",JUMBOMARKET:"JUMBOMARKET",SMELPUEBLO:"SMELPUEBLO",BAM:"BAM",REFACIL:"REFACIL",ACYVALORES:"ACYVALORES"}),C={[S.SORIANA]:{label:"Soriana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png"},[S.OXXO]:{label:"Oxxo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png"},[S.CODI]:{label:"CoDi",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png"},[S.SPEI]:{label:"SPEI",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png"},[S.PAYPAL]:{label:"Paypal",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png"},[S.COMERCIALMEXICANA]:{label:"Comercial Mexicana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png"},[S.BANCOMER]:{label:"Bancomer",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png"},[S.WALMART]:{label:"Walmart",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png"},[S.BODEGA]:{label:"Bodega Aurrera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png"},[S.SAMSCLUB]:{label:"Sam´s Club",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png"},[S.SUPERAMA]:{label:"Superama",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png"},[S.CALIMAX]:{label:"Calimax",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png"},[S.EXTRA]:{label:"Tiendas Extra",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png"},[S.CIRCULOK]:{label:"Círculo K",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png"},[S.SEVEN11]:{label:"7 Eleven",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png"},[S.TELECOMM]:{label:"Telecomm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png"},[S.BANORTE]:{label:"Banorte",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png"},[S.BENAVIDES]:{label:"Farmacias Benavides",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png"},[S.DELAHORRO]:{label:"Farmacias del Ahorro",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png"},[S.ELASTURIANO]:{label:"El Asturiano",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png"},[S.WALDOS]:{label:"Waldos",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png"},[S.ALSUPER]:{label:"Alsuper",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png"},[S.KIOSKO]:{label:"Kiosko",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png"},[S.STAMARIA]:{label:"Farmacias Santa María",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png"},[S.LAMASBARATA]:{label:"Farmacias la más barata",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png"},[S.FARMROMA]:{label:"Farmacias Roma",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png"},[S.FARMUNION]:{label:"Pago en Farmacias Unión",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png"},[S.FARMATODO]:{label:"Pago en Farmacias Farmatodo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png\t"},[S.SFDEASIS]:{label:"Pago en Farmacias San Francisco de Asís",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png"},[S.FARM911]:{label:"Farmacias 911",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.FARMECONOMICAS]:{label:"Farmacias Economicas",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.FARMMEDICITY]:{label:"Farmacias Medicity",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.RIANXEIRA]:{label:"Rianxeira",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.WESTERNUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.ZONAPAGO]:{label:"Zona Pago",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.CAJALOSANDES]:{label:"Caja Los Andes",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.CAJAPAITA]:{label:"Caja Paita",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.CAJASANTA]:{label:"Caja Santa",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.CAJASULLANA]:{label:"Caja Sullana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.CAJATRUJILLO]:{label:"Caja Trujillo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.EDPYME]:{label:"Edpyme",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.KASNET]:{label:"KasNet",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.NORANDINO]:{label:"Norandino",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.QAPAQ]:{label:"Qapaq",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.RAIZ]:{label:"Raiz",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.PAYSER]:{label:"Paysera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.WUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.BANCOCONTINENTAL]:{label:"Banco Continental",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.GMONEY]:{label:"Go money",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.GOPAY]:{label:"Go pay",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.WU]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.PUNTOSHEY]:{label:"Puntoshey",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.AMPM]:{label:"Ampm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.JUMBOMARKET]:{label:"Jumbomarket",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.SMELPUEBLO]:{label:"Smelpueblo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.BAM]:{label:"Bam",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.REFACIL]:{label:"Refacil",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[S.ACYVALORES]:{label:"Acyvalores",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"}},j=t=>{const e=t.toUpperCase().trim().replace(/\s+/g,"");return C[e]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}};class w extends E{constructor({apiKey:t,mode:e,returnUrl:n,callBack:o}){super({mode:e,apiKey:t,returnUrl:n,callBack:o}),this.activeAPMs=[]}injectCheckout(){return e(this,void 0,void 0,(function*(){yield this._initializeCheckout()}))}getCustomerCards(){return e(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:t}=yield this._getCustomer(),n=yield function(t,n,o,r=null){return e(this,void 0,void 0,(function*(){try{const e=`${t}/api/v1/business/${o}/cards/`,i=yield fetch(e,{method:"GET",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();const s=yield i.json();throw yield d(i,s)}catch(t){throw a(t)}}))}(this.baseUrl,t,this.merchantData.business.pk);return Object.assign(Object.assign({},n),{cards:n.cards.map((t=>{return Object.assign(Object.assign({},t),{icon:(e=t.fields.card_scheme,"Visa"===e?"https://d35a75syrgujp0.cloudfront.net/cards/visa.png":"Mastercard"===e?"https://d35a75syrgujp0.cloudfront.net/cards/mastercard.png":"American Express"===e?"https://d35a75syrgujp0.cloudfront.net/cards/american_express.png":"https://d35a75syrgujp0.cloudfront.net/cards/default_card.png")});var e}))})}catch(t){throw l({message:T.getCardsError},t)}}))}saveCustomerCard(t){return e(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:n}=yield this._getCustomer(),{vault_id:o,vault_url:r,business:i}=this.merchantData,s=yield O({vault_id:o,vault_url:r,data:t,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder});return yield function(t,n,o,r){return e(this,void 0,void 0,(function*(){try{const e=`${t}/api/v1/business/${o}/cards/`,i=yield fetch(e,{method:"POST",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"},body:JSON.stringify(r)});if(i.ok)return yield i.json();const s=yield i.json();throw yield d(i,s)}catch(t){throw a(t)}}))}(this.baseUrl,n,null==i?void 0:i.pk,s)}catch(t){throw l({message:T.saveCardError},t)}}))}removeCustomerCard(t){return e(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:n}=yield this._getCustomer(),{business:o}=this.merchantData;return yield function(t,n,o="",r){return e(this,void 0,void 0,(function*(){try{const e=`${t}/api/v1/business/${r}/cards/${o}`,i=yield fetch(e,{method:"DELETE",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"}});if(204===i.status)return T.cardSaved;if(i.ok&&"json"in i)return yield i.json();const s=yield i.json();throw yield d(i,s)}catch(t){throw a(t)}}))}(this.baseUrl,n,t,null==o?void 0:o.pk)}catch(t){throw l({message:T.removeCardError},t)}}))}getCustomerPaymentMethods(){return e(this,void 0,void 0,(function*(){try{const t=yield function(t,n,o={status:"active",pagesize:"10000"},r=null){return e(this,void 0,void 0,(function*(){try{const e=new URLSearchParams(o).toString(),i=yield fetch(`${t}/api/v1/payment_methods?${e}`,{method:"GET",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();const s=yield i.json();throw yield d(i,s)}catch(t){throw a(t)}}))}(this.baseUrl,this.apiKeyTonder);return(t&&"results"in t&&t.results.length>0?t.results:[]).filter((t=>"cards"!==t.category.toLowerCase())).map((t=>Object.assign({id:t.pk,payment_method:t.payment_method,priority:t.priority,category:t.category},j(t.payment_method)))).sort(((t,e)=>t.priority-e.priority))}catch(t){throw l({message:T.getPaymentMethodsError},t)}}))}getBusiness(){return e(this,void 0,void 0,(function*(){try{return yield o(this.baseUrl,this.apiKeyTonder,this.abortController.signal)}catch(t){throw l({message:T.getBusinessError},t)}}))}getOpenpayDeviceSessionID(t,n,o){return e(this,void 0,void 0,(function*(){try{return yield p(t,n,o)}catch(t){throw a(t)}}))}getSkyflowTokens({vault_id:t,vault_url:n,data:o}){return e(this,void 0,void 0,(function*(){return yield O({vault_id:t,vault_url:n,data:o,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})}))}_setCartTotal(t){this.cartTotal=t}_checkout({card:t,payment_method:n,isSandbox:o}){return e(this,void 0,void 0,(function*(){yield this._fetchMerchantData();const e=yield this._getCustomer(this.abortController.signal),{vault_id:r,vault_url:i}=this.merchantData;let s;return n&&""===n&&null!==n||(s="string"==typeof t?{skyflow_id:t}:yield O({vault_id:r,vault_url:i,data:Object.assign(Object.assign({},t),{card_number:t.card_number.replace(/\s+/g,"")}),baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})),yield this._handleCheckout({card:s,payment_method:n,customer:e,isSandbox:o})}))}customerRegister(t){return e(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/customer/`,n={email:t},o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},signal:this.abortController.signal,body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield d(o)}catch(t){throw a(t)}}))}createOrder(t){return e(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/orders/`,n=t,o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield d(o)}catch(t){throw a(t)}}))}createPayment(t){return e(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/business/${t.business_pk}/payments/`,n=t,o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield d(o)}catch(t){throw a(t)}}))}startCheckoutRouter(t){return e(this,void 0,void 0,(function*(){const e=yield h(this.baseUrl,this.apiKeyTonder,t);if(yield this.init3DSRedirect(e))return e}))}init3DSRedirect(t){return e(this,void 0,void 0,(function*(){return this.process3ds.setPayload(t),yield this._handle3dsRedirect(t)}))}startCheckoutRouterFull(t){return e(this,void 0,void 0,(function*(){try{const{order:e,total:n,customer:o,skyflowTokens:s,return_url:a,isSandbox:d,metadata:l,currency:c,payment_method:u}=t,m=yield this._fetchMerchantData(),y=yield this.customerRegister(o.email);if(!(y&&"auth_token"in y&&m&&"reference"in m))throw new r({code:"500",body:m,name:"Keys error",message:"Merchant or customer reposne errors"});{const t={business:this.apiKeyTonder,client:y.auth_token,billing_address_id:null,shipping_address_id:null,amount:n,reference:m.reference,is_oneclick:!0,items:e.items},f=yield this.createOrder(t),g=(new Date).toISOString();if(!("id"in f&&"id"in y&&"business"in m))throw new r({code:"500",body:f,name:"Keys error",message:"Order response errors"});{const t={business_pk:m.business.pk,amount:n,date:g,order_id:f.id,client_id:y.id},e=yield this.createPayment(t);let r;const{openpay_keys:v,business:A}=m;v.merchant_id&&v.public_key&&(r=yield p(v.merchant_id,v.public_key,d));const _=Object.assign(Object.assign({name:o.name,last_name:o.lastname,email_client:o.email,phone_number:o.phone,return_url:a,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:n,title_ship:"shipping",description:"transaction",device_session_id:r||null,token_id:"",order_id:"id"in f&&f.id,business_id:A.pk,payment_id:"pk"in e&&e.pk,source:"sdk",metadata:l,browser_info:i(),currency:c},u?{payment_method:u}:{card:s}),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}),b=yield h(this.baseUrl,this.apiKeyTonder,_);if(yield this.init3DSRedirect(b))return b}}}catch(t){throw a(t)}}))}registerCustomerCard(t,n){return e(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const e=yield fetch(`${this.baseUrl}/api/v1/business/${s(this.merchantData)}/cards/`,{method:"POST",headers:{Authorization:`Token ${t}`,"Content-Type":"application/json"},body:JSON.stringify(Object.assign({},n))});if(e.ok)return yield e.json();throw yield d(e)}catch(t){throw a(t)}}))}deleteCustomerCard(t,n=""){return e(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const e=yield fetch(`${this.baseUrl}/api/v1/business/${s(this.merchantData)}/cards/${n}`,{method:"DELETE",headers:{Authorization:`Token ${t}`,"Content-Type":"application/json"},signal:this.abortController.signal});if(e.ok)return!0;throw yield d(e)}catch(t){throw a(t)}}))}getActiveAPMs(){return e(this,void 0,void 0,(function*(){try{const t=yield function(t,n,o="?status=active&page_size=10000&country=México",r=null){return e(this,void 0,void 0,(function*(){try{const e=yield fetch(`${t}/api/v1/payment_methods${o}`,{method:"GET",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"},signal:r});if(e.ok)return yield e.json();throw yield d(e)}catch(t){throw a(t)}}))}(this.baseUrl,this.apiKeyTonder),n=t&&t.results&&t.results.length>0?t.results:[];return this.activeAPMs=n.filter((t=>"cards"!==t.category.toLowerCase())).map((t=>Object.assign({id:t.pk,payment_method:t.payment_method,priority:t.priority,category:t.category},j(t.payment_method)))).sort(((t,e)=>t.priority-e.priority)),this.activeAPMs}catch(t){return console.error("Error getting APMS",t),[]}}))}}function N(t){return/^\d{12,19}$/.test(t)&&U(t)}function R(t){return/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/.test(t)}function M(t){return/^\d{3,4}$/.test(t)}function I(t){return/^(0[1-9]|1[0-2])$/.test(t)}function k(t){if(!/^\d{2}$/.test(t))return!1;const e=(new Date).getFullYear()%100;return parseInt(t,10)>=e}const U=t=>{const e=`${t}`.split("").reverse().map((t=>Number.parseInt(t))),n=e.shift();let o=e.reduce(((t,e,n)=>n%2!=0?t+e:t+((e*=2)>9?e-9:e)),0);return o+=n,o%10==0};export{w as LiteCheckout,M as validateCVV,N as validateCardNumber,R as validateCardholderName,I as validateExpirationMonth,k as validateExpirationYear};
|
|
1
|
+
import{get as t}from"lodash";import e from"skyflow-js";function n(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{d(o.next(t))}catch(t){i(t)}}function a(t){try{d(o.throw(t))}catch(t){i(t)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}d((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function r(t,e,o){return n(this,void 0,void 0,(function*(){const n=yield fetch(`${t}/api/v1/payments/business/${e}`,{headers:{Authorization:`Token ${e}`},signal:o});return yield n.json()}))}"function"==typeof SuppressedError&&SuppressedError;class i{constructor({code:t,body:e,name:n,message:o,stack:r}){this.code=t,this.body=e,this.name=n,this.message=o,this.stack=r}}const s=()=>({javascript_enabled:!0,time_zone:(new Date).getTimezoneOffset(),language:navigator.language||"en-US",color_depth:window.screen?window.screen.colorDepth:null,screen_width:window.screen?window.screen.width*window.devicePixelRatio||window.screen.width:null,screen_height:window.screen?window.screen.height*window.devicePixelRatio||window.screen.height:null,user_agent:navigator.userAgent}),a=t=>{var e;return t&&"business"in t?null===(e=null==t?void 0:t.business)||void 0===e?void 0:e.pk:""},d=t=>new i({code:(null==t?void 0:t.status)?t.status:t.code,body:null==t?void 0:t.body,name:t?"string"==typeof t?"catch":t.name:"Error",message:t?"string"==typeof t?t:t.message:"Error",stack:"string"==typeof t?void 0:t.stack}),c=(t,e=void 0)=>n(void 0,void 0,void 0,(function*(){let n,o,r="Error";t&&"json"in t&&(n=yield null==t?void 0:t.json()),t&&"status"in t&&(o=t.status.toString()),!n&&t&&"text"in t&&(r=yield t.text()),(null==n?void 0:n.detail)&&(r=n.detail);return new i({code:o,body:n,name:o,message:r,stack:e})}));function l(t,e){var n,o;let r=200;try{r=Number((null==e?void 0:e.code)||200)}catch(t){}const i={status:"error",code:r,message:"",detail:(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.detail)||(null===(o=null==e?void 0:e.body)||void 0===o?void 0:o.error)||e.body||"Ocurrio un error inesperado."};return Object.assign(Object.assign({},i),t)}class u{constructor({payload:t=null,apiKey:e,baseUrl:n}){this.localStorageKey="verify_transaction_status_url",this.setPayload=t=>{this.payload=t},this.baseUrl=n,this.apiKey=e,this.payload=t}setStorageItem(t){return localStorage.setItem(this.localStorageKey,JSON.stringify(t))}getStorageItem(){return localStorage.getItem(this.localStorageKey)}removeStorageItem(){return localStorage.removeItem(this.localStorageKey)}saveVerifyTransactionUrl(){var t,e,n,o,r,i;const s=null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.redirect_to_url)||void 0===n?void 0:n.verify_transaction_status_url;if(s)this.saveUrlWithExpiration(s);else{const t=null===(i=null===(r=null===(o=this.payload)||void 0===o?void 0:o.next_action)||void 0===r?void 0:r.iframe_resources)||void 0===i?void 0:i.verify_transaction_status_url;t?this.saveUrlWithExpiration(t):console.log("No verify_transaction_status_url found")}}saveUrlWithExpiration(t){try{const e={url:t,expires:(new Date).getTime()+12e5};this.setStorageItem(e)}catch(t){console.log("error: ",t)}}getUrlWithExpiration(){const t=this.getStorageItem();if(t){const e=JSON.parse(t);if(!e)return;return(new Date).getTime()>e.expires?(this.removeVerifyTransactionUrl(),null):e.url}return null}removeVerifyTransactionUrl(){return this.removeStorageItem()}getVerifyTransactionUrl(){return this.getStorageItem()}loadIframe(){var t,e,n;if(null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===n?void 0:n.iframe)return new Promise(((t,e)=>{var n,o,r;const i=null===(r=null===(o=null===(n=this.payload)||void 0===n?void 0:n.next_action)||void 0===o?void 0:o.iframe_resources)||void 0===r?void 0:r.iframe;if(i){this.saveVerifyTransactionUrl();const n=document.createElement("div");n.innerHTML=i,document.body.appendChild(n);const o=document.createElement("script");o.textContent='document.getElementById("tdsMmethodForm").submit();',n.appendChild(o);const r=document.getElementById("tdsMmethodTgtFrame");r?r.onload=()=>t(!0):(console.log("No redirection found"),e(!1))}else console.log("No redirection found"),e(!1)}))}getRedirectUrl(){var t,e,n;return null===(n=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.redirect_to_url)||void 0===n?void 0:n.url}redirectToChallenge(){const t=this.getRedirectUrl();t?(this.saveVerifyTransactionUrl(),window.location=t):console.log("No redirection found")}getURLParameters(){const t={},e=new URLSearchParams(window.location.search);for(const[n,o]of e)t[n]=o;return t}handleSuccessTransaction(t){return this.removeVerifyTransactionUrl(),console.log("Transacción autorizada."),t}handleDeclinedTransaction(t){return this.removeVerifyTransactionUrl(),t}handle3dsChallenge(t){return n(this,void 0,void 0,(function*(){const e=document.createElement("form");e.name="frm",e.method="POST",e.action=t.redirect_post_url;const n=document.createElement("input");n.type="hidden",n.name=t.creq,n.value=t.creq,e.appendChild(n);const o=document.createElement("input");o.type="hidden",o.name=t.term_url,o.value=t.TermUrl,e.appendChild(o),document.body.appendChild(e),e.submit(),yield this.verifyTransactionStatus()}))}handleTransactionResponse(t){return n(this,void 0,void 0,(function*(){const e=yield t.json();return"Pending"===e.status&&e.redirect_post_url?yield this.handle3dsChallenge(e):["Success","Authorized"].includes(e.status)?this.handleSuccessTransaction(e):(this.handleDeclinedTransaction(t),e)}))}verifyTransactionStatus(){return n(this,void 0,void 0,(function*(){const t=this.getUrlWithExpiration();if(t){const e=`${this.baseUrl}${t}`;try{const t=yield fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKey}`}});return 200!==t.status?(console.error("La verificación de la transacción falló."),this.removeVerifyTransactionUrl(),t):yield this.handleTransactionResponse(t)}catch(t){console.error("Error al verificar la transacción:",t),this.removeVerifyTransactionUrl()}}else console.log("No verify_transaction_status_url found")}))}}const h=Object.freeze({production:"https://app.tonder.io",sandbox:"https://sandbox.tonder.io",stage:"https://stage.tonder.io",development:"http://localhost:8000"});function p(t,e,o){return n(this,void 0,void 0,(function*(){try{const n=`${t}/api/v1/checkout-router/`,r=o,i=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${e}`},body:JSON.stringify(Object.assign(Object.assign({},r),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}))});if(i.status>=200&&i.status<=299)return yield i.json();{const t=yield i.json(),e=new Error("Failed to start checkout router");throw e.details=t,e}}catch(t){throw t}}))}function m(t,e,o=!0,r=null){return n(this,void 0,void 0,(function*(){let n=yield window.OpenPay;return n.setId(t),n.setApiKey(e),n.setSandboxMode(o),yield n.deviceData.setup({signal:r})}))}var y,f,g,v,A,_,b,E;class T{constructor({mode:t="stage",apiKey:e,apiKeyTonder:n,returnUrl:o,callBack:r=(()=>{})}){y.add(this),this.baseUrl="",this.cartTotal="0",this.metadata={},this.card={},this.currency="",f.set(this,void 0),this.apiKeyTonder=e||n||"",this.returnUrl=o,this.callBack=r,this.mode=t,this.baseUrl=h[this.mode]||h.stage,this.abortController=new AbortController,this.process3ds=new u({apiKey:e,baseUrl:this.baseUrl})}configureCheckout(t){"customer"in t&&o(this,y,"m",g).call(this,t.customer)}verify3dsTransaction(){return n(this,void 0,void 0,(function*(){const t=yield this.process3ds.verifyTransactionStatus(),e=yield o(this,y,"m",E).call(this,t);return this.process3ds.setPayload(e),this._handle3dsRedirect(e)}))}payment(t){return new Promise(((e,r)=>n(this,void 0,void 0,(function*(){var n,i;try{o(this,y,"m",g).call(this,t.customer),this._setCartTotal(null===(n=t.cart)||void 0===n?void 0:n.total),o(this,y,"m",v).call(this,null===(i=t.cart)||void 0===i?void 0:i.items),o(this,y,"m",A).call(this,t),o(this,y,"m",_).call(this,t),o(this,y,"m",b).call(this,t);const r=yield this._checkout(t);this.process3ds.setPayload(r),this.callBack&&this.callBack(r);(yield this._handle3dsRedirect(r))&&e(r)}catch(t){r(t)}}))))}_initializeCheckout(){return n(this,void 0,void 0,(function*(){const t=yield this._fetchMerchantData();t&&t.mercado_pago&&t.mercado_pago.active&&function(){try{const t=document.createElement("script");t.src="https://www.mercadopago.com/v2/security.js",t.setAttribute("view",""),t.onload=()=>{console.log("Mercado Pago script loaded successfully.")},t.onerror=t=>{console.error("Error loading Mercado Pago script:",t)},document.head.appendChild(t)}catch(t){console.error("Error attempting to inject Mercado Pago script:",t)}}()}))}_checkout(t){return n(this,void 0,void 0,(function*(){throw new Error("The #checkout method should be implement in child classes.")}))}_setCartTotal(t){throw new Error("The #setCartTotal method should be implement in child classes.")}_getCustomer(t=null){return n(this,void 0,void 0,(function*(){return o(this,f,"f")||function(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?r.call(t,n):r?r.value=n:e.set(t,n)}(this,f,yield function(t,e,o,r=null){return n(this,void 0,void 0,(function*(){const n=`${t}/api/v1/customer/`,i={email:o.email,first_name:null==o?void 0:o.firstName,last_name:null==o?void 0:o.lastName,phone:null==o?void 0:o.phone},s=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${e}`},signal:r,body:JSON.stringify(i)});if(201===s.status)return yield s.json();throw new Error(`Error: ${s.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,this.customer,t),"f"),o(this,f,"f")}))}_handleCheckout({card:e,payment_method:o,customer:r,isSandbox:i}){return n(this,void 0,void 0,(function*(){const{openpay_keys:a,reference:d,business:c}=this.merchantData,l=Number(this.cartTotal);try{let u;!u&&a.merchant_id&&a.public_key&&(u=yield m(a.merchant_id,a.public_key,i,this.abortController.signal));const{id:h,auth_token:y}=r,f={business:this.apiKeyTonder,client:y,billing_address_id:null,shipping_address_id:null,amount:l,status:"A",reference:d,is_oneclick:!0,items:this.cartItems},g=yield function(t,e,o){return n(this,void 0,void 0,(function*(){const n=`${t}/api/v1/orders/`,r=o,i=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${e}`},body:JSON.stringify(r)});if(201===i.status)return yield i.json();throw new Error(`Error: ${i.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,f),v=(new Date).toISOString(),A={business_pk:c.pk,client_id:h,amount:l,date:v,order_id:g.id},_=yield function(t,e,o){return n(this,void 0,void 0,(function*(){const n=`${t}/api/v1/business/${o.business_pk}/payments/`,r=o,i=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${e}`},body:JSON.stringify(r)});if(i.status>=200&&i.status<=299)return yield i.json();throw new Error(`Error: ${i.statusText}`)}))}(this.baseUrl,this.apiKeyTonder,A),b=Object.assign({name:t(this.customer,"firstName",t(this.customer,"name","")),last_name:t(this.customer,"lastName",t(this.customer,"lastname","")),email_client:t(this.customer,"email",""),phone_number:t(this.customer,"phone",""),return_url:this.returnUrl,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:l,title_ship:"shipping",description:"transaction",device_session_id:u||null,token_id:"",order_id:g.id,business_id:c.pk,payment_id:_.pk,source:"sdk",metadata:this.metadata,browser_info:s(),currency:this.currency},o?{payment_method:o}:{card:e}),E=yield p(this.baseUrl,this.apiKeyTonder,b);return E||!1}catch(t){throw console.log(t),t}}))}_fetchMerchantData(){return n(this,void 0,void 0,(function*(){try{return this.merchantData||(this.merchantData=yield r(this.baseUrl,this.apiKeyTonder,this.abortController.signal)),this.merchantData}catch(t){return this.merchantData}}))}_handle3dsRedirect(t){var e,o;return n(this,void 0,void 0,(function*(){if(t&&"next_action"in t?null===(o=null===(e=null==t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===o?void 0:o.iframe:null)this.process3ds.loadIframe().then((()=>{this.process3ds.verifyTransactionStatus()})).catch((t=>{console.log("Error loading iframe:",t)}));else{if(!this.process3ds.getRedirectUrl())return t;this.process3ds.redirectToChallenge()}}))}}f=new WeakMap,y=new WeakSet,g=function(t){t&&(this.customer=t)},v=function(t){this.cartItems=t},A=function(t){this.metadata=null==t?void 0:t.metadata},_=function(t){this.currency=null==t?void 0:t.currency},b=function(t){this.card=null==t?void 0:t.card},E=function(t){var e,o;return n(this,void 0,void 0,(function*(){if("Hard"===(null===(e=null==t?void 0:t.decline)||void 0===e?void 0:e.error_type))return t;if(["Success","Authorized"].includes(null==t?void 0:t.transaction_status))return t;if(t){const e={checkout_id:null===(o=t.checkout)||void 0===o?void 0:o.id};try{return yield p(this.baseUrl,this.apiKeyTonder,e)}catch(t){}return t}}))};const O=Object.freeze({saveCardError:"Ha ocurrido un error guardando la tarjeta. Inténtalo nuevamente.",removeCardError:"Ha ocurrido un error eliminado la tarjeta. Inténtalo nuevamente.",getCardsError:"Ha ocurrido un error obteniendo las tarjetas del customer. Inténtalo nuevamente.",cardExist:"La tarjeta fue registrada previamente.",removedCard:"Card deleted successfully",errorCheckout:"No se ha podido procesar el pago",cardSaved:"Tarjeta registrada con éxito.",getPaymentMethodsError:"Ha ocurrido un error obteniendo las métodos de pago del customer. Inténtalo nuevamente.",getBusinessError:"Ha ocurrido un error obteniendo los datos del comercio. Inténtalo nuevamente."});function S({baseUrl:t,apiKey:o,vault_id:r,vault_url:i,data:s}){return n(this,void 0,void 0,(function*(){const a=e.init({vaultID:r,vaultURL:i,getBearerToken:()=>n(this,void 0,void 0,(function*(){return yield function(t,e,o=null){return n(this,void 0,void 0,(function*(){const n=yield fetch(`${t}/api/v1/vault-token/`,{method:"GET",headers:{Authorization:`Token ${e}`},signal:o});if(n.ok)return(yield n.json()).token;throw new Error("Failed to retrieve bearer token")}))}(t,o)})),options:{logLevel:e.LogLevel.ERROR,env:e.Env.DEV}}),c=a.container(e.ContainerType.COLLECT),l=yield function(t,o){return n(this,void 0,void 0,(function*(){const r=yield function(t,o){return n(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(t).map((t=>n(this,void 0,void 0,(function*(){return{element:yield o.create({table:"cards",column:t,type:e.ElementType.INPUT_FIELD}),key:t}})))))}))}(t,o);return r?r.map((e=>new Promise((n=>{var o;const r=document.createElement("div");r.hidden=!0,r.id=`id-${e.key}`,null===(o=document.querySelector("body"))||void 0===o||o.appendChild(r),setTimeout((()=>{e.element.mount(`#id-${e.key}`),setInterval((()=>{if(e.element.isMounted()){const o=t[e.key];return e.element.update({value:o}),n(e.element.isMounted())}}),120)}),120)})))):[]}))}(s,c);if((yield Promise.all(l)).some((t=>!t)))throw d(Error("Ocurrió un error al montar los campos de la tarjeta"));try{const t=yield c.collect();if(t)return t.records[0].fields;throw d(Error("Por favor, verifica todos los campos de tu tarjeta"))}catch(t){throw d(t)}}))}const C=Object.freeze({SORIANA:"SORIANA",OXXO:"OXXO",SPEI:"SPEI",CODI:"CODI",MERCADOPAGO:"MERCADOPAGO",PAYPAL:"PAYPAL",COMERCIALMEXICANA:"COMERCIALMEXICANA",BANCOMER:"BANCOMER",WALMART:"WALMART",BODEGA:"BODEGA",SAMSCLUB:"SAMSCLUB",SUPERAMA:"SUPERAMA",CALIMAX:"CALIMAX",EXTRA:"EXTRA",CIRCULOK:"CIRCULOK",SEVEN11:"7ELEVEN",TELECOMM:"TELECOMM",BANORTE:"BANORTE",BENAVIDES:"BENAVIDES",DELAHORRO:"DELAHORRO",ELASTURIANO:"ELASTURIANO",WALDOS:"WALDOS",ALSUPER:"ALSUPER",KIOSKO:"KIOSKO",STAMARIA:"STAMARIA",LAMASBARATA:"LAMASBARATA",FARMROMA:"FARMROMA",FARMUNION:"FARMUNION",FARMATODO:"FARMATODO",SFDEASIS:"SFDEASIS",FARM911:"FARM911",FARMECONOMICAS:"FARMECONOMICAS",FARMMEDICITY:"FARMMEDICITY",RIANXEIRA:"RIANXEIRA",WESTERNUNION:"WESTERNUNION",ZONAPAGO:"ZONAPAGO",CAJALOSANDES:"CAJALOSANDES",CAJAPAITA:"CAJAPAITA",CAJASANTA:"CAJASANTA",CAJASULLANA:"CAJASULLANA",CAJATRUJILLO:"CAJATRUJILLO",EDPYME:"EDPYME",KASNET:"KASNET",NORANDINO:"NORANDINO",QAPAQ:"QAPAQ",RAIZ:"RAIZ",PAYSER:"PAYSER",WUNION:"WUNION",BANCOCONTINENTAL:"BANCOCONTINENTAL",GMONEY:"GMONEY",GOPAY:"GOPAY",WU:"WU",PUNTOSHEY:"PUNTOSHEY",AMPM:"AMPM",JUMBOMARKET:"JUMBOMARKET",SMELPUEBLO:"SMELPUEBLO",BAM:"BAM",REFACIL:"REFACIL",ACYVALORES:"ACYVALORES"}),j={[C.SORIANA]:{label:"Soriana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png"},[C.OXXO]:{label:"Oxxo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png"},[C.CODI]:{label:"CoDi",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png"},[C.SPEI]:{label:"SPEI",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png"},[C.PAYPAL]:{label:"Paypal",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png"},[C.COMERCIALMEXICANA]:{label:"Comercial Mexicana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png"},[C.BANCOMER]:{label:"Bancomer",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png"},[C.WALMART]:{label:"Walmart",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png"},[C.BODEGA]:{label:"Bodega Aurrera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png"},[C.SAMSCLUB]:{label:"Sam´s Club",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png"},[C.SUPERAMA]:{label:"Superama",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png"},[C.CALIMAX]:{label:"Calimax",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png"},[C.EXTRA]:{label:"Tiendas Extra",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png"},[C.CIRCULOK]:{label:"Círculo K",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png"},[C.SEVEN11]:{label:"7 Eleven",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png"},[C.TELECOMM]:{label:"Telecomm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png"},[C.BANORTE]:{label:"Banorte",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png"},[C.BENAVIDES]:{label:"Farmacias Benavides",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png"},[C.DELAHORRO]:{label:"Farmacias del Ahorro",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png"},[C.ELASTURIANO]:{label:"El Asturiano",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png"},[C.WALDOS]:{label:"Waldos",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png"},[C.ALSUPER]:{label:"Alsuper",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png"},[C.KIOSKO]:{label:"Kiosko",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png"},[C.STAMARIA]:{label:"Farmacias Santa María",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png"},[C.LAMASBARATA]:{label:"Farmacias la más barata",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png"},[C.FARMROMA]:{label:"Farmacias Roma",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png"},[C.FARMUNION]:{label:"Pago en Farmacias Unión",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png"},[C.FARMATODO]:{label:"Pago en Farmacias Farmatodo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png\t"},[C.SFDEASIS]:{label:"Pago en Farmacias San Francisco de Asís",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png"},[C.FARM911]:{label:"Farmacias 911",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.FARMECONOMICAS]:{label:"Farmacias Economicas",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.FARMMEDICITY]:{label:"Farmacias Medicity",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.RIANXEIRA]:{label:"Rianxeira",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.WESTERNUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.ZONAPAGO]:{label:"Zona Pago",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.CAJALOSANDES]:{label:"Caja Los Andes",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.CAJAPAITA]:{label:"Caja Paita",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.CAJASANTA]:{label:"Caja Santa",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.CAJASULLANA]:{label:"Caja Sullana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.CAJATRUJILLO]:{label:"Caja Trujillo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.EDPYME]:{label:"Edpyme",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.KASNET]:{label:"KasNet",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.NORANDINO]:{label:"Norandino",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.QAPAQ]:{label:"Qapaq",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.RAIZ]:{label:"Raiz",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.PAYSER]:{label:"Paysera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.WUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.BANCOCONTINENTAL]:{label:"Banco Continental",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.GMONEY]:{label:"Go money",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.GOPAY]:{label:"Go pay",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.WU]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.PUNTOSHEY]:{label:"Puntoshey",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.AMPM]:{label:"Ampm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.JUMBOMARKET]:{label:"Jumbomarket",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.SMELPUEBLO]:{label:"Smelpueblo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.BAM]:{label:"Bam",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.REFACIL]:{label:"Refacil",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[C.ACYVALORES]:{label:"Acyvalores",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"}},w=t=>{const e=t.toUpperCase().trim().replace(/\s+/g,"");return j[e]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}};class R extends T{constructor({apiKey:t,mode:e,returnUrl:n,callBack:o}){super({mode:e,apiKey:t,returnUrl:n,callBack:o}),this.activeAPMs=[]}injectCheckout(){return n(this,void 0,void 0,(function*(){yield this._initializeCheckout()}))}getCustomerCards(){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:t}=yield this._getCustomer(),e=yield function(t,e,o,r=null){return n(this,void 0,void 0,(function*(){try{const n=`${t}/api/v1/business/${o}/cards/`,i=yield fetch(n,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();const s=yield i.json();throw yield c(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.merchantData.business.pk);return Object.assign(Object.assign({},e),{cards:e.cards.map((t=>{return Object.assign(Object.assign({},t),{icon:(e=t.fields.card_scheme,"Visa"===e?"https://d35a75syrgujp0.cloudfront.net/cards/visa.png":"Mastercard"===e?"https://d35a75syrgujp0.cloudfront.net/cards/mastercard.png":"American Express"===e?"https://d35a75syrgujp0.cloudfront.net/cards/american_express.png":"https://d35a75syrgujp0.cloudfront.net/cards/default_card.png")});var e}))})}catch(t){throw l({message:O.getCardsError},t)}}))}saveCustomerCard(t){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{vault_id:o,vault_url:r,business:i}=this.merchantData,s=yield S({vault_id:o,vault_url:r,data:t,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder});return yield function(t,e,o,r){return n(this,void 0,void 0,(function*(){try{const n=`${t}/api/v1/business/${o}/cards/`,i=yield fetch(n,{method:"POST",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},body:JSON.stringify(r)});if(i.ok)return yield i.json();const s=yield i.json();throw yield c(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,e,null==i?void 0:i.pk,s)}catch(t){throw l({message:O.saveCardError},t)}}))}removeCustomerCard(t){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{business:o}=this.merchantData;return yield function(t,e,o="",r){return n(this,void 0,void 0,(function*(){try{const n=`${t}/api/v1/business/${r}/cards/${o}`,i=yield fetch(n,{method:"DELETE",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"}});if(204===i.status)return O.cardSaved;if(i.ok&&"json"in i)return yield i.json();const s=yield i.json();throw yield c(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,e,t,null==o?void 0:o.pk)}catch(t){throw l({message:O.removeCardError},t)}}))}getCustomerPaymentMethods(){return n(this,void 0,void 0,(function*(){try{const t=yield function(t,e,o={status:"active",pagesize:"10000"},r=null){return n(this,void 0,void 0,(function*(){try{const n=new URLSearchParams(o).toString(),i=yield fetch(`${t}/api/v1/payment_methods?${n}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();const s=yield i.json();throw yield c(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,this.apiKeyTonder);return(t&&"results"in t&&t.results.length>0?t.results:[]).filter((t=>"cards"!==t.category.toLowerCase())).map((t=>Object.assign({id:t.pk,payment_method:t.payment_method,priority:t.priority,category:t.category},w(t.payment_method)))).sort(((t,e)=>t.priority-e.priority))}catch(t){throw l({message:O.getPaymentMethodsError},t)}}))}getBusiness(){return n(this,void 0,void 0,(function*(){try{return yield r(this.baseUrl,this.apiKeyTonder,this.abortController.signal)}catch(t){throw l({message:O.getBusinessError},t)}}))}getOpenpayDeviceSessionID(t,e,o){return n(this,void 0,void 0,(function*(){try{return yield m(t,e,o)}catch(t){throw d(t)}}))}getSkyflowTokens({vault_id:t,vault_url:e,data:o}){return n(this,void 0,void 0,(function*(){return yield S({vault_id:t,vault_url:e,data:o,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})}))}_setCartTotal(t){this.cartTotal=t}_checkout({card:t,payment_method:e,isSandbox:o}){return n(this,void 0,void 0,(function*(){yield this._fetchMerchantData();const n=yield this._getCustomer(this.abortController.signal),{vault_id:r,vault_url:i}=this.merchantData;let s;return e&&""===e&&null!==e||(s="string"==typeof t?{skyflow_id:t}:yield S({vault_id:r,vault_url:i,data:Object.assign(Object.assign({},t),{card_number:t.card_number.replace(/\s+/g,"")}),baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})),yield this._handleCheckout({card:s,payment_method:e,customer:n,isSandbox:o})}))}customerRegister(t){return n(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/customer/`,n={email:t},o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},signal:this.abortController.signal,body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}createOrder(t){return n(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/orders/`,n=t,o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}createPayment(t){return n(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/business/${t.business_pk}/payments/`,n=t,o=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}startCheckoutRouter(t){return n(this,void 0,void 0,(function*(){const e=yield p(this.baseUrl,this.apiKeyTonder,t);if(yield this.init3DSRedirect(e))return e}))}init3DSRedirect(t){return n(this,void 0,void 0,(function*(){return this.process3ds.setPayload(t),yield this._handle3dsRedirect(t)}))}startCheckoutRouterFull(t){return n(this,void 0,void 0,(function*(){try{const{order:e,total:n,customer:o,skyflowTokens:r,return_url:a,isSandbox:d,metadata:c,currency:l,payment_method:u}=t,h=yield this._fetchMerchantData(),y=yield this.customerRegister(o.email);if(!(y&&"auth_token"in y&&h&&"reference"in h))throw new i({code:"500",body:h,name:"Keys error",message:"Merchant or customer reposne errors"});{const t={business:this.apiKeyTonder,client:y.auth_token,billing_address_id:null,shipping_address_id:null,amount:n,reference:h.reference,is_oneclick:!0,items:e.items},f=yield this.createOrder(t),g=(new Date).toISOString();if(!("id"in f&&"id"in y&&"business"in h))throw new i({code:"500",body:f,name:"Keys error",message:"Order response errors"});{const t={business_pk:h.business.pk,amount:n,date:g,order_id:f.id,client_id:y.id},e=yield this.createPayment(t);let i;const{openpay_keys:v,business:A}=h;v.merchant_id&&v.public_key&&(i=yield m(v.merchant_id,v.public_key,d));const _=Object.assign(Object.assign({name:o.name,last_name:o.lastname,email_client:o.email,phone_number:o.phone,return_url:a,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:n,title_ship:"shipping",description:"transaction",device_session_id:i||null,token_id:"",order_id:"id"in f&&f.id,business_id:A.pk,payment_id:"pk"in e&&e.pk,source:"sdk",metadata:c,browser_info:s(),currency:l},u?{payment_method:u}:{card:r}),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}),b=yield p(this.baseUrl,this.apiKeyTonder,_);if(yield this.init3DSRedirect(b))return b}}}catch(t){throw d(t)}}))}registerCustomerCard(t,e){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const n=yield fetch(`${this.baseUrl}/api/v1/business/${a(this.merchantData)}/cards/`,{method:"POST",headers:{Authorization:`Token ${t}`,"Content-Type":"application/json"},body:JSON.stringify(Object.assign({},e))});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}deleteCustomerCard(t,e=""){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const n=yield fetch(`${this.baseUrl}/api/v1/business/${a(this.merchantData)}/cards/${e}`,{method:"DELETE",headers:{Authorization:`Token ${t}`,"Content-Type":"application/json"},signal:this.abortController.signal});if(n.ok)return!0;throw yield c(n)}catch(t){throw d(t)}}))}getActiveAPMs(){return n(this,void 0,void 0,(function*(){try{const t=yield function(t,e,o="?status=active&page_size=10000&country=México",r=null){return n(this,void 0,void 0,(function*(){try{const n=yield fetch(`${t}/api/v1/payment_methods${o}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}(this.baseUrl,this.apiKeyTonder),e=t&&t.results&&t.results.length>0?t.results:[];return this.activeAPMs=e.filter((t=>"cards"!==t.category.toLowerCase())).map((t=>Object.assign({id:t.pk,payment_method:t.payment_method,priority:t.priority,category:t.category},w(t.payment_method)))).sort(((t,e)=>t.priority-e.priority)),this.activeAPMs}catch(t){return console.error("Error getting APMS",t),[]}}))}}function M(t){return/^\d{12,19}$/.test(t)&&P(t)}function I(t){return/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/.test(t)}function N(t){return/^\d{3,4}$/.test(t)}function k(t){return/^(0[1-9]|1[0-2])$/.test(t)}function U(t){if(!/^\d{2}$/.test(t))return!1;const e=(new Date).getFullYear()%100;return parseInt(t,10)>=e}const P=t=>{const e=`${t}`.split("").reverse().map((t=>Number.parseInt(t))),n=e.shift();let o=e.reduce(((t,e,n)=>n%2!=0?t+e:t+((e*=2)>9?e-9:e)),0);return o+=n,o%10==0};export{R as LiteCheckout,N as validateCVV,M as validateCardNumber,I as validateCardholderName,k as validateExpirationMonth,U as validateExpirationYear};
|
package/dist/types/checkout.d.ts
CHANGED
package/dist/types/commons.d.ts
CHANGED
|
@@ -78,7 +78,9 @@ export type APM = {
|
|
|
78
78
|
label: string;
|
|
79
79
|
};
|
|
80
80
|
export interface IConfigureCheckout {
|
|
81
|
-
customer: ICustomer
|
|
81
|
+
customer: ICustomer | {
|
|
82
|
+
email: string;
|
|
83
|
+
};
|
|
82
84
|
}
|
|
83
85
|
export interface IInlineCheckoutBaseOptions {
|
|
84
86
|
mode?: "production" | "sandbox" | "stage" | "development";
|
|
@@ -98,7 +100,7 @@ export interface IInlineCheckoutBaseOptions {
|
|
|
98
100
|
*/
|
|
99
101
|
signal?: AbortSignal;
|
|
100
102
|
apiKey: string;
|
|
101
|
-
returnUrl
|
|
103
|
+
returnUrl?: string;
|
|
102
104
|
callBack?: (response: any) => void;
|
|
103
105
|
}
|
|
104
106
|
export interface IApiError {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonder.io/ionic-lite-sdk",
|
|
3
|
-
"version": "0.0.35-beta.
|
|
3
|
+
"version": "0.0.35-beta.12",
|
|
4
4
|
"description": "Tonder ionic lite SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/types/index.d.ts",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"author": "",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"lodash.get": "^4.4.2",
|
|
15
16
|
"skyflow-js": "^1.34.1",
|
|
16
17
|
"ts-node": "^10.9.2"
|
|
17
18
|
},
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"@rollup/plugin-typescript": "11.1.6",
|
|
25
26
|
"@types/crypto-js": "^4.2.2",
|
|
26
27
|
"@types/jest": "^29.5.11",
|
|
28
|
+
"@types/lodash.get": "^4.4.9",
|
|
27
29
|
"@types/node": "^20.11.5",
|
|
28
30
|
"jest": "^29.7.0",
|
|
29
31
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -22,31 +22,19 @@ import {
|
|
|
22
22
|
StartCheckoutResponse,
|
|
23
23
|
ICardFields,
|
|
24
24
|
} from "../types";
|
|
25
|
+
import { get } from "lodash"
|
|
25
26
|
export class BaseInlineCheckout {
|
|
26
27
|
baseUrl = "";
|
|
27
28
|
cartTotal = "0";
|
|
28
29
|
process3ds: ThreeDSHandler;
|
|
29
30
|
mode?: "production" | "sandbox" | "stage" | "development" | undefined;
|
|
30
31
|
apiKeyTonder: string;
|
|
31
|
-
returnUrl
|
|
32
|
+
returnUrl?: string;
|
|
32
33
|
callBack?: ((response: any) => void) | undefined;
|
|
33
34
|
merchantData?: Business;
|
|
34
35
|
abortController: AbortController;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
name?: string;
|
|
38
|
-
lastname?: string;
|
|
39
|
-
|
|
40
|
-
firstName?: string;
|
|
41
|
-
lastName?: string;
|
|
42
|
-
country?: string;
|
|
43
|
-
address?: string;
|
|
44
|
-
city?: string;
|
|
45
|
-
state?: string;
|
|
46
|
-
postCode?: string;
|
|
47
|
-
email?: string;
|
|
48
|
-
phone?: string;
|
|
49
|
-
customer?: ICustomer;
|
|
36
|
+
|
|
37
|
+
customer?: ICustomer | {email: string};
|
|
50
38
|
|
|
51
39
|
cartItems?: IItem[];
|
|
52
40
|
metadata = {};
|
|
@@ -209,10 +197,10 @@ export class BaseInlineCheckout {
|
|
|
209
197
|
|
|
210
198
|
// Checkout router
|
|
211
199
|
const routerItems = {
|
|
212
|
-
name: this.firstName
|
|
213
|
-
last_name: this.lastName
|
|
214
|
-
email_client: this.email,
|
|
215
|
-
phone_number: this.phone,
|
|
200
|
+
name: get(this.customer,"firstName",get(this.customer,"name","")),
|
|
201
|
+
last_name: get(this.customer,"lastName",get(this.customer,"lastname","")),
|
|
202
|
+
email_client: get(this.customer,"email", ""),
|
|
203
|
+
phone_number: get(this.customer,"phone", ""),
|
|
216
204
|
return_url: this.returnUrl,
|
|
217
205
|
id_product: "no_id",
|
|
218
206
|
quantity_product: 1,
|
|
@@ -265,18 +253,9 @@ export class BaseInlineCheckout {
|
|
|
265
253
|
}
|
|
266
254
|
}
|
|
267
255
|
|
|
268
|
-
#handleCustomer(customer: ICustomer) {
|
|
256
|
+
#handleCustomer(customer: ICustomer | { email: string}) {
|
|
269
257
|
if (!customer) return;
|
|
270
258
|
|
|
271
|
-
this.firstName = customer?.firstName;
|
|
272
|
-
this.lastName = customer?.lastName;
|
|
273
|
-
this.country = customer?.country;
|
|
274
|
-
this.address = customer?.street;
|
|
275
|
-
this.city = customer?.city;
|
|
276
|
-
this.state = customer?.state;
|
|
277
|
-
this.postCode = customer?.postCode;
|
|
278
|
-
this.email = customer?.email;
|
|
279
|
-
this.phone = customer?.phone;
|
|
280
259
|
this.customer = customer;
|
|
281
260
|
}
|
|
282
261
|
|
package/src/types/checkout.ts
CHANGED
package/src/types/commons.ts
CHANGED
|
@@ -1,125 +1,124 @@
|
|
|
1
|
-
import {ICustomer} from "./customer";
|
|
1
|
+
import { ICustomer } from "./customer";
|
|
2
2
|
|
|
3
3
|
export type Business = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
business: {
|
|
5
|
+
pk: number;
|
|
6
|
+
name: string;
|
|
7
|
+
categories: {
|
|
8
|
+
pk: number;
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
web: string;
|
|
12
|
+
logo: string;
|
|
13
|
+
full_logo_url: string;
|
|
14
|
+
background_color: string;
|
|
15
|
+
primary_color: string;
|
|
16
|
+
checkout_mode: boolean;
|
|
17
|
+
textCheckoutColor: string;
|
|
18
|
+
textDetailsColor: string;
|
|
19
|
+
checkout_logo: string;
|
|
20
|
+
};
|
|
21
|
+
openpay_keys: {
|
|
22
|
+
merchant_id: string;
|
|
23
|
+
public_key: string;
|
|
24
|
+
};
|
|
25
|
+
fintoc_keys: {
|
|
26
|
+
public_key: string;
|
|
27
|
+
};
|
|
28
|
+
mercado_pago: {
|
|
29
|
+
active: boolean;
|
|
30
|
+
};
|
|
31
|
+
vault_id: string;
|
|
32
|
+
vault_url: string;
|
|
33
|
+
reference: number;
|
|
34
|
+
is_installments_available: boolean;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export type Customer = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
firstName: string;
|
|
39
|
+
lastName: string;
|
|
40
|
+
country: string;
|
|
41
|
+
street: string;
|
|
42
|
+
city: string;
|
|
43
|
+
state: string;
|
|
44
|
+
postCode: string;
|
|
45
|
+
email: string;
|
|
46
|
+
phone: string;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export type OrderItem = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
description: string;
|
|
51
|
+
quantity: number;
|
|
52
|
+
price_unit: number;
|
|
53
|
+
discount: number;
|
|
54
|
+
taxes: number;
|
|
55
|
+
product_reference: number;
|
|
56
|
+
name: string;
|
|
57
|
+
amount_total: number;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
export type PaymentData = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
customer: Customer;
|
|
62
|
+
currency: string;
|
|
63
|
+
cart: {
|
|
64
|
+
total: string | number;
|
|
65
|
+
items: OrderItem[];
|
|
66
|
+
};
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export type TonderAPM = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
70
|
+
pk: string;
|
|
71
|
+
payment_method: string;
|
|
72
|
+
priority: number;
|
|
73
|
+
category: string;
|
|
74
|
+
unavailable_countries: string[];
|
|
75
|
+
status: string;
|
|
76
|
+
};
|
|
77
77
|
|
|
78
78
|
export type APM = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
79
|
+
id: string;
|
|
80
|
+
payment_method: string;
|
|
81
|
+
priority: number;
|
|
82
|
+
category: string;
|
|
83
|
+
icon: string;
|
|
84
|
+
label: string;
|
|
85
|
+
};
|
|
87
86
|
|
|
88
87
|
export interface IConfigureCheckout {
|
|
89
|
-
|
|
88
|
+
customer: ICustomer | { email: string };
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
export interface IInlineCheckoutBaseOptions {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
mode?: "production" | "sandbox" | "stage" | "development";
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated This property is deprecated and will be removed in a future release.
|
|
95
|
+
* `baseUrlTonder` is no longer required.
|
|
96
|
+
*/
|
|
97
|
+
baseUrlTonder?: string;
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated This property is deprecated and will be removed in a future release.
|
|
100
|
+
* Use `apiKey` instead, as `apiKeyTonder` is no longer required.
|
|
101
|
+
*/
|
|
102
|
+
apiKeyTonder?: string;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated This property is deprecated and will be removed in a future release.
|
|
105
|
+
* `signal` is no longer required.
|
|
106
|
+
*/
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
apiKey: string;
|
|
109
|
+
returnUrl?: string;
|
|
110
|
+
callBack?: (response: any) => void;
|
|
112
111
|
}
|
|
113
112
|
export interface IApiError {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
code: string;
|
|
114
|
+
body: Record<string, string> | string;
|
|
115
|
+
name: string;
|
|
116
|
+
message: string;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
export interface IPublicError {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
120
|
+
status: string;
|
|
121
|
+
code: number;
|
|
122
|
+
message: string;
|
|
123
|
+
detail: Record<string, any> | string;
|
|
124
|
+
}
|