@tonder.io/ionic-lite-sdk 0.0.42-beta.8 → 0.0.50-beta.DEV1406.1
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 +3 -0
- package/dist/classes/BaseInlineCheckout.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/checkout.d.ts +3 -1
- package/dist/types/commons.d.ts +2 -2
- package/dist/types/liteInlineCheckout.d.ts +2 -1
- package/package.json +1 -1
- package/src/classes/BaseInlineCheckout.ts +14 -9
- package/src/types/checkout.ts +1 -1
- package/src/types/commons.ts +2 -2
- package/src/types/liteInlineCheckout.ts +2 -1
package/README.md
CHANGED
|
@@ -239,6 +239,9 @@ if (
|
|
|
239
239
|
- `payment(data)`: Process a payment
|
|
240
240
|
- `verify3dsTransaction()`: Verify a 3DS transaction
|
|
241
241
|
|
|
242
|
+
> **Important Note about SaveCard functionality**:
|
|
243
|
+
> To properly implement the SaveCard feature, you must use a SecureToken. For detailed implementation instructions and best practices, please refer to our official documentation on [How to use SecureToken for secure card saving](https://docs.tonder.io/integration/sdks/secure-token#how-to-use-securetoken-for-secure-card-saving).
|
|
244
|
+
|
|
242
245
|
|
|
243
246
|
## Examples
|
|
244
247
|
|
|
@@ -32,7 +32,7 @@ export declare class BaseInlineCheckout {
|
|
|
32
32
|
configureCheckout(data: IConfigureCheckout): void;
|
|
33
33
|
verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
|
|
34
34
|
payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
|
|
35
|
-
getSecureToken(): Promise<GetSecureTokenResponse>;
|
|
35
|
+
getSecureToken(secretApikey: string): Promise<GetSecureTokenResponse>;
|
|
36
36
|
_initializeCheckout(): Promise<void>;
|
|
37
37
|
_checkout(data: any): Promise<any>;
|
|
38
38
|
_setCartTotal(total: string | number): void;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{get as t}from"lodash";import e from"skyflow-js";function o(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{d(n.next(t))}catch(t){i(t)}}function a(t){try{d(n.throw(t))}catch(t){i(t)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))}function n(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)}function r(t,e,n){return o(this,void 0,void 0,(function*(){const o=yield fetch(`${t}/api/v1/payments/business/${e}`,{headers:{Authorization:`Token ${e}`},signal:n});return yield o.json()}))}"function"==typeof SuppressedError&&SuppressedError;class i{constructor({code:t,body:e,name:o,message:n,stack:r}){this.code=t,this.body=e,this.name=o,this.message=n,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)=>o(void 0,void 0,void 0,(function*(){let o,n,r="Error";t&&"json"in t&&(o=yield null==t?void 0:t.json()),t&&"status"in t&&(n=t.status.toString()),!o&&t&&"text"in t&&(r=yield t.text()),(null==o?void 0:o.detail)&&(r=o.detail);return new i({code:n,body:o,name:n,message:r,stack:e})}));function l(t,e){var o,n;let r=200;try{r=Number((null==e?void 0:e.code)||200)}catch(t){}const i={status:"error",code:r,message:"",detail:(null===(o=null==e?void 0:e.body)||void 0===o?void 0:o.detail)||(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.error)||e.body||"Ocurrio un error inesperado."};return Object.assign(Object.assign({},i),t)}class u{constructor({payload:t=null,apiKey:e,baseUrl:o,customization:n,tdsIframeId:r,tonderPayButtonId:i,callBack:s}){this.localStorageKey="verify_transaction_status_url",this.customization={saveCards:{showSaveCardOption:!0,showSaved:!0,autoSave:!1},redirectOnComplete:!0},this.setPayload=t=>{this.payload=t},this.baseUrl=o,this.apiKey=e,this.payload=t,this.tdsIframeId=r,this.tonderPayButtonId=i,this.customization=Object.assign(Object.assign(Object.assign({},this.customization),n||{}),{saveCards:Object.assign(Object.assign({},this.customization.saveCards),(null==n?void 0:n.saveCards)||{})}),this.callBack=s}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,o,n,r,i;const s=null===(o=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===o?void 0:o.verify_transaction_status_url;if(s)this.saveUrlWithExpiration(s);else{const t=null===(i=null===(r=null===(n=this.payload)||void 0===n?void 0:n.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,o;if(null===(o=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===o?void 0:o.iframe)return new Promise(((t,e)=>{var o,n,r;const i=null===(r=null===(n=null===(o=this.payload)||void 0===o?void 0:o.next_action)||void 0===n?void 0:n.iframe_resources)||void 0===r?void 0:r.iframe;if(i){this.saveVerifyTransactionUrl();const o=document.createElement("div");o.innerHTML=i,document.body.appendChild(o);const n=document.createElement("script");n.textContent='document.getElementById("tdsMmethodForm").submit();',o.appendChild(n);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,o;return null===(o=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===o?void 0:o.url}redirectToChallenge(){var t;const e=this.getRedirectUrl();if(e)if(this.saveVerifyTransactionUrl(),this.customization)if(null===(t=this.customization)||void 0===t?void 0:t.redirectOnComplete)window.location=e;else{const t=document.querySelector(`#${this.tdsIframeId}`);if(t){t.setAttribute("src",e),t.setAttribute("style","display: block");const n=this,r=e=>o(this,void 0,void 0,(function*(){const e=()=>{try{const t=document.querySelector(`#${this.tonderPayButtonId}`);t&&(t.disabled=!1)}catch(t){}t&&t.setAttribute("style","display: none"),n.callBack&&n.callBack(n.payload),t.removeEventListener("load",r)},i=t=>o(this,void 0,void 0,(function*(){const r=yield new Promise(((e,o)=>e(t)));if(r){if((t=>"Pending"!==(null==t?void 0:t.transaction_status))(r))return e();{const t=setTimeout((()=>o(this,void 0,void 0,(function*(){clearTimeout(t),yield i(n.requestTransactionStatus())}))),7e3)}}}));yield i(n.requestTransactionStatus())}));t.addEventListener("load",r)}else console.log("No iframe found")}else window.location=e;else this.callBack&&this.callBack(this.payload)}requestTransactionStatus(){return o(this,void 0,void 0,(function*(){const t=this.getUrlWithExpiration(),e=`${this.baseUrl}${t}`,o=yield fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKey}`}});if(200!==o.status)return console.error("La verificación de la transacción falló."),null;return yield o.json()}))}getURLParameters(){const t={},e=new URLSearchParams(window.location.search);for(const[o,n]of e)t[o]=n;return t}handleSuccessTransaction(t){return this.removeVerifyTransactionUrl(),console.log("Transacción autorizada."),t}handleDeclinedTransaction(t){return this.removeVerifyTransactionUrl(),t}handle3dsChallenge(t){return o(this,void 0,void 0,(function*(){const e=document.createElement("form");e.name="frm",e.method="POST",e.action=t.redirect_post_url;const o=document.createElement("input");o.type="hidden",o.name=t.creq,o.value=t.creq,e.appendChild(o);const n=document.createElement("input");n.type="hidden",n.name=t.term_url,n.value=t.TermUrl,e.appendChild(n),document.body.appendChild(e),e.submit(),yield this.verifyTransactionStatus()}))}handleTransactionResponse(t){return o(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 o(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,n){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/checkout-router/`,r=n,i=yield fetch(o,{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,n=!0,r=null){return o(this,void 0,void 0,(function*(){let o=yield window.OpenPay;return o.setId(t),o.setApiKey(e),o.setSandboxMode(n),yield o.deviceData.setup({signal:r})}))}const y=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.",secureTokenError:"Ha ocurrido un error obteniendo el token de seguridad."});var f,v,g,_,A,b,T,E,C;class O{constructor({mode:t="stage",customization:e,apiKey:o,apiKeyTonder:n,returnUrl:r,tdsIframeId:i,callBack:s=(()=>{}),baseUrlTonder:a,tonderPayButtonId:d}){f.add(this),this.baseUrl="",this.cartTotal="0",this.secureToken="",this.customization={saveCards:{showSaveCardOption:!0,showSaved:!0,autoSave:!1},redirectOnComplete:!0},this.metadata={},this.card={},this.currency="",v.set(this,void 0),this.apiKeyTonder=n||o||"",this.returnUrl=r,this.callBack=s,this.mode=t,this.customer={},this.baseUrl=a||h[this.mode]||h.stage,this.abortController=new AbortController,this.process3ds=new u({apiKey:o,baseUrl:this.baseUrl,customization:e,tdsIframeId:i,tonderPayButtonId:d,callBack:s}),this.tdsIframeId=i,this.customization=Object.assign(Object.assign(Object.assign({},this.customization),e||{}),{saveCards:Object.assign(Object.assign({},this.customization.saveCards),(null==e?void 0:e.saveCards)||{})})}configureCheckout(t){"customer"in t&&n(this,f,"m",g).call(this,t.customer),"secureToken"in t&&n(this,f,"m",_).call(this,t.secureToken)}verify3dsTransaction(){return o(this,void 0,void 0,(function*(){const t=yield this.process3ds.verifyTransactionStatus(),e=yield n(this,f,"m",C).call(this,t);return this.process3ds.setPayload(e),this._handle3dsRedirect(e)}))}payment(t){return new Promise(((e,r)=>o(this,void 0,void 0,(function*(){var o,i;try{n(this,f,"m",g).call(this,t.customer),this._setCartTotal(null===(o=t.cart)||void 0===o?void 0:o.total),n(this,f,"m",A).call(this,null===(i=t.cart)||void 0===i?void 0:i.items),n(this,f,"m",b).call(this,t),n(this,f,"m",T).call(this,t),n(this,f,"m",E).call(this,t);const r=yield this._checkout(t);this.process3ds.setPayload(r);if(yield this._handle3dsRedirect(r)){try{const t=document.querySelector(`#${this.tonderPayButtonId}`);t&&(t.disabled=!1)}catch(t){}this.callBack&&this.callBack(r),e(r)}}catch(t){r(t)}}))))}getSecureToken(){return o(this,void 0,void 0,(function*(){try{return yield function(t,e,n=null){return o(this,void 0,void 0,(function*(){try{const o=yield fetch(`${t}/api/secure-token/`,{method:"POST",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:n});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}(this.baseUrl,this.secureToken)}catch(t){throw l({message:y.secureTokenError},t)}}))}_initializeCheckout(){return o(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 o(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 o(this,void 0,void 0,(function*(){return n(this,v,"f")||function(t,e,o,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?r.call(t,o):r?r.value=o:e.set(t,o)}(this,v,yield function(t,e,n,r=null){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/customer/`,i={email:n.email,first_name:null==n?void 0:n.firstName,last_name:null==n?void 0:n.lastName,phone:null==n?void 0:n.phone},s=yield fetch(o,{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"),n(this,v,"f")}))}_handleCheckout({card:e,payment_method:n,customer:r,isSandbox:i,returnUrl:a}){return o(this,void 0,void 0,(function*(){const{openpay_keys:d,reference:c,business:l}=this.merchantData,u=Number(this.cartTotal);try{let h;!h&&d.merchant_id&&d.public_key&&(h=yield m(d.merchant_id,d.public_key,i,this.abortController.signal));const{id:y,auth_token:f}=r,v={business:this.apiKeyTonder,client:f,billing_address_id:null,shipping_address_id:null,amount:u,status:"A",reference:c,is_oneclick:!0,items:this.cartItems},g=yield function(t,e,n){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/orders/`,r=n,i=yield fetch(o,{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,v),_=(new Date).toISOString(),A={business_pk:l.pk,client_id:y,amount:u,date:_,order_id:g.id},b=yield function(t,e,n){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/business/${n.business_pk}/payments/`,r=n,i=yield fetch(o,{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),T=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:a||this.returnUrl,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:u,title_ship:"shipping",description:"transaction",device_session_id:h||null,token_id:"",order_id:g.id,business_id:l.pk,payment_id:b.pk,source:"sdk",metadata:this.metadata,browser_info:s(),currency:this.currency},n?{payment_method:n}:{card:e}),E=yield p(this.baseUrl,this.apiKeyTonder,T);return E||!1}catch(t){throw console.log(t),t}}))}_fetchMerchantData(){return o(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}}))}_getCustomerCards(t,e){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r,i=null){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${r}/cards/`,s=yield fetch(o,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e},signal:i});if(s.ok)return yield s.json();if(401===s.status)return{user_id:0,cards:[]};throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,e)}))}_saveCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r,i){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${r}/cards/`,s=yield fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e},body:JSON.stringify(i)});if(s.ok)return yield s.json();throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,e,n)}))}_removeCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r="",i){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${i}/cards/${r}`,s=yield fetch(o,{method:"DELETE",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e}});if(204===s.status)return y.removedCard;if(s.ok&&"json"in s)return yield s.json();throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,n,e)}))}_fetchCustomerPaymentMethods(){return o(this,void 0,void 0,(function*(){return yield function(t,e,n={status:"active",pagesize:"10000"},r=null){return o(this,void 0,void 0,(function*(){try{const o=new URLSearchParams(n).toString(),i=yield fetch(`${t}/api/v1/payment_methods?${o}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();throw yield c(i)}catch(t){throw d(t)}}))}(this.baseUrl,this.apiKeyTonder)}))}_handle3dsRedirect(t){var e,n;return o(this,void 0,void 0,(function*(){if(t&&"next_action"in t?null===(n=null===(e=null==t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===n?void 0:n.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()}}))}}function S({baseUrl:t,apiKey:n,vault_id:r,vault_url:i,data:s}){return o(this,void 0,void 0,(function*(){const a=e.init({vaultID:r,vaultURL:i,getBearerToken:()=>o(this,void 0,void 0,(function*(){return yield function(t,e,n=null){return o(this,void 0,void 0,(function*(){const o=yield fetch(`${t}/api/v1/vault-token/`,{method:"GET",headers:{Authorization:`Token ${e}`},signal:n});if(o.ok)return(yield o.json()).token;throw new Error("Failed to retrieve bearer token")}))}(t,n)})),options:{logLevel:e.LogLevel.ERROR,env:e.Env.DEV}}),c=a.container(e.ContainerType.COLLECT),l=yield function(t,n){return o(this,void 0,void 0,(function*(){const r=yield function(t,n){return o(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(t).map((t=>o(this,void 0,void 0,(function*(){return{element:yield n.create({table:"cards",column:t,type:e.ElementType.INPUT_FIELD}),key:t}})))))}))}(t,n);return r?r.map((e=>new Promise((o=>{var n;const r=document.createElement("div");r.hidden=!0,r.id=`id-${e.key}`,null===(n=document.querySelector("body"))||void 0===n||n.appendChild(r),setTimeout((()=>{e.element.mount(`#id-${e.key}`),setInterval((()=>{if(e.element.isMounted()){const n=t[e.key];return e.element.update({value:n}),o(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)}}))}v=new WeakMap,f=new WeakSet,g=function(t){t&&(this.customer=t)},_=function(t){this.secureToken=t},A=function(t){this.cartItems=t},b=function(t){this.metadata=null==t?void 0:t.metadata},T=function(t){this.currency=null==t?void 0:t.currency},E=function(t){this.card=null==t?void 0:t.card},C=function(t){var e,n;return o(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===(n=t.checkout)||void 0===n?void 0:n.id};try{return yield p(this.baseUrl,this.apiKeyTonder,e)}catch(t){}return t}}))};const j=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"}),w={[j.SORIANA]:{label:"Soriana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png"},[j.OXXO]:{label:"Oxxo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png"},[j.CODI]:{label:"CoDi",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png"},[j.SPEI]:{label:"SPEI",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png"},[j.PAYPAL]:{label:"Paypal",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png"},[j.COMERCIALMEXICANA]:{label:"Comercial Mexicana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png"},[j.BANCOMER]:{label:"Bancomer",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png"},[j.WALMART]:{label:"Walmart",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png"},[j.BODEGA]:{label:"Bodega Aurrera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png"},[j.SAMSCLUB]:{label:"Sam´s Club",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png"},[j.SUPERAMA]:{label:"Superama",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png"},[j.CALIMAX]:{label:"Calimax",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png"},[j.EXTRA]:{label:"Tiendas Extra",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png"},[j.CIRCULOK]:{label:"Círculo K",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png"},[j.SEVEN11]:{label:"7 Eleven",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png"},[j.TELECOMM]:{label:"Telecomm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png"},[j.BANORTE]:{label:"Banorte",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png"},[j.BENAVIDES]:{label:"Farmacias Benavides",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png"},[j.DELAHORRO]:{label:"Farmacias del Ahorro",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png"},[j.ELASTURIANO]:{label:"El Asturiano",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png"},[j.WALDOS]:{label:"Waldos",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png"},[j.ALSUPER]:{label:"Alsuper",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png"},[j.KIOSKO]:{label:"Kiosko",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png"},[j.STAMARIA]:{label:"Farmacias Santa María",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png"},[j.LAMASBARATA]:{label:"Farmacias la más barata",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png"},[j.FARMROMA]:{label:"Farmacias Roma",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png"},[j.FARMUNION]:{label:"Pago en Farmacias Unión",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png"},[j.FARMATODO]:{label:"Pago en Farmacias Farmatodo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png\t"},[j.SFDEASIS]:{label:"Pago en Farmacias San Francisco de Asís",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png"},[j.FARM911]:{label:"Farmacias 911",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.FARMECONOMICAS]:{label:"Farmacias Economicas",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.FARMMEDICITY]:{label:"Farmacias Medicity",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.RIANXEIRA]:{label:"Rianxeira",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.WESTERNUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.ZONAPAGO]:{label:"Zona Pago",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.CAJALOSANDES]:{label:"Caja Los Andes",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.CAJAPAITA]:{label:"Caja Paita",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.CAJASANTA]:{label:"Caja Santa",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.CAJASULLANA]:{label:"Caja Sullana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.CAJATRUJILLO]:{label:"Caja Trujillo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.EDPYME]:{label:"Edpyme",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.KASNET]:{label:"KasNet",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.NORANDINO]:{label:"Norandino",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.QAPAQ]:{label:"Qapaq",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.RAIZ]:{label:"Raiz",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.PAYSER]:{label:"Paysera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.WUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.BANCOCONTINENTAL]:{label:"Banco Continental",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.GMONEY]:{label:"Go money",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.GOPAY]:{label:"Go pay",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.WU]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.PUNTOSHEY]:{label:"Puntoshey",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.AMPM]:{label:"Ampm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.JUMBOMARKET]:{label:"Jumbomarket",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.SMELPUEBLO]:{label:"Smelpueblo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.BAM]:{label:"Bam",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.REFACIL]:{label:"Refacil",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[j.ACYVALORES]:{label:"Acyvalores",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"}},I=t=>{const e=t.toUpperCase().trim().replace(/\s+/g,"");return w[e]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}};class k extends O{constructor({apiKey:t,mode:e,returnUrl:o,callBack:n,apiKeyTonder:r,baseUrlTonder:i}){super({mode:e,apiKey:t,returnUrl:o,callBack:n,apiKeyTonder:r,baseUrlTonder:i}),this.activeAPMs=[]}injectCheckout(){return o(this,void 0,void 0,(function*(){yield this._initializeCheckout()}))}getCustomerCards(){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:t}=yield this._getCustomer(),e=yield this._getCustomerCards(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:y.getCardsError},t)}}))}saveCustomerCard(t){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{vault_id:o,vault_url:n,business:r}=this.merchantData,i=yield S({vault_id:o,vault_url:n,data:t,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder});return yield this._saveCustomerCard(e,null==r?void 0:r.pk,i)}catch(t){throw l({message:y.saveCardError},t)}}))}removeCustomerCard(t){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{business:o}=this.merchantData;return yield this._removeCustomerCard(e,null==o?void 0:o.pk,t)}catch(t){throw l({message:y.removeCardError},t)}}))}getCustomerPaymentMethods(){return o(this,void 0,void 0,(function*(){try{const t=yield this._fetchCustomerPaymentMethods();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},I(t.payment_method)))).sort(((t,e)=>t.priority-e.priority))}catch(t){throw l({message:y.getPaymentMethodsError},t)}}))}getBusiness(){return o(this,void 0,void 0,(function*(){try{return yield r(this.baseUrl,this.apiKeyTonder,this.abortController.signal)}catch(t){throw l({message:y.getBusinessError},t)}}))}getOpenpayDeviceSessionID(t,e,n){return o(this,void 0,void 0,(function*(){try{return yield m(t,e,n)}catch(t){throw d(t)}}))}getSkyflowTokens({vault_id:t,vault_url:e,data:n}){return o(this,void 0,void 0,(function*(){return yield S({vault_id:t,vault_url:e,data:n,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})}))}_setCartTotal(t){this.cartTotal=t}_checkout({card:t,payment_method:e,isSandbox:n,returnUrl:r}){return o(this,void 0,void 0,(function*(){yield this._fetchMerchantData();const o=yield this._getCustomer(this.abortController.signal),{vault_id:i,vault_url:s}=this.merchantData;let a;return e&&""===e&&null!==e||(a="string"==typeof t?{skyflow_id:t}:yield S({vault_id:i,vault_url:s,data:Object.assign(Object.assign({},t),{card_number:t.card_number.replace(/\s+/g,"")}),baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})),yield this._handleCheckout({card:a,payment_method:e,customer:o,isSandbox:n,returnUrl:r})}))}customerRegister(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/customer/`,o={email:t},n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},signal:this.abortController.signal,body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}createOrder(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/orders/`,o=t,n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}createPayment(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/business/${t.business_pk}/payments/`,o=t,n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}startCheckoutRouter(t){return o(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 o(this,void 0,void 0,(function*(){return this.process3ds.setPayload(t),yield this._handle3dsRedirect(t)}))}startCheckoutRouterFull(t){return o(this,void 0,void 0,(function*(){try{const{order:e,total:o,customer:n,skyflowTokens:r,return_url:a,isSandbox:d,metadata:c,currency:l,payment_method:u}=t,h=yield this._fetchMerchantData(),y=yield this.customerRegister(n.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:o,reference:h.reference,is_oneclick:!0,items:e.items},f=yield this.createOrder(t),v=(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:o,date:v,order_id:f.id,client_id:y.id},e=yield this.createPayment(t);let i;const{openpay_keys:g,business:_}=h;g.merchant_id&&g.public_key&&(i=yield m(g.merchant_id,g.public_key,d));const A=Object.assign(Object.assign({name:n.name,last_name:n.lastname,email_client:n.email,phone_number:n.phone,return_url:a,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:o,title_ship:"shipping",description:"transaction",device_session_id:i||null,token_id:"",order_id:"id"in f&&f.id,business_id:_.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,A);if(yield this.init3DSRedirect(b))return b}}}catch(t){throw d(t)}}))}registerCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const o=yield fetch(`${this.baseUrl}/api/v1/business/${a(this.merchantData)}/cards/`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"User-token":e,"Content-Type":"application/json"},body:JSON.stringify(Object.assign({},n))});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}deleteCustomerCard(t,e=""){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const o=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(o.ok)return!0;throw yield c(o)}catch(t){throw d(t)}}))}getActiveAPMs(){return o(this,void 0,void 0,(function*(){try{const t=yield function(t,e,n="?status=active&page_size=10000&country=México",r=null){return o(this,void 0,void 0,(function*(){try{const o=yield fetch(`${t}/api/v1/payment_methods${n}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(o.ok)return yield o.json();throw yield c(o)}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},I(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)&&L(t)}function R(t){return/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/.test(t)}function U(t){return/^\d{3,4}$/.test(t)}function N(t){return/^(0[1-9]|1[0-2])$/.test(t)}function P(t){if(!/^\d{2}$/.test(t))return!1;const e=(new Date).getFullYear()%100;return parseInt(t,10)>=e}const L=t=>{const e=`${t}`.split("").reverse().map((t=>Number.parseInt(t))),o=e.shift();let n=e.reduce(((t,e,o)=>o%2!=0?t+e:t+((e*=2)>9?e-9:e)),0);return n+=o,n%10==0};export{O as BaseInlineCheckout,k as LiteCheckout,U as validateCVV,M as validateCardNumber,R as validateCardholderName,N as validateExpirationMonth,P as validateExpirationYear};
|
|
1
|
+
import{get as t}from"lodash";import e from"skyflow-js";function o(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{d(n.next(t))}catch(t){i(t)}}function a(t){try{d(n.throw(t))}catch(t){i(t)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))}function n(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)}function r(t,e,n){return o(this,void 0,void 0,(function*(){const o=yield fetch(`${t}/api/v1/payments/business/${e}`,{headers:{Authorization:`Token ${e}`},signal:n});return yield o.json()}))}"function"==typeof SuppressedError&&SuppressedError;class i{constructor({code:t,body:e,name:o,message:n,stack:r}){this.code=t,this.body=e,this.name=o,this.message=n,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)=>o(void 0,void 0,void 0,(function*(){let o,n,r="Error";t&&"json"in t&&(o=yield null==t?void 0:t.json()),t&&"status"in t&&(n=t.status.toString()),!o&&t&&"text"in t&&(r=yield t.text()),(null==o?void 0:o.detail)&&(r=o.detail);return new i({code:n,body:o,name:n,message:r,stack:e})}));function l(t,e){var o,n;let r=200;try{r=Number((null==e?void 0:e.code)||200)}catch(t){}const i={status:"error",code:r,message:"",detail:(null===(o=null==e?void 0:e.body)||void 0===o?void 0:o.detail)||(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.error)||e.body||"Ocurrio un error inesperado."};return Object.assign(Object.assign({},i),t)}class u{constructor({payload:t=null,apiKey:e,baseUrl:o,customization:n,tdsIframeId:r,tonderPayButtonId:i,callBack:s}){this.localStorageKey="verify_transaction_status_url",this.customization={saveCards:{showSaveCardOption:!0,showSaved:!0,autoSave:!1},redirectOnComplete:!0},this.setPayload=t=>{this.payload=t},this.baseUrl=o,this.apiKey=e,this.payload=t,this.tdsIframeId=r,this.tonderPayButtonId=i,this.customization=Object.assign(Object.assign(Object.assign({},this.customization),n||{}),{saveCards:Object.assign(Object.assign({},this.customization.saveCards),(null==n?void 0:n.saveCards)||{})}),this.callBack=s}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,o,n,r,i;const s=null===(o=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===o?void 0:o.verify_transaction_status_url;if(s)this.saveUrlWithExpiration(s);else{const t=null===(i=null===(r=null===(n=this.payload)||void 0===n?void 0:n.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,o;if(null===(o=null===(e=null===(t=this.payload)||void 0===t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===o?void 0:o.iframe)return new Promise(((t,e)=>{var o,n,r;const i=null===(r=null===(n=null===(o=this.payload)||void 0===o?void 0:o.next_action)||void 0===n?void 0:n.iframe_resources)||void 0===r?void 0:r.iframe;if(i){this.saveVerifyTransactionUrl();const o=document.createElement("div");o.innerHTML=i,document.body.appendChild(o);const n=document.createElement("script");n.textContent='document.getElementById("tdsMmethodForm").submit();',o.appendChild(n);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,o;return null===(o=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===o?void 0:o.url}redirectToChallenge(){var t;const e=this.getRedirectUrl();if(e)if(this.saveVerifyTransactionUrl(),this.customization)if(null===(t=this.customization)||void 0===t?void 0:t.redirectOnComplete)window.location=e;else{const t=document.querySelector(`#${this.tdsIframeId}`);if(t){t.setAttribute("src",e),t.setAttribute("style","display: block");const n=this,r=e=>o(this,void 0,void 0,(function*(){const e=()=>{try{const t=document.querySelector(`#${this.tonderPayButtonId}`);t&&(t.disabled=!1)}catch(t){}t&&t.setAttribute("style","display: none"),n.callBack&&n.callBack(n.payload),t.removeEventListener("load",r)},i=t=>o(this,void 0,void 0,(function*(){const r=yield new Promise(((e,o)=>e(t)));if(r){if((t=>"Pending"!==(null==t?void 0:t.transaction_status))(r))return e();{const t=setTimeout((()=>o(this,void 0,void 0,(function*(){clearTimeout(t),yield i(n.requestTransactionStatus())}))),7e3)}}}));yield i(n.requestTransactionStatus())}));t.addEventListener("load",r)}else console.log("No iframe found")}else window.location=e;else this.callBack&&this.callBack(this.payload)}requestTransactionStatus(){return o(this,void 0,void 0,(function*(){const t=this.getUrlWithExpiration(),e=`${this.baseUrl}${t}`,o=yield fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKey}`}});if(200!==o.status)return console.error("La verificación de la transacción falló."),null;return yield o.json()}))}getURLParameters(){const t={},e=new URLSearchParams(window.location.search);for(const[o,n]of e)t[o]=n;return t}handleSuccessTransaction(t){return this.removeVerifyTransactionUrl(),console.log("Transacción autorizada."),t}handleDeclinedTransaction(t){return this.removeVerifyTransactionUrl(),t}handle3dsChallenge(t){return o(this,void 0,void 0,(function*(){const e=document.createElement("form");e.name="frm",e.method="POST",e.action=t.redirect_post_url;const o=document.createElement("input");o.type="hidden",o.name=t.creq,o.value=t.creq,e.appendChild(o);const n=document.createElement("input");n.type="hidden",n.name=t.term_url,n.value=t.TermUrl,e.appendChild(n),document.body.appendChild(e),e.submit(),yield this.verifyTransactionStatus()}))}handleTransactionResponse(t){return o(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 o(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,n){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/checkout-router/`,r=n,i=yield fetch(o,{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,n=!0,r=null){return o(this,void 0,void 0,(function*(){let o=yield window.OpenPay;return o.setId(t),o.setApiKey(e),o.setSandboxMode(n),yield o.deviceData.setup({signal:r})}))}const y=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.",secureTokenError:"Ha ocurrido un error obteniendo el token de seguridad."});var f,v,g,_,A,b,E,T,C,O;class S{constructor({mode:t="stage",customization:e,apiKey:o,apiKeyTonder:n,returnUrl:r,tdsIframeId:i,callBack:s=(()=>{}),baseUrlTonder:a,tonderPayButtonId:d}){f.add(this),this.baseUrl="",this.cartTotal="0",this.secureToken="",this.customization={saveCards:{showSaveCardOption:!0,showSaved:!0,autoSave:!1},redirectOnComplete:!0},this.metadata={},this.card={},this.currency="",v.set(this,void 0),this.apiKeyTonder=n||o||"",this.returnUrl=r,this.callBack=s,this.mode=t,this.customer={},this.baseUrl=a||h[this.mode]||h.stage,this.abortController=new AbortController,this.process3ds=new u({apiKey:o,baseUrl:this.baseUrl,customization:e,tdsIframeId:i,tonderPayButtonId:d,callBack:s}),this.tdsIframeId=i,this.customization=Object.assign(Object.assign(Object.assign({},this.customization),e||{}),{saveCards:Object.assign(Object.assign({},this.customization.saveCards),(null==e?void 0:e.saveCards)||{})})}configureCheckout(t){"secureToken"in t&&n(this,f,"m",A).call(this,t.secureToken),n(this,f,"m",g).call(this,t)}verify3dsTransaction(){return o(this,void 0,void 0,(function*(){const t=yield this.process3ds.verifyTransactionStatus(),e=yield n(this,f,"m",O).call(this,t);return this.process3ds.setPayload(e),this._handle3dsRedirect(e)}))}payment(t){return new Promise(((e,r)=>o(this,void 0,void 0,(function*(){try{n(this,f,"m",g).call(this,t);const o=yield this._checkout(t);this.process3ds.setPayload(o);if(yield this._handle3dsRedirect(o)){try{const t=document.querySelector(`#${this.tonderPayButtonId}`);t&&(t.disabled=!1)}catch(t){}this.callBack&&this.callBack(o),e(o)}}catch(t){r(t)}}))))}getSecureToken(t){return o(this,void 0,void 0,(function*(){try{return yield function(t,e,n=null){return o(this,void 0,void 0,(function*(){try{const o=yield fetch(`${t}/api/secure-token/`,{method:"POST",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:n});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}(this.baseUrl,t)}catch(t){throw l({message:y.secureTokenError},t)}}))}_initializeCheckout(){return o(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 o(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 o(this,void 0,void 0,(function*(){return n(this,v,"f")||function(t,e,o,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?r.call(t,o):r?r.value=o:e.set(t,o)}(this,v,yield function(t,e,n,r=null){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/customer/`,i={email:n.email,first_name:null==n?void 0:n.firstName,last_name:null==n?void 0:n.lastName,phone:null==n?void 0:n.phone},s=yield fetch(o,{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"),n(this,v,"f")}))}_handleCheckout({card:e,payment_method:n,customer:r,isSandbox:i,returnUrl:a}){return o(this,void 0,void 0,(function*(){const{openpay_keys:d,reference:c,business:l}=this.merchantData,u=Number(this.cartTotal);try{let h;!h&&d.merchant_id&&d.public_key&&(h=yield m(d.merchant_id,d.public_key,i,this.abortController.signal));const{id:y,auth_token:f}=r,v={business:this.apiKeyTonder,client:f,billing_address_id:null,shipping_address_id:null,amount:u,status:"A",reference:c,is_oneclick:!0,items:this.cartItems},g=yield function(t,e,n){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/orders/`,r=n,i=yield fetch(o,{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,v),_=(new Date).toISOString(),A={business_pk:l.pk,client_id:y,amount:u,date:_,order_id:g.id},b=yield function(t,e,n){return o(this,void 0,void 0,(function*(){const o=`${t}/api/v1/business/${n.business_pk}/payments/`,r=n,i=yield fetch(o,{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),E=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:a||this.returnUrl,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:u,title_ship:"shipping",description:"transaction",device_session_id:h||null,token_id:"",order_id:g.id,business_id:l.pk,payment_id:b.pk,source:"sdk",metadata:this.metadata,browser_info:s(),currency:this.currency},n?{payment_method:n}:{card:e}),T=yield p(this.baseUrl,this.apiKeyTonder,E);return T||!1}catch(t){throw console.log(t),t}}))}_fetchMerchantData(){return o(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}}))}_getCustomerCards(t,e){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r,i=null){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${r}/cards/`,s=yield fetch(o,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e},signal:i});if(s.ok)return yield s.json();if(401===s.status)return{user_id:0,cards:[]};throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,e)}))}_saveCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r,i){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${r}/cards/`,s=yield fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e},body:JSON.stringify(i)});if(s.ok)return yield s.json();throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,e,n)}))}_removeCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){return yield function(t,e,n,r="",i){return o(this,void 0,void 0,(function*(){try{const o=`${t}/api/v1/business/${i}/cards/${r}`,s=yield fetch(o,{method:"DELETE",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json","User-token":e}});if(204===s.status)return y.removedCard;if(s.ok&&"json"in s)return yield s.json();throw yield c(s)}catch(t){throw d(t)}}))}(this.baseUrl,t,this.secureToken,n,e)}))}_fetchCustomerPaymentMethods(){return o(this,void 0,void 0,(function*(){return yield function(t,e,n={status:"active",pagesize:"10000"},r=null){return o(this,void 0,void 0,(function*(){try{const o=new URLSearchParams(n).toString(),i=yield fetch(`${t}/api/v1/payment_methods?${o}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(i.ok)return yield i.json();throw yield c(i)}catch(t){throw d(t)}}))}(this.baseUrl,this.apiKeyTonder)}))}_handle3dsRedirect(t){var e,n;return o(this,void 0,void 0,(function*(){if(t&&"next_action"in t?null===(n=null===(e=null==t?void 0:t.next_action)||void 0===e?void 0:e.iframe_resources)||void 0===n?void 0:n.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()}}))}}function j({baseUrl:t,apiKey:n,vault_id:r,vault_url:i,data:s}){return o(this,void 0,void 0,(function*(){const a=e.init({vaultID:r,vaultURL:i,getBearerToken:()=>o(this,void 0,void 0,(function*(){return yield function(t,e,n=null){return o(this,void 0,void 0,(function*(){const o=yield fetch(`${t}/api/v1/vault-token/`,{method:"GET",headers:{Authorization:`Token ${e}`},signal:n});if(o.ok)return(yield o.json()).token;throw new Error("Failed to retrieve bearer token")}))}(t,n)})),options:{logLevel:e.LogLevel.ERROR,env:e.Env.DEV}}),c=a.container(e.ContainerType.COLLECT),l=yield function(t,n){return o(this,void 0,void 0,(function*(){const r=yield function(t,n){return o(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(t).map((t=>o(this,void 0,void 0,(function*(){return{element:yield n.create({table:"cards",column:t,type:e.ElementType.INPUT_FIELD}),key:t}})))))}))}(t,n);return r?r.map((e=>new Promise((o=>{var n;const r=document.createElement("div");r.hidden=!0,r.id=`id-${e.key}`,null===(n=document.querySelector("body"))||void 0===n||n.appendChild(r),setTimeout((()=>{e.element.mount(`#id-${e.key}`),setInterval((()=>{if(e.element.isMounted()){const n=t[e.key];return e.element.update({value:n}),o(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)}}))}v=new WeakMap,f=new WeakSet,g=function(t){var e,o;!t||t&&0===Object.keys(t).length||(n(this,f,"m",_).call(this,t.customer),this._setCartTotal(null===(e=t.cart)||void 0===e?void 0:e.total),n(this,f,"m",b).call(this,null===(o=t.cart)||void 0===o?void 0:o.items),n(this,f,"m",E).call(this,t),n(this,f,"m",T).call(this,t),n(this,f,"m",C).call(this,t))},_=function(t){t&&(this.customer=t)},A=function(t){this.secureToken=t},b=function(t){this.cartItems=t},E=function(t){this.metadata=null==t?void 0:t.metadata},T=function(t){this.currency=null==t?void 0:t.currency},C=function(t){this.card=null==t?void 0:t.card},O=function(t){var e,n;return o(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===(n=t.checkout)||void 0===n?void 0:n.id};try{return yield p(this.baseUrl,this.apiKeyTonder,e)}catch(t){}return t}}))};const w=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"}),I={[w.SORIANA]:{label:"Soriana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png"},[w.OXXO]:{label:"Oxxo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png"},[w.CODI]:{label:"CoDi",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png"},[w.SPEI]:{label:"SPEI",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png"},[w.PAYPAL]:{label:"Paypal",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png"},[w.COMERCIALMEXICANA]:{label:"Comercial Mexicana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png"},[w.BANCOMER]:{label:"Bancomer",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png"},[w.WALMART]:{label:"Walmart",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png"},[w.BODEGA]:{label:"Bodega Aurrera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png"},[w.SAMSCLUB]:{label:"Sam´s Club",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png"},[w.SUPERAMA]:{label:"Superama",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png"},[w.CALIMAX]:{label:"Calimax",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png"},[w.EXTRA]:{label:"Tiendas Extra",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png"},[w.CIRCULOK]:{label:"Círculo K",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png"},[w.SEVEN11]:{label:"7 Eleven",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png"},[w.TELECOMM]:{label:"Telecomm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png"},[w.BANORTE]:{label:"Banorte",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png"},[w.BENAVIDES]:{label:"Farmacias Benavides",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png"},[w.DELAHORRO]:{label:"Farmacias del Ahorro",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png"},[w.ELASTURIANO]:{label:"El Asturiano",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png"},[w.WALDOS]:{label:"Waldos",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png"},[w.ALSUPER]:{label:"Alsuper",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png"},[w.KIOSKO]:{label:"Kiosko",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png"},[w.STAMARIA]:{label:"Farmacias Santa María",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png"},[w.LAMASBARATA]:{label:"Farmacias la más barata",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png"},[w.FARMROMA]:{label:"Farmacias Roma",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png"},[w.FARMUNION]:{label:"Pago en Farmacias Unión",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png"},[w.FARMATODO]:{label:"Pago en Farmacias Farmatodo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png\t"},[w.SFDEASIS]:{label:"Pago en Farmacias San Francisco de Asís",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png"},[w.FARM911]:{label:"Farmacias 911",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.FARMECONOMICAS]:{label:"Farmacias Economicas",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.FARMMEDICITY]:{label:"Farmacias Medicity",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.RIANXEIRA]:{label:"Rianxeira",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.WESTERNUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.ZONAPAGO]:{label:"Zona Pago",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.CAJALOSANDES]:{label:"Caja Los Andes",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.CAJAPAITA]:{label:"Caja Paita",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.CAJASANTA]:{label:"Caja Santa",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.CAJASULLANA]:{label:"Caja Sullana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.CAJATRUJILLO]:{label:"Caja Trujillo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.EDPYME]:{label:"Edpyme",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.KASNET]:{label:"KasNet",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.NORANDINO]:{label:"Norandino",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.QAPAQ]:{label:"Qapaq",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.RAIZ]:{label:"Raiz",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.PAYSER]:{label:"Paysera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.WUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.BANCOCONTINENTAL]:{label:"Banco Continental",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.GMONEY]:{label:"Go money",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.GOPAY]:{label:"Go pay",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.WU]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.PUNTOSHEY]:{label:"Puntoshey",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.AMPM]:{label:"Ampm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.JUMBOMARKET]:{label:"Jumbomarket",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.SMELPUEBLO]:{label:"Smelpueblo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.BAM]:{label:"Bam",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.REFACIL]:{label:"Refacil",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[w.ACYVALORES]:{label:"Acyvalores",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"}},k=t=>{const e=t.toUpperCase().trim().replace(/\s+/g,"");return I[e]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}};class M extends S{constructor({apiKey:t,mode:e,returnUrl:o,callBack:n,apiKeyTonder:r,baseUrlTonder:i}){super({mode:e,apiKey:t,returnUrl:o,callBack:n,apiKeyTonder:r,baseUrlTonder:i}),this.activeAPMs=[]}injectCheckout(){return o(this,void 0,void 0,(function*(){yield this._initializeCheckout()}))}getCustomerCards(){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:t}=yield this._getCustomer(),e=yield this._getCustomerCards(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:y.getCardsError},t)}}))}saveCustomerCard(t){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{vault_id:o,vault_url:n,business:r}=this.merchantData,i=yield j({vault_id:o,vault_url:n,data:t,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder});return yield this._saveCustomerCard(e,null==r?void 0:r.pk,i)}catch(t){throw l({message:y.saveCardError},t)}}))}removeCustomerCard(t){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{business:o}=this.merchantData;return yield this._removeCustomerCard(e,null==o?void 0:o.pk,t)}catch(t){throw l({message:y.removeCardError},t)}}))}getCustomerPaymentMethods(){return o(this,void 0,void 0,(function*(){try{const t=yield this._fetchCustomerPaymentMethods();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},k(t.payment_method)))).sort(((t,e)=>t.priority-e.priority))}catch(t){throw l({message:y.getPaymentMethodsError},t)}}))}getBusiness(){return o(this,void 0,void 0,(function*(){try{return yield r(this.baseUrl,this.apiKeyTonder,this.abortController.signal)}catch(t){throw l({message:y.getBusinessError},t)}}))}getOpenpayDeviceSessionID(t,e,n){return o(this,void 0,void 0,(function*(){try{return yield m(t,e,n)}catch(t){throw d(t)}}))}getSkyflowTokens({vault_id:t,vault_url:e,data:n}){return o(this,void 0,void 0,(function*(){return yield j({vault_id:t,vault_url:e,data:n,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})}))}_setCartTotal(t){this.cartTotal=t}_checkout({card:t,payment_method:e,isSandbox:n,returnUrl:r}){return o(this,void 0,void 0,(function*(){yield this._fetchMerchantData();const o=yield this._getCustomer(this.abortController.signal),{vault_id:i,vault_url:s}=this.merchantData;let a;return e&&""===e&&null!==e||(a="string"==typeof t?{skyflow_id:t}:yield j({vault_id:i,vault_url:s,data:Object.assign(Object.assign({},t),{card_number:t.card_number.replace(/\s+/g,"")}),baseUrl:this.baseUrl,apiKey:this.apiKeyTonder})),yield this._handleCheckout({card:a,payment_method:e,customer:o,isSandbox:n,returnUrl:r})}))}customerRegister(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/customer/`,o={email:t},n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},signal:this.abortController.signal,body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}createOrder(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/orders/`,o=t,n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}createPayment(t){return o(this,void 0,void 0,(function*(){try{const e=`${this.baseUrl}/api/v1/business/${t.business_pk}/payments/`,o=t,n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});if(n.ok)return yield n.json();throw yield c(n)}catch(t){throw d(t)}}))}startCheckoutRouter(t){return o(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 o(this,void 0,void 0,(function*(){return this.process3ds.setPayload(t),yield this._handle3dsRedirect(t)}))}startCheckoutRouterFull(t){return o(this,void 0,void 0,(function*(){try{const{order:e,total:o,customer:n,skyflowTokens:r,return_url:a,isSandbox:d,metadata:c,currency:l,payment_method:u}=t,h=yield this._fetchMerchantData(),y=yield this.customerRegister(n.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:o,reference:h.reference,is_oneclick:!0,items:e.items},f=yield this.createOrder(t),v=(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:o,date:v,order_id:f.id,client_id:y.id},e=yield this.createPayment(t);let i;const{openpay_keys:g,business:_}=h;g.merchant_id&&g.public_key&&(i=yield m(g.merchant_id,g.public_key,d));const A=Object.assign(Object.assign({name:n.name,last_name:n.lastname,email_client:n.email,phone_number:n.phone,return_url:a,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:o,title_ship:"shipping",description:"transaction",device_session_id:i||null,token_id:"",order_id:"id"in f&&f.id,business_id:_.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,A);if(yield this.init3DSRedirect(b))return b}}}catch(t){throw d(t)}}))}registerCustomerCard(t,e,n){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const o=yield fetch(`${this.baseUrl}/api/v1/business/${a(this.merchantData)}/cards/`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"User-token":e,"Content-Type":"application/json"},body:JSON.stringify(Object.assign({},n))});if(o.ok)return yield o.json();throw yield c(o)}catch(t){throw d(t)}}))}deleteCustomerCard(t,e=""){return o(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const o=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(o.ok)return!0;throw yield c(o)}catch(t){throw d(t)}}))}getActiveAPMs(){return o(this,void 0,void 0,(function*(){try{const t=yield function(t,e,n="?status=active&page_size=10000&country=México",r=null){return o(this,void 0,void 0,(function*(){try{const o=yield fetch(`${t}/api/v1/payment_methods${n}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:r});if(o.ok)return yield o.json();throw yield c(o)}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},k(t.payment_method)))).sort(((t,e)=>t.priority-e.priority)),this.activeAPMs}catch(t){return console.error("Error getting APMS",t),[]}}))}}function R(t){return/^\d{12,19}$/.test(t)&&D(t)}function U(t){return/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/.test(t)}function N(t){return/^\d{3,4}$/.test(t)}function P(t){return/^(0[1-9]|1[0-2])$/.test(t)}function L(t){if(!/^\d{2}$/.test(t))return!1;const e=(new Date).getFullYear()%100;return parseInt(t,10)>=e}const D=t=>{const e=`${t}`.split("").reverse().map((t=>Number.parseInt(t))),o=e.shift();let n=e.reduce(((t,e,o)=>o%2!=0?t+e:t+((e*=2)>9?e-9:e)),0);return n+=o,n%10==0};export{S as BaseInlineCheckout,M as LiteCheckout,N as validateCVV,R as validateCardNumber,U as validateCardholderName,P as validateExpirationMonth,L as validateExpirationYear};
|
package/dist/types/checkout.d.ts
CHANGED
package/dist/types/commons.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICustomer } from "./customer";
|
|
2
|
-
import { IStartCheckoutResponse } from "./checkout";
|
|
2
|
+
import { IProcessPaymentRequest, IStartCheckoutResponse } from "./checkout";
|
|
3
3
|
export type Business = {
|
|
4
4
|
business: {
|
|
5
5
|
pk: number;
|
|
@@ -78,7 +78,7 @@ export type APM = {
|
|
|
78
78
|
icon: string;
|
|
79
79
|
label: string;
|
|
80
80
|
};
|
|
81
|
-
export interface IConfigureCheckout {
|
|
81
|
+
export interface IConfigureCheckout extends IProcessPaymentRequest {
|
|
82
82
|
customer: ICustomer | {
|
|
83
83
|
email: string;
|
|
84
84
|
};
|
|
@@ -82,13 +82,14 @@ export interface ILiteCheckout {
|
|
|
82
82
|
getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
|
|
83
83
|
/**
|
|
84
84
|
* Retrieves security token to access the saved cards functionality.
|
|
85
|
+
* @param {string} secretApikey
|
|
85
86
|
* @returns {Promise<import("./index").GetSecureTokenResponse>} A promise that resolves with the token.
|
|
86
87
|
*
|
|
87
88
|
* @throws {import("./index").IPublicError} Throws an error object if the operation fails.
|
|
88
89
|
*
|
|
89
90
|
* @public
|
|
90
91
|
*/
|
|
91
|
-
getSecureToken(): Promise<GetSecureTokenResponse>;
|
|
92
|
+
getSecureToken(secretApikey: string): Promise<GetSecureTokenResponse>;
|
|
92
93
|
/**
|
|
93
94
|
* @deprecated This method is deprecated and will be removed in a future release.
|
|
94
95
|
* It is no longer necessary to use this method, now automatically handled
|
package/package.json
CHANGED
|
@@ -105,8 +105,8 @@ export class BaseInlineCheckout {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
configureCheckout(data: IConfigureCheckout) {
|
|
108
|
-
if ("customer" in data) this.#handleCustomer(data["customer"]);
|
|
109
108
|
if ("secureToken" in data) this.#setSecureToken(data["secureToken"]);
|
|
109
|
+
this.#setCheckoutData(data)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
async verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void> {
|
|
@@ -119,12 +119,7 @@ export class BaseInlineCheckout {
|
|
|
119
119
|
payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse> {
|
|
120
120
|
return new Promise(async (resolve, reject) => {
|
|
121
121
|
try {
|
|
122
|
-
this.#
|
|
123
|
-
this._setCartTotal(data.cart?.total);
|
|
124
|
-
this.#setCartItems(data.cart?.items);
|
|
125
|
-
this.#handleMetadata(data);
|
|
126
|
-
this.#handleCurrency(data);
|
|
127
|
-
this.#handleCard(data);
|
|
122
|
+
this.#setCheckoutData(data)
|
|
128
123
|
const response = await this._checkout(data);
|
|
129
124
|
this.process3ds.setPayload(response);
|
|
130
125
|
const payload = await this._handle3dsRedirect(response);
|
|
@@ -144,9 +139,9 @@ export class BaseInlineCheckout {
|
|
|
144
139
|
});
|
|
145
140
|
}
|
|
146
141
|
|
|
147
|
-
async getSecureToken(): Promise<GetSecureTokenResponse> {
|
|
142
|
+
async getSecureToken(secretApikey: string): Promise<GetSecureTokenResponse> {
|
|
148
143
|
try {
|
|
149
|
-
return await getSecureToken(this.baseUrl,
|
|
144
|
+
return await getSecureToken(this.baseUrl, secretApikey)
|
|
150
145
|
} catch (error) {
|
|
151
146
|
throw formatPublicErrorResponse(
|
|
152
147
|
{
|
|
@@ -307,6 +302,16 @@ export class BaseInlineCheckout {
|
|
|
307
302
|
}
|
|
308
303
|
}
|
|
309
304
|
|
|
305
|
+
#setCheckoutData(data: IConfigureCheckout | IProcessPaymentRequest){
|
|
306
|
+
if(!data || (data && Object.keys(data).length === 0)) return;
|
|
307
|
+
this.#handleCustomer(data.customer);
|
|
308
|
+
this._setCartTotal(data.cart?.total);
|
|
309
|
+
this.#setCartItems(data.cart?.items);
|
|
310
|
+
this.#handleMetadata(data);
|
|
311
|
+
this.#handleCurrency(data);
|
|
312
|
+
this.#handleCard(data);
|
|
313
|
+
}
|
|
314
|
+
|
|
310
315
|
async _fetchMerchantData() {
|
|
311
316
|
try {
|
|
312
317
|
if (!this.merchantData) {
|
package/src/types/checkout.ts
CHANGED
package/src/types/commons.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICustomer } from "./customer";
|
|
2
|
-
import {IStartCheckoutResponse} from "./checkout";
|
|
2
|
+
import {IProcessPaymentRequest, IStartCheckoutResponse} from "./checkout";
|
|
3
3
|
|
|
4
4
|
export type Business = {
|
|
5
5
|
business: {
|
|
@@ -85,7 +85,7 @@ export type APM = {
|
|
|
85
85
|
label: string;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
export interface IConfigureCheckout {
|
|
88
|
+
export interface IConfigureCheckout extends IProcessPaymentRequest{
|
|
89
89
|
customer: ICustomer | { email: string };
|
|
90
90
|
secureToken: string
|
|
91
91
|
}
|
|
@@ -111,13 +111,14 @@ export interface ILiteCheckout {
|
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Retrieves security token to access the saved cards functionality.
|
|
114
|
+
* @param {string} secretApikey
|
|
114
115
|
* @returns {Promise<import("./index").GetSecureTokenResponse>} A promise that resolves with the token.
|
|
115
116
|
*
|
|
116
117
|
* @throws {import("./index").IPublicError} Throws an error object if the operation fails.
|
|
117
118
|
*
|
|
118
119
|
* @public
|
|
119
120
|
*/
|
|
120
|
-
getSecureToken(): Promise<GetSecureTokenResponse>
|
|
121
|
+
getSecureToken(secretApikey: string): Promise<GetSecureTokenResponse>
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
124
|
* @deprecated This method is deprecated and will be removed in a future release.
|