@tonder.io/ionic-lite-sdk 0.0.36-beta.1 → 0.0.38-beta.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.
Files changed (79) hide show
  1. package/README.md +427 -116
  2. package/dist/classes/BaseInlineCheckout.d.ts +47 -0
  3. package/dist/classes/liteCheckout.d.ts +25 -29
  4. package/dist/data/businessApi.d.ts +2 -0
  5. package/dist/data/cardApi.d.ts +4 -0
  6. package/dist/data/checkoutApi.d.ts +5 -0
  7. package/dist/data/customerApi.d.ts +2 -0
  8. package/dist/data/openPayApi.d.ts +1 -0
  9. package/dist/data/paymentMethodApi.d.ts +5 -0
  10. package/dist/data/skyflowApi.d.ts +1 -0
  11. package/dist/helpers/skyflow.d.ts +3 -0
  12. package/dist/helpers/utils.d.ts +8 -4
  13. package/dist/helpers/validations.d.ts +6 -0
  14. package/dist/index.d.ts +3 -1
  15. package/dist/index.js +1 -1
  16. package/dist/shared/catalog/paymentMethodsCatalog.d.ts +1 -0
  17. package/dist/shared/constants/messages.d.ts +11 -0
  18. package/dist/shared/constants/paymentMethodAPM.d.ts +62 -0
  19. package/dist/shared/constants/tonderUrl.d.ts +7 -0
  20. package/dist/types/card.d.ts +30 -0
  21. package/dist/types/checkout.d.ts +109 -0
  22. package/dist/types/commons.d.ts +42 -0
  23. package/dist/types/customer.d.ts +22 -0
  24. package/dist/types/liteInlineCheckout.d.ts +151 -0
  25. package/dist/types/paymentMethod.d.ts +22 -0
  26. package/dist/types/requests.d.ts +12 -3
  27. package/dist/types/transaction.d.ts +101 -0
  28. package/package.json +4 -1
  29. package/src/classes/BaseInlineCheckout.ts +387 -0
  30. package/src/classes/errorResponse.ts +1 -1
  31. package/src/classes/liteCheckout.ts +372 -356
  32. package/src/data/businessApi.ts +18 -0
  33. package/src/data/cardApi.ts +87 -0
  34. package/src/data/checkoutApi.ts +84 -0
  35. package/src/data/customerApi.ts +31 -0
  36. package/src/data/openPayApi.ts +12 -0
  37. package/src/data/paymentMethodApi.ts +37 -0
  38. package/src/data/skyflowApi.ts +20 -0
  39. package/src/helpers/mercadopago.ts +14 -14
  40. package/src/helpers/skyflow.ts +91 -0
  41. package/src/helpers/utils.ts +66 -266
  42. package/src/helpers/validations.ts +55 -0
  43. package/src/index.ts +9 -1
  44. package/src/shared/catalog/paymentMethodsCatalog.ts +248 -0
  45. package/src/shared/constants/messages.ts +11 -0
  46. package/src/shared/constants/paymentMethodAPM.ts +63 -0
  47. package/src/shared/constants/tonderUrl.ts +8 -0
  48. package/src/types/card.ts +35 -0
  49. package/src/types/checkout.ts +124 -0
  50. package/src/types/commons.ts +114 -67
  51. package/src/types/customer.ts +22 -0
  52. package/src/types/liteInlineCheckout.ts +216 -0
  53. package/src/types/paymentMethod.ts +24 -0
  54. package/src/types/requests.ts +12 -3
  55. package/src/types/transaction.ts +101 -0
  56. package/src/types/validations.d.ts +11 -0
  57. package/tests/classes/liteCheckout.test.ts +5 -5
  58. package/tests/methods/createOrder.test.ts +3 -4
  59. package/tests/methods/createPayment.test.ts +2 -3
  60. package/tests/methods/customerRegister.test.ts +3 -4
  61. package/tests/methods/getBusiness.test.ts +4 -5
  62. package/tests/methods/getCustomerCards.test.ts +6 -13
  63. package/tests/methods/registerCustomerCard.test.ts +2 -2
  64. package/tests/methods/startCheckoutRouter.test.ts +2 -2
  65. package/tests/methods/startCheckoutRouterFull.test.ts +2 -2
  66. package/tests/utils/defaultMock.ts +3 -2
  67. package/tests/utils/mockClasses.ts +7 -4
  68. package/types/classes/liteCheckout.d.ts +29 -0
  69. package/types/classes/liteCheckout.js +225 -0
  70. package/types/classes/liteCheckout.js.map +1 -0
  71. package/types/helpers/utils.d.ts +3 -0
  72. package/types/helpers/utils.js +27 -0
  73. package/types/helpers/utils.js.map +1 -0
  74. package/types/index.d.ts +2 -0
  75. package/types/index.js +6 -0
  76. package/types/index.js.map +1 -0
  77. package/tests/methods/getOpenpayDeviceSessionID.test.ts +0 -95
  78. package/tests/methods/getSkyflowToken.test.ts +0 -155
  79. package/tests/methods/getVaultToken.test.ts +0 -107
@@ -1,47 +1,43 @@
1
- import CollectContainer from "skyflow-js/types/core/external/collect/collect-container";
2
- import { APM, Business } from "../types/commons";
3
- import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutRequest, TokensRequest, StartCheckoutFullRequest, StartCheckoutIdRequest } from "../types/requests";
4
- import { GetSecureTokenResponse, GetBusinessResponse, CustomerRegisterResponse, CreateOrderResponse, CreatePaymentResponse, StartCheckoutResponse, GetCustomerCardsResponse, RegisterCustomerCardResponse } from "../types/responses";
5
1
  import { ErrorResponse } from "./errorResponse";
6
- import { ThreeDSHandler } from "./3dsHandler";
2
+ import { BaseInlineCheckout } from "./BaseInlineCheckout";
3
+ import { APM, IInlineLiteCheckoutOptions } from "../types/commons";
4
+ import { ICustomerCardsResponse, ISaveCardRequest, ISaveCardResponse } from "../types/card";
5
+ import { IPaymentMethod } from "../types/paymentMethod";
6
+ import { CreateOrderResponse, CreatePaymentResponse, CustomerRegisterResponse, GetBusinessResponse, RegisterCustomerCardResponse, StartCheckoutResponse, GetSecureTokenResponse } from "../types/responses";
7
+ import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutFullRequest, StartCheckoutIdRequest, StartCheckoutRequest, TokensRequest } from "../types/requests";
8
+ import { ICardFields, IStartCheckoutResponse } from "../types/checkout";
9
+ import { ILiteCheckout } from "../types/liteInlineCheckout";
7
10
  declare global {
8
11
  interface Window {
9
12
  OpenPay: any;
10
13
  }
11
14
  }
12
- export type LiteCheckoutConstructor = {
13
- signal: AbortSignal;
14
- baseUrlTonder: string;
15
- publicApiKeyTonder: string;
16
- };
17
- export declare class LiteCheckout implements LiteCheckoutConstructor {
18
- #private;
19
- signal: AbortSignal;
20
- baseUrlTonder: string;
21
- publicApiKeyTonder: string;
22
- process3ds: ThreeDSHandler;
15
+ export declare class LiteCheckout extends BaseInlineCheckout implements ILiteCheckout {
23
16
  activeAPMs: APM[];
24
- merchantData?: Business | ErrorResponse;
25
- constructor({ signal, baseUrlTonder, publicApiKeyTonder, }: LiteCheckoutConstructor);
17
+ constructor({ apiKey, mode, returnUrl, callBack, apiKeyTonder, baseUrlTonder }: IInlineLiteCheckoutOptions);
18
+ injectCheckout(): Promise<void>;
19
+ getCustomerCards(): Promise<ICustomerCardsResponse>;
20
+ saveCustomerCard(secureToken: string, card: ISaveCardRequest): Promise<ISaveCardResponse>;
21
+ removeCustomerCard(skyflowId: string): Promise<string>;
22
+ getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
23
+ getBusiness(): Promise<GetBusinessResponse>;
26
24
  getOpenpayDeviceSessionID(merchant_id: string, public_key: string, is_sandbox: boolean): Promise<string | ErrorResponse>;
27
- getBusiness(): Promise<GetBusinessResponse | ErrorResponse>;
28
- verify3dsTransaction(): Promise<false | StartCheckoutResponse | ErrorResponse | undefined>;
29
- resumeCheckout(response: any): Promise<any>;
30
- handle3dsRedirect(response: ErrorResponse | StartCheckoutResponse | false | undefined): Promise<false | StartCheckoutResponse | ErrorResponse | undefined>;
25
+ getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
26
+ _setCartTotal(total: string): void;
27
+ _checkout({ card, payment_method, isSandbox, returnUrl: returnUrlData }: {
28
+ card?: ICardFields | string;
29
+ payment_method?: string;
30
+ isSandbox?: boolean;
31
+ returnUrl?: string;
32
+ }): Promise<any>;
31
33
  customerRegister(email: string): Promise<CustomerRegisterResponse | ErrorResponse>;
32
34
  createOrder(orderItems: CreateOrderRequest): Promise<CreateOrderResponse | ErrorResponse>;
33
35
  createPayment(paymentItems: CreatePaymentRequest): Promise<CreatePaymentResponse | ErrorResponse>;
34
- handleCheckoutRouter(routerData: StartCheckoutRequest | StartCheckoutIdRequest): Promise<StartCheckoutResponse>;
35
36
  startCheckoutRouter(routerData: StartCheckoutRequest | StartCheckoutIdRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
37
+ init3DSRedirect(checkoutResult: IStartCheckoutResponse): Promise<void | IStartCheckoutResponse | import("../types/transaction").ITransaction>;
36
38
  startCheckoutRouterFull(routerFullData: StartCheckoutFullRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
37
- init3DSRedirect(checkoutResult: ErrorResponse | StartCheckoutResponse): Promise<false | StartCheckoutResponse | ErrorResponse | undefined>;
38
- getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
39
- getVaultToken(): Promise<string>;
40
- getFieldsPromise(data: any, collectContainer: CollectContainer): Promise<Promise<boolean>[]>;
41
39
  registerCustomerCard(secureToken: string, customerToken: string, data: RegisterCustomerCardRequest): Promise<RegisterCustomerCardResponse | ErrorResponse>;
42
- getCustomerCards(customerToken: string, bearerToken: string): Promise<GetCustomerCardsResponse | ErrorResponse>;
43
40
  deleteCustomerCard(customerToken: string, skyflowId?: string): Promise<Boolean | ErrorResponse>;
44
- private getFields;
45
41
  getActiveAPMs(): Promise<APM[]>;
46
42
  getSecureToken(token: string): Promise<GetSecureTokenResponse | ErrorResponse>;
47
43
  }
@@ -0,0 +1,2 @@
1
+ import { GetBusinessResponse } from "../types/responses";
2
+ export declare function fetchBusiness(baseUrl: string, apiKey: string, signal: AbortSignal): Promise<GetBusinessResponse>;
@@ -0,0 +1,4 @@
1
+ import { ICustomerCardsResponse, ISaveCardResponse, ISaveCardSkyflowRequest } from "../types/card";
2
+ export declare function fetchCustomerCards(baseUrl: string, customerToken: string, businessId: string | number, signal?: null): Promise<ICustomerCardsResponse>;
3
+ export declare function saveCustomerCard(baseUrl: string, secureToken: string, customerToken: string, businessId: string | number, data: ISaveCardSkyflowRequest): Promise<ISaveCardResponse>;
4
+ export declare function removeCustomerCard(baseUrl: string, customerToken: string, skyflowId: string | undefined, businessId: string | number): Promise<string>;
@@ -0,0 +1,5 @@
1
+ import { CreateOrderRequest, CreatePaymentRequest } from "../types/requests";
2
+ import { IStartCheckoutIdRequest, IStartCheckoutRequest } from "../types/checkout";
3
+ export declare function createOrder(baseUrl: string, apiKey: string, orderItems: CreateOrderRequest): Promise<any>;
4
+ export declare function createPayment(baseUrl: string, apiKey: string, paymentItems: CreatePaymentRequest): Promise<any>;
5
+ export declare function startCheckoutRouter(baseUrl: string, apiKey: string, routerItems: IStartCheckoutRequest | IStartCheckoutIdRequest): Promise<any>;
@@ -0,0 +1,2 @@
1
+ import { CustomerRegisterResponse } from "../types/responses";
2
+ export declare function registerOrFetchCustomer(baseUrl: string, apiKey: string, customer: Record<string, any>, signal?: AbortSignal | null): Promise<CustomerRegisterResponse>;
@@ -0,0 +1 @@
1
+ export declare function getOpenpayDeviceSessionID(merchant_id: string, public_key: string, isSandbox?: boolean, signal?: AbortSignal | null): Promise<string>;
@@ -0,0 +1,5 @@
1
+ import { IPaymentMethodResponse } from "../types/paymentMethod";
2
+ export declare function fetchCustomerPaymentMethods(baseUrl: string, apiKey: string, params?: {
3
+ status: string;
4
+ pagesize: string;
5
+ }, signal?: null): Promise<IPaymentMethodResponse>;
@@ -0,0 +1 @@
1
+ export declare function getVaultToken(baseUrl: string, apiKey: string, signal?: null): Promise<any>;
@@ -0,0 +1,3 @@
1
+ import { ErrorResponse } from "../classes/errorResponse";
2
+ import { TokensSkyflowRequest } from "../types/requests";
3
+ export declare function getSkyflowTokens({ baseUrl, apiKey, vault_id, vault_url, data, }: TokensSkyflowRequest): Promise<any | ErrorResponse>;
@@ -11,8 +11,12 @@ export declare const getBrowserInfo: () => {
11
11
  export declare const getBusinessId: (merchantData: any) => any;
12
12
  declare const buildErrorResponseFromCatch: (e: any) => ErrorResponse;
13
13
  declare const buildErrorResponse: (response: Response, stack?: string | undefined) => Promise<ErrorResponse>;
14
- declare const getPaymentMethodDetails: (scheme_data: string) => {
15
- icon: string;
16
- label: string;
14
+ declare function formatPublicErrorResponse(data: Record<string, any>, error: any): {
15
+ status: string;
16
+ code: number;
17
+ message: string;
18
+ detail: any;
17
19
  };
18
- export { buildErrorResponseFromCatch, buildErrorResponse, getPaymentMethodDetails };
20
+ declare const clearSpace: (text: string) => string;
21
+ declare const getCardType: (scheme: string) => "https://d35a75syrgujp0.cloudfront.net/cards/visa.png" | "https://d35a75syrgujp0.cloudfront.net/cards/mastercard.png" | "https://d35a75syrgujp0.cloudfront.net/cards/american_express.png" | "https://d35a75syrgujp0.cloudfront.net/cards/default_card.png";
22
+ export { buildErrorResponseFromCatch, buildErrorResponse, getCardType, formatPublicErrorResponse, clearSpace, };
@@ -0,0 +1,6 @@
1
+ export declare function validateCardNumber(cardNumber: string): boolean;
2
+ export declare function validateCardholderName(name: string): boolean;
3
+ export declare function validateCVV(cvv: string): boolean;
4
+ export declare function validateExpirationDate(expirationDate: string): boolean;
5
+ export declare function validateExpirationMonth(month: string): boolean;
6
+ export declare function validateExpirationYear(year: string): boolean;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  import { LiteCheckout } from './classes/liteCheckout';
2
- export { LiteCheckout };
2
+ import { BaseInlineCheckout } from './classes/BaseInlineCheckout';
3
+ import { validateCVV, validateCardNumber, validateExpirationMonth, validateCardholderName, validateExpirationYear } from './helpers/validations';
4
+ export { LiteCheckout, BaseInlineCheckout, validateCVV, validateCardNumber, validateCardholderName, validateExpirationMonth, validateExpirationYear };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"skyflow-js";function t(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{d(o.next(e))}catch(e){r(e)}}function a(e){try{d(o.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}d((o=o.apply(e,t||[])).next())}))}function n(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;class o{constructor({code:e,body:t,name:n,message:o,stack:i}){this.code=e,this.body=t,this.name=n,this.message=o,this.stack=i}}var i;!function(e){e.SORIANA="SORIANA",e.OXXO="OXXO",e.SPEI="SPEI",e.CODI="CODI",e.MERCADOPAGO="MERCADOPAGO",e.PAYPAL="PAYPAL",e.COMERCIALMEXICANA="COMERCIALMEXICANA",e.BANCOMER="BANCOMER",e.WALMART="WALMART",e.BODEGA="BODEGA",e.SAMSCLUB="SAMSCLUB",e.SUPERAMA="SUPERAMA",e.CALIMAX="CALIMAX",e.EXTRA="EXTRA",e.CIRCULOK="CIRCULOK",e.SEVEN11="7ELEVEN",e.TELECOMM="TELECOMM",e.BANORTE="BANORTE",e.BENAVIDES="BENAVIDES",e.DELAHORRO="DELAHORRO",e.ELASTURIANO="ELASTURIANO",e.WALDOS="WALDOS",e.ALSUPER="ALSUPER",e.KIOSKO="KIOSKO",e.STAMARIA="STAMARIA",e.LAMASBARATA="LAMASBARATA",e.FARMROMA="FARMROMA",e.FARMUNION="FARMUNION",e.FARMATODO="FARMATODO",e.SFDEASIS="SFDEASIS",e.FARM911="FARM911",e.FARMECONOMICAS="FARMECONOMICAS",e.FARMMEDICITY="FARMMEDICITY",e.RIANXEIRA="RIANXEIRA",e.WESTERNUNION="WESTERNUNION",e.ZONAPAGO="ZONAPAGO",e.CAJALOSANDES="CAJALOSANDES",e.CAJAPAITA="CAJAPAITA",e.CAJASANTA="CAJASANTA",e.CAJASULLANA="CAJASULLANA",e.CAJATRUJILLO="CAJATRUJILLO",e.EDPYME="EDPYME",e.KASNET="KASNET",e.NORANDINO="NORANDINO",e.QAPAQ="QAPAQ",e.RAIZ="RAIZ",e.PAYSER="PAYSER",e.WUNION="WUNION",e.BANCOCONTINENTAL="BANCOCONTINENTAL",e.GMONEY="GMONEY",e.GOPAY="GOPAY",e.WU="WU",e.PUNTOSHEY="PUNTOSHEY",e.AMPM="AMPM",e.JUMBOMARKET="JUMBOMARKET",e.SMELPUEBLO="SMELPUEBLO",e.BAM="BAM",e.REFACIL="REFACIL",e.ACYVALORES="ACYVALORES"}(i||(i={}));const r=e=>{var t;return e&&"business"in e?null===(t=null==e?void 0:e.business)||void 0===t?void 0:t.pk:""},s=e=>new o({code:(null==e?void 0:e.status)?e.status:e.code,body:null==e?void 0:e.body,name:e?"string"==typeof e?"catch":e.name:"Error",message:e?"string"==typeof e?e:e.message:"Error",stack:"string"==typeof e?void 0:e.stack}),a=(e,n=void 0)=>t(void 0,void 0,void 0,(function*(){let t,i,r="Error";e&&"json"in e&&(t=yield null==e?void 0:e.json()),e&&"status"in e&&(i=e.status.toString()),!t&&e&&"text"in e&&(r=yield e.text()),(null==t?void 0:t.detail)&&(r=t.detail);return new o({code:i,body:t,name:i,message:r,stack:n})})),d=e=>e.trim().replace(/\s+/g,"");class l{constructor({payload:e=null,apiKey:t,baseUrl:n}){this.localStorageKey="verify_transaction_status_url",this.setPayload=e=>{this.payload=e},this.baseUrl=n,this.apiKey=t,this.payload=e}setStorageItem(e){return localStorage.setItem(this.localStorageKey,JSON.stringify(e))}getStorageItem(){return localStorage.getItem(this.localStorageKey)}removeStorageItem(){return localStorage.removeItem(this.localStorageKey)}saveVerifyTransactionUrl(){var e,t,n,o,i,r;const s=null===(n=null===(t=null===(e=this.payload)||void 0===e?void 0:e.next_action)||void 0===t?void 0:t.redirect_to_url)||void 0===n?void 0:n.verify_transaction_status_url;if(s)this.saveUrlWithExpiration(s);else{const e=null===(r=null===(i=null===(o=this.payload)||void 0===o?void 0:o.next_action)||void 0===i?void 0:i.iframe_resources)||void 0===r?void 0:r.verify_transaction_status_url;e?this.saveUrlWithExpiration(e):console.log("No verify_transaction_status_url found")}}saveUrlWithExpiration(e){try{const t={url:e,expires:(new Date).getTime()+12e5};this.setStorageItem(t)}catch(e){console.log("error: ",e)}}getUrlWithExpiration(){const e=this.getStorageItem();if(e){const t=JSON.parse(e);if(!t)return;return(new Date).getTime()>t.expires?(this.removeVerifyTransactionUrl(),null):t.url}return null}removeVerifyTransactionUrl(){return this.removeStorageItem()}getVerifyTransactionUrl(){return this.getStorageItem()}loadIframe(){var e,t,n;if(null===(n=null===(t=null===(e=this.payload)||void 0===e?void 0:e.next_action)||void 0===t?void 0:t.iframe_resources)||void 0===n?void 0:n.iframe)return new Promise(((e,t)=>{var n,o,i;const r=null===(i=null===(o=null===(n=this.payload)||void 0===n?void 0:n.next_action)||void 0===o?void 0:o.iframe_resources)||void 0===i?void 0:i.iframe;if(r){this.saveVerifyTransactionUrl();const n=document.createElement("div");n.innerHTML=r,document.body.appendChild(n);const o=document.createElement("script");o.textContent='document.getElementById("tdsMmethodForm").submit();',n.appendChild(o);const i=document.getElementById("tdsMmethodTgtFrame");i?i.onload=()=>e(!0):(console.log("No redirection found"),t(!1))}else console.log("No redirection found"),t(!1)}))}getRedirectUrl(){var e,t,n;return null===(n=null===(t=null===(e=this.payload)||void 0===e?void 0:e.next_action)||void 0===t?void 0:t.redirect_to_url)||void 0===n?void 0:n.url}redirectToChallenge(){const e=this.getRedirectUrl();e?(this.saveVerifyTransactionUrl(),window.location=e):console.log("No redirection found")}getURLParameters(){const e={},t=new URLSearchParams(window.location.search);for(const[n,o]of t)e[n]=o;return e}handleSuccessTransaction(e){return this.removeVerifyTransactionUrl(),console.log("Transacción autorizada."),e}handleDeclinedTransaction(e){return this.removeVerifyTransactionUrl(),e}handle3dsChallenge(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("form");t.name="frm",t.method="POST",t.action=e.redirect_post_url;const n=document.createElement("input");n.type="hidden",n.name=e.creq,n.value=e.creq,t.appendChild(n);const o=document.createElement("input");o.type="hidden",o.name=e.term_url,o.value=e.TermUrl,t.appendChild(o),document.body.appendChild(t),t.submit(),yield this.verifyTransactionStatus()}))}handleTransactionResponse(e){return t(this,void 0,void 0,(function*(){const t=yield e.json();return"Pending"===t.status&&t.redirect_post_url?yield this.handle3dsChallenge(t):["Success","Authorized"].includes(t.status)?this.handleSuccessTransaction(t):(this.handleDeclinedTransaction(e),t)}))}verifyTransactionStatus(){return t(this,void 0,void 0,(function*(){const e=this.getUrlWithExpiration();if(e){const t=`${this.baseUrl}${e}`;try{const e=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKey}`}});return 200!==e.status?(console.error("La verificación de la transacción falló."),this.removeVerifyTransactionUrl(),e):yield this.handleTransactionResponse(e)}catch(e){console.error("Error al verificar la transacción:",e),this.removeVerifyTransactionUrl()}}else console.log("No verify_transaction_status_url found")}))}}var c,u,h;class p{constructor({signal:e,baseUrlTonder:t,publicApiKeyTonder:o}){c.add(this),this.activeAPMs=[],this.baseUrlTonder=t,this.signal=e,this.publicApiKeyTonder=o,this.process3ds=new l({apiKey:this.publicApiKeyTonder,baseUrl:this.baseUrlTonder}),n(this,c,"m",u).call(this)}getOpenpayDeviceSessionID(e,n,o){return t(this,void 0,void 0,(function*(){try{let t=yield window.OpenPay;return t.setId(e),t.setApiKey(n),t.setSandboxMode(o),yield t.deviceData.setup({signal:this.signal})}catch(e){throw s(e)}}))}getBusiness(){return t(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.baseUrlTonder}/api/v1/payments/business/${this.publicApiKeyTonder}`,{headers:{Authorization:`Token ${this.publicApiKeyTonder}`},signal:this.signal});if(e.ok)return yield e.json();throw yield a(e)}catch(e){throw s(e)}}))}verify3dsTransaction(){return t(this,void 0,void 0,(function*(){const e=yield this.process3ds.verifyTransactionStatus(),t=yield this.resumeCheckout(e);return this.process3ds.setPayload(t),this.handle3dsRedirect(t)}))}resumeCheckout(e){var n,o;return t(this,void 0,void 0,(function*(){if("Hard"===(null===(n=null==e?void 0:e.decline)||void 0===n?void 0:n.error_type))return e;if(["Success","Authorized"].includes(null==e?void 0:e.transaction_status))return e;if(e){const t={checkout_id:null===(o=null==e?void 0:e.checkout)||void 0===o?void 0:o.id};try{return yield this.handleCheckoutRouter(t)}catch(e){}return e}}))}handle3dsRedirect(e){var n,o;return t(this,void 0,void 0,(function*(){if(e&&"next_action"in e?null===(o=null===(n=null==e?void 0:e.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((e=>{console.log("Error loading iframe:",e)}));else{if(!this.process3ds.getRedirectUrl())return e;this.process3ds.redirectToChallenge()}}))}customerRegister(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/customer/`,n={email:e},o=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.publicApiKeyTonder}`},signal:this.signal,body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield a(o)}catch(e){throw s(e)}}))}createOrder(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/orders/`,n=e,o=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.publicApiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield a(o)}catch(e){throw s(e)}}))}createPayment(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/business/${e.business_pk}/payments/`,n=e,o=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.publicApiKeyTonder}`},body:JSON.stringify(n)});if(o.ok)return yield o.json();throw yield a(o)}catch(e){throw s(e)}}))}handleCheckoutRouter(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/checkout-router/`,n=e,o=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.publicApiKeyTonder}`},body:JSON.stringify(Object.assign(Object.assign({},n),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}))});if(o.ok)return yield o.json();throw yield a(o)}catch(e){throw s(e)}}))}startCheckoutRouter(e){return t(this,void 0,void 0,(function*(){const t=yield this.handleCheckoutRouter(e);if(yield this.init3DSRedirect(t))return t}))}startCheckoutRouterFull(e){return t(this,void 0,void 0,(function*(){try{const{order:t,total:n,customer:i,skyflowTokens:r,return_url:s,isSandbox:a,metadata:d,currency:l,payment_method:c}=e,u=yield this.getBusiness(),h=yield this.customerRegister(i.email);if(!(h&&"auth_token"in h&&u&&"reference"in u))throw new o({code:"500",body:u,name:"Keys error",message:"Merchant or customer reposne errors"});{const e={business:this.publicApiKeyTonder,client:h.auth_token,billing_address_id:null,shipping_address_id:null,amount:n,reference:u.reference,is_oneclick:!0,items:t.items},p=yield this.createOrder(e),y=(new Date).toISOString();if(!("id"in p&&"id"in h&&"business"in u))throw new o({code:"500",body:p,name:"Keys error",message:"Order response errors"});{const e={business_pk:u.business.pk,amount:n,date:y,order_id:p.id,client_id:h.id},t=yield this.createPayment(e);let o;const{openpay_keys:m,business:A}=u;m.merchant_id&&m.public_key&&(o=yield this.getOpenpayDeviceSessionID(m.merchant_id,m.public_key,a));const g=Object.assign(Object.assign({name:i.name,last_name:i.lastname,email_client:i.email,phone_number:i.phone,return_url:s,id_product:"no_id",quantity_product:1,id_ship:"0",instance_id_ship:"0",amount:n,title_ship:"shipping",description:"transaction",device_session_id:o||null,token_id:"",order_id:"id"in p&&p.id,business_id:A.pk,payment_id:"pk"in t&&t.pk,source:"sdk",metadata:d,browser_info:{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},currency:l},c?{payment_method:c}:{card:r}),"undefined"!=typeof MP_DEVICE_SESSION_ID?{mp_device_session_id:MP_DEVICE_SESSION_ID}:{}),f=yield this.handleCheckoutRouter(g);if(yield this.init3DSRedirect(f))return f}}}catch(e){throw s(e)}}))}init3DSRedirect(e){return t(this,void 0,void 0,(function*(){return this.process3ds.setPayload(e),yield this.handle3dsRedirect(e)}))}getSkyflowTokens({vault_id:n,vault_url:o,data:i}){return t(this,void 0,void 0,(function*(){const r=e.init({vaultID:n,vaultURL:o,getBearerToken:()=>t(this,void 0,void 0,(function*(){return yield this.getVaultToken()})),options:{logLevel:e.LogLevel.ERROR,env:e.Env.DEV}}).container(e.ContainerType.COLLECT),a=yield this.getFieldsPromise(i,r);if((yield Promise.all(a)).some((e=>!e)))throw s(Error("Ocurrió un error al montar los campos de la tarjeta"));try{const e=yield r.collect();if(e)return e.records[0].fields;throw s(Error("Por favor, verifica todos los campos de tu tarjeta"))}catch(e){throw s(e)}}))}getVaultToken(){var e;return t(this,void 0,void 0,(function*(){try{const t=yield fetch(`${this.baseUrlTonder}/api/v1/vault-token/`,{method:"GET",headers:{Authorization:`Token ${this.publicApiKeyTonder}`},signal:this.signal});if(t.ok)return null===(e=yield t.json())||void 0===e?void 0:e.token;throw new Error(`HTTPCODE: ${t.status}`)}catch(e){throw new Error(`Failed to retrieve bearer token; ${"string"==typeof e?e:e.message}`)}}))}getFieldsPromise(e,n){return t(this,void 0,void 0,(function*(){const t=yield this.getFields(e,n);return t?t.map((t=>new Promise((n=>{var o;const i=document.createElement("div");i.hidden=!0,i.id=`id-${t.key}`,null===(o=document.querySelector("body"))||void 0===o||o.appendChild(i),setTimeout((()=>{t.element.mount(`#id-${t.key}`),setInterval((()=>{if(t.element.isMounted()){const o=e[t.key];return t.element.update({value:o}),n(t.element.isMounted())}}),120)}),120)})))):[]}))}registerCustomerCard(e,o,i){return t(this,void 0,void 0,(function*(){try{yield n(this,c,"m",h).call(this);const t=yield fetch(`${this.baseUrlTonder}/api/v1/business/${r(this.merchantData)}/cards/`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"User-token":o,"Content-Type":"application/json"},signal:this.signal,body:JSON.stringify(Object.assign({},i))});if(t.ok)return yield t.json();throw yield a(t)}catch(e){throw s(e)}}))}getCustomerCards(e,o){return t(this,void 0,void 0,(function*(){try{yield n(this,c,"m",h).call(this);const t=yield fetch(`${this.baseUrlTonder}/api/v1/business/${r(this.merchantData)}/cards`,{method:"GET",headers:{Authorization:`Bearer ${o}`,"User-Token":e,"Content-Type":"application/json",Accept:"application/json"},signal:this.signal});if(t.ok)return yield t.json();throw yield a(t)}catch(e){throw s(e)}}))}deleteCustomerCard(e,o=""){return t(this,void 0,void 0,(function*(){try{yield n(this,c,"m",h).call(this);const t=yield fetch(`${this.baseUrlTonder}/api/v1/business/${r(this.merchantData)}/cards/${o}`,{method:"DELETE",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:this.signal});if(t.ok)return!0;throw yield a(t)}catch(e){throw s(e)}}))}getFields(n,o){return t(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(n).map((n=>t(this,void 0,void 0,(function*(){return{element:yield o.create({table:"cards",column:n,type:e.ElementType.INPUT_FIELD}),key:n}})))))}))}getActiveAPMs(){return t(this,void 0,void 0,(function*(){try{const e=yield function(e,n,o="?status=active&page_size=10000&country=México",i=null){return t(this,void 0,void 0,(function*(){try{const t=yield fetch(`${e}/api/v1/payment_methods${o}`,{method:"GET",headers:{Authorization:`Token ${n}`,"Content-Type":"application/json"},signal:i});if(t.ok)return yield t.json();throw yield a(t)}catch(e){throw s(e)}}))}(this.baseUrlTonder,this.publicApiKeyTonder),n=e&&e.results&&e.results.length>0?e.results:[];return this.activeAPMs=n.filter((e=>"cards"!==e.category.toLowerCase())).map((e=>Object.assign({id:e.pk,payment_method:e.payment_method,priority:e.priority,category:e.category},(e=>{const t=d(e.toUpperCase());return{[i.SORIANA]:{label:"Soriana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png"},[i.OXXO]:{label:"Oxxo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png"},[i.CODI]:{label:"CoDi",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png"},[i.SPEI]:{label:"SPEI",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png"},[i.PAYPAL]:{label:"Paypal",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png"},[i.COMERCIALMEXICANA]:{label:"Comercial Mexicana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png"},[i.BANCOMER]:{label:"Bancomer",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png"},[i.WALMART]:{label:"Walmart",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png"},[i.BODEGA]:{label:"Bodega Aurrera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png"},[i.SAMSCLUB]:{label:"Sam´s Club",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png"},[i.SUPERAMA]:{label:"Superama",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png"},[i.CALIMAX]:{label:"Calimax",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png"},[i.EXTRA]:{label:"Tiendas Extra",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png"},[i.CIRCULOK]:{label:"Círculo K",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png"},[i.SEVEN11]:{label:"7 Eleven",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png"},[i.TELECOMM]:{label:"Telecomm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png"},[i.BANORTE]:{label:"Banorte",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png"},[i.BENAVIDES]:{label:"Farmacias Benavides",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png"},[i.DELAHORRO]:{label:"Farmacias del Ahorro",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png"},[i.ELASTURIANO]:{label:"El Asturiano",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png"},[i.WALDOS]:{label:"Waldos",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png"},[i.ALSUPER]:{label:"Alsuper",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png"},[i.KIOSKO]:{label:"Kiosko",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png"},[i.STAMARIA]:{label:"Farmacias Santa María",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png"},[i.LAMASBARATA]:{label:"Farmacias la más barata",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png"},[i.FARMROMA]:{label:"Farmacias Roma",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png"},[i.FARMUNION]:{label:"Pago en Farmacias Unión",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png"},[i.FARMATODO]:{label:"Pago en Farmacias Farmatodo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png\t"},[i.SFDEASIS]:{label:"Pago en Farmacias San Francisco de Asís",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png"},[i.FARM911]:{label:"Farmacias 911",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.FARMECONOMICAS]:{label:"Farmacias Economicas",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.FARMMEDICITY]:{label:"Farmacias Medicity",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.RIANXEIRA]:{label:"Rianxeira",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.WESTERNUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.ZONAPAGO]:{label:"Zona Pago",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.CAJALOSANDES]:{label:"Caja Los Andes",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.CAJAPAITA]:{label:"Caja Paita",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.CAJASANTA]:{label:"Caja Santa",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.CAJASULLANA]:{label:"Caja Sullana",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.CAJATRUJILLO]:{label:"Caja Trujillo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.EDPYME]:{label:"Edpyme",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.KASNET]:{label:"KasNet",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.NORANDINO]:{label:"Norandino",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.QAPAQ]:{label:"Qapaq",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.RAIZ]:{label:"Raiz",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.PAYSER]:{label:"Paysera",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.WUNION]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.BANCOCONTINENTAL]:{label:"Banco Continental",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.GMONEY]:{label:"Go money",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.GOPAY]:{label:"Go pay",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.WU]:{label:"Western Union",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.PUNTOSHEY]:{label:"Puntoshey",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.AMPM]:{label:"Ampm",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.JUMBOMARKET]:{label:"Jumbomarket",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.SMELPUEBLO]:{label:"Smelpueblo",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.BAM]:{label:"Bam",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.REFACIL]:{label:"Refacil",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"},[i.ACYVALORES]:{label:"Acyvalores",icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png"}}[t]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}})(e.payment_method)))).sort(((e,t)=>e.priority-t.priority)),this.activeAPMs}catch(e){return console.error("Error getting APMS",e),[]}}))}getSecureToken(e){return t(this,void 0,void 0,(function*(){try{const t=yield fetch(`${this.baseUrlTonder}/api/secure-token/`,{method:"POST",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:this.signal});if(t.ok)return yield t.json();throw yield a(t)}catch(e){throw s(e)}}))}}c=new WeakSet,u=function(){return t(this,void 0,void 0,(function*(){this.getActiveAPMs();const{mercado_pago:e}=yield n(this,c,"m",h).call(this);e&&e.active&&function(){try{const e=document.createElement("script");e.src="https://www.mercadopago.com/v2/security.js",e.setAttribute("view",""),e.onload=()=>{console.log("Mercado Pago script loaded successfully.")},e.onerror=e=>{console.error("Error loading Mercado Pago script:",e)},document.head.appendChild(e)}catch(e){console.error("Error attempting to inject Mercado Pago script:",e)}}()}))},h=function(){return t(this,void 0,void 0,(function*(){try{return this.merchantData||(this.merchantData=yield this.getBusiness()),this.merchantData}catch(e){return this.merchantData}}))};export{p as LiteCheckout};
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}),l=(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 c(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})}))}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."});var f,g,v,_,A,b,E,T;class C{constructor({mode:t="stage",apiKey:e,apiKeyTonder:n,returnUrl:o,callBack:r=(()=>{}),baseUrlTonder:i}){f.add(this),this.baseUrl="",this.cartTotal="0",this.metadata={},this.card={},this.currency="",g.set(this,void 0),this.apiKeyTonder=n||e||"",this.returnUrl=o,this.callBack=r,this.mode=t,this.customer={},this.baseUrl=i||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,f,"m",v).call(this,t.customer)}verify3dsTransaction(){return n(this,void 0,void 0,(function*(){const t=yield this.process3ds.verifyTransactionStatus(),e=yield o(this,f,"m",T).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,f,"m",v).call(this,t.customer),this._setCartTotal(null===(n=t.cart)||void 0===n?void 0:n.total),o(this,f,"m",_).call(this,null===(i=t.cart)||void 0===i?void 0:i.items),o(this,f,"m",A).call(this,t),o(this,f,"m",b).call(this,t),o(this,f,"m",E).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,g,"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,g,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,g,"f")}))}_handleCheckout({card:e,payment_method:o,customer:r,isSandbox:i,returnUrl:a}){return n(this,void 0,void 0,(function*(){const{openpay_keys:d,reference:l,business:c}=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,g={business:this.apiKeyTonder,client:f,billing_address_id:null,shipping_address_id:null,amount:u,status:"A",reference:l,is_oneclick:!0,items:this.cartItems},v=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,g),_=(new Date).toISOString(),A={business_pk:c.pk,client_id:y,amount:u,date:_,order_id:v.id},b=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),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:v.id,business_id:c.pk,payment_id:b.pk,source:"sdk",metadata:this.metadata,browser_info:s(),currency:this.currency},o?{payment_method:o}:{card:e}),T=yield p(this.baseUrl,this.apiKeyTonder,E);return T||!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}}))}_getCustomerCards(t,e){return n(this,void 0,void 0,(function*(){return 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 l(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,t,e)}))}_saveCustomerCard(t,e,o,r){return n(this,void 0,void 0,(function*(){return yield function(t,e,o,r,i){return n(this,void 0,void 0,(function*(){try{const n=`${t}/api/v1/business/${r}/cards/`,s=yield fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","User-token":o},body:JSON.stringify(i)});if(s.ok)return yield s.json();const a=yield s.json();throw yield l(s,a)}catch(t){throw d(t)}}))}(this.baseUrl,e,t,o,r)}))}_removeCustomerCard(t,e,o){return n(this,void 0,void 0,(function*(){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 y.cardSaved;if(i.ok&&"json"in i)return yield i.json();const s=yield i.json();throw yield l(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,t,o,e)}))}_fetchCustomerPaymentMethods(){return n(this,void 0,void 0,(function*(){return 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 l(i,s)}catch(t){throw d(t)}}))}(this.baseUrl,this.apiKeyTonder)}))}_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()}}))}}function O({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}}),l=a.container(e.ContainerType.COLLECT),c=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,l);if((yield Promise.all(c)).some((t=>!t)))throw d(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 d(Error("Por favor, verifica todos los campos de tu tarjeta"))}catch(t){throw d(t)}}))}g=new WeakMap,f=new WeakSet,v=function(t){t&&(this.customer=t)},_=function(t){this.cartItems=t},A=function(t){this.metadata=null==t?void 0:t.metadata},b=function(t){this.currency=null==t?void 0:t.currency},E=function(t){this.card=null==t?void 0:t.card},T=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 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"}),j={[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"}},w=t=>{const e=t.toUpperCase().trim().replace(/\s+/g,"");return j[e]||{icon:"https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",label:""}};class M extends C{constructor({apiKey:t,mode:e,returnUrl:n,callBack:o,apiKeyTonder:r,baseUrlTonder:i}){super({mode:e,apiKey:t,returnUrl:n,callBack:o,apiKeyTonder:r,baseUrlTonder:i}),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 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 c({message:y.getCardsError},t)}}))}saveCustomerCard(t,e){return n(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:e,baseUrl:this.baseUrl,apiKey:this.apiKeyTonder});return yield this._saveCustomerCard(t,n,null==i?void 0:i.pk,s)}catch(t){throw c({message:y.saveCardError},t)}}))}removeCustomerCard(t){return n(this,void 0,void 0,(function*(){try{yield this._fetchMerchantData();const{auth_token:e}=yield this._getCustomer(),{business:n}=this.merchantData;return yield this._removeCustomerCard(e,null==n?void 0:n.pk,t)}catch(t){throw c({message:y.removeCardError},t)}}))}getCustomerPaymentMethods(){return n(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},w(t.payment_method)))).sort(((t,e)=>t.priority-e.priority))}catch(t){throw c({message:y.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 c({message:y.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 O({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,returnUrl:r}){return n(this,void 0,void 0,(function*(){yield this._fetchMerchantData();const n=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 O({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:n,isSandbox:o,returnUrl:r})}))}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 l(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 l(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 l(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:l,currency:c,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:_}=h;v.merchant_id&&v.public_key&&(i=yield m(v.merchant_id,v.public_key,d));const A=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:_.pk,payment_id:"pk"in e&&e.pk,source:"sdk",metadata:l,browser_info:s(),currency:c},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,o){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:`Bearer ${t}`,"User-token":e,"Content-Type":"application/json"},body:JSON.stringify(Object.assign({},o))});if(n.ok)return yield n.json();throw yield l(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 l(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 l(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),[]}}))}getSecureToken(t){return n(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.baseUrl}/api/secure-token/`,{method:"POST",headers:{Authorization:`Token ${t}`,"Content-Type":"application/json"},signal:this.abortController.signal});if(e.ok)return yield e.json();throw yield l(e)}catch(t){throw d(t)}}))}}function R(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 U(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 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{C as BaseInlineCheckout,M as LiteCheckout,N as validateCVV,R as validateCardNumber,I as validateCardholderName,U as validateExpirationMonth,k as validateExpirationYear};
@@ -0,0 +1 @@
1
+ export declare const getPaymentMethodDetails: (scheme_data: string) => any;
@@ -0,0 +1,11 @@
1
+ export declare const MESSAGES: Readonly<{
2
+ saveCardError: "Ha ocurrido un error guardando la tarjeta. Inténtalo nuevamente.";
3
+ removeCardError: "Ha ocurrido un error eliminado la tarjeta. Inténtalo nuevamente.";
4
+ getCardsError: "Ha ocurrido un error obteniendo las tarjetas del customer. Inténtalo nuevamente.";
5
+ cardExist: "La tarjeta fue registrada previamente.";
6
+ removedCard: "Card deleted successfully";
7
+ errorCheckout: "No se ha podido procesar el pago";
8
+ cardSaved: "Tarjeta registrada con éxito.";
9
+ getPaymentMethodsError: "Ha ocurrido un error obteniendo las métodos de pago del customer. Inténtalo nuevamente.";
10
+ getBusinessError: "Ha ocurrido un error obteniendo los datos del comercio. Inténtalo nuevamente.";
11
+ }>;
@@ -0,0 +1,62 @@
1
+ declare const PAYMENT_METHOD_APM: Readonly<{
2
+ SORIANA: "SORIANA";
3
+ OXXO: "OXXO";
4
+ SPEI: "SPEI";
5
+ CODI: "CODI";
6
+ MERCADOPAGO: "MERCADOPAGO";
7
+ PAYPAL: "PAYPAL";
8
+ COMERCIALMEXICANA: "COMERCIALMEXICANA";
9
+ BANCOMER: "BANCOMER";
10
+ WALMART: "WALMART";
11
+ BODEGA: "BODEGA";
12
+ SAMSCLUB: "SAMSCLUB";
13
+ SUPERAMA: "SUPERAMA";
14
+ CALIMAX: "CALIMAX";
15
+ EXTRA: "EXTRA";
16
+ CIRCULOK: "CIRCULOK";
17
+ SEVEN11: "7ELEVEN";
18
+ TELECOMM: "TELECOMM";
19
+ BANORTE: "BANORTE";
20
+ BENAVIDES: "BENAVIDES";
21
+ DELAHORRO: "DELAHORRO";
22
+ ELASTURIANO: "ELASTURIANO";
23
+ WALDOS: "WALDOS";
24
+ ALSUPER: "ALSUPER";
25
+ KIOSKO: "KIOSKO";
26
+ STAMARIA: "STAMARIA";
27
+ LAMASBARATA: "LAMASBARATA";
28
+ FARMROMA: "FARMROMA";
29
+ FARMUNION: "FARMUNION";
30
+ FARMATODO: "FARMATODO";
31
+ SFDEASIS: "SFDEASIS";
32
+ FARM911: "FARM911";
33
+ FARMECONOMICAS: "FARMECONOMICAS";
34
+ FARMMEDICITY: "FARMMEDICITY";
35
+ RIANXEIRA: "RIANXEIRA";
36
+ WESTERNUNION: "WESTERNUNION";
37
+ ZONAPAGO: "ZONAPAGO";
38
+ CAJALOSANDES: "CAJALOSANDES";
39
+ CAJAPAITA: "CAJAPAITA";
40
+ CAJASANTA: "CAJASANTA";
41
+ CAJASULLANA: "CAJASULLANA";
42
+ CAJATRUJILLO: "CAJATRUJILLO";
43
+ EDPYME: "EDPYME";
44
+ KASNET: "KASNET";
45
+ NORANDINO: "NORANDINO";
46
+ QAPAQ: "QAPAQ";
47
+ RAIZ: "RAIZ";
48
+ PAYSER: "PAYSER";
49
+ WUNION: "WUNION";
50
+ BANCOCONTINENTAL: "BANCOCONTINENTAL";
51
+ GMONEY: "GMONEY";
52
+ GOPAY: "GOPAY";
53
+ WU: "WU";
54
+ PUNTOSHEY: "PUNTOSHEY";
55
+ AMPM: "AMPM";
56
+ JUMBOMARKET: "JUMBOMARKET";
57
+ SMELPUEBLO: "SMELPUEBLO";
58
+ BAM: "BAM";
59
+ REFACIL: "REFACIL";
60
+ ACYVALORES: "ACYVALORES";
61
+ }>;
62
+ export { PAYMENT_METHOD_APM };
@@ -0,0 +1,7 @@
1
+ declare const TONDER_URL_BY_MODE: Readonly<{
2
+ production: "https://app.tonder.io";
3
+ sandbox: "https://sandbox.tonder.io";
4
+ stage: "https://stage.tonder.io";
5
+ development: "http://localhost:8000";
6
+ }>;
7
+ export { TONDER_URL_BY_MODE };
@@ -0,0 +1,30 @@
1
+ export interface ICard {
2
+ fields: ICardSkyflowFields;
3
+ icon?: string;
4
+ }
5
+ export interface ICardSkyflowFields {
6
+ card_number: string;
7
+ expiration_month: string;
8
+ expiration_year: string;
9
+ skyflow_id: string;
10
+ card_scheme: string;
11
+ cardholder_name: string;
12
+ }
13
+ export interface ICustomerCardsResponse {
14
+ user_id: number;
15
+ cards: ICard[];
16
+ }
17
+ export interface ISaveCardResponse {
18
+ skyflow_id: string;
19
+ user_id: number;
20
+ }
21
+ export interface ISaveCardSkyflowRequest {
22
+ skyflow_id: string;
23
+ }
24
+ export interface ISaveCardRequest {
25
+ card_number: string;
26
+ cvv: string;
27
+ expiration_month: string;
28
+ expiration_year: string;
29
+ cardholder_name: string;
30
+ }
@@ -0,0 +1,109 @@
1
+ import { ICustomer } from "./customer";
2
+ export interface IStartCheckoutRequestBase {
3
+ name: any;
4
+ last_name: string;
5
+ email_client: any;
6
+ phone_number: any;
7
+ return_url?: string;
8
+ id_product: string;
9
+ quantity_product: number;
10
+ id_ship: string;
11
+ instance_id_ship: string;
12
+ amount: any;
13
+ title_ship: string;
14
+ description: string;
15
+ device_session_id: any;
16
+ token_id: string;
17
+ order_id: any;
18
+ business_id: any;
19
+ payment_id: any;
20
+ source: string;
21
+ browser_info?: any;
22
+ metadata: any;
23
+ currency: string;
24
+ }
25
+ export type IStartCheckoutRequestWithCard = IStartCheckoutRequestBase & {
26
+ card: any;
27
+ payment_method?: never;
28
+ };
29
+ export type IStartCheckoutRequestWithPaymentMethod = IStartCheckoutRequestBase & {
30
+ card?: never;
31
+ payment_method: string;
32
+ };
33
+ export type IStartCheckoutRequest = IStartCheckoutRequestWithCard | IStartCheckoutRequestWithPaymentMethod;
34
+ export interface IStartCheckoutIdRequest {
35
+ checkout_id: string;
36
+ }
37
+ export interface IStartCheckoutErrorResponse {
38
+ status: string;
39
+ message: string;
40
+ psp_response: [
41
+ {
42
+ status: number;
43
+ response: Object;
44
+ }
45
+ ];
46
+ checkout_id: string;
47
+ is_route_finished: boolean;
48
+ }
49
+ export interface IStartCheckoutResponse {
50
+ status: string;
51
+ message: string;
52
+ psp_response: Record<string, any>;
53
+ checkout_id: string;
54
+ is_route_finished: Boolean;
55
+ transaction_status: string;
56
+ transaction_id: number;
57
+ payment_id: number;
58
+ provider: string;
59
+ next_action: {
60
+ redirect_to_url?: {
61
+ url: string;
62
+ return_url: string;
63
+ verify_transaction_status_url: string;
64
+ };
65
+ iframe_resources?: {
66
+ iframe: string;
67
+ };
68
+ };
69
+ actions: IStartCheckoutActionResponse[];
70
+ }
71
+ export interface IStartCheckoutActionResponse {
72
+ name: string;
73
+ url: string;
74
+ method: string;
75
+ }
76
+ export interface IItem {
77
+ description: string;
78
+ quantity: number;
79
+ price_unit: number;
80
+ discount: number;
81
+ taxes: number;
82
+ product_reference: string | number;
83
+ name: string;
84
+ amount_total: number;
85
+ }
86
+ export interface IProcessPaymentRequest {
87
+ customer: ICustomer;
88
+ cart: {
89
+ total: string | number;
90
+ items: IItem[];
91
+ };
92
+ metadata?: Record<string, any>;
93
+ currency?: string;
94
+ payment_method?: string;
95
+ card?: ICardFields | string;
96
+ isSandbox?: boolean;
97
+ /**
98
+ * @deprecated This property is deprecated and will be removed in a future release.
99
+ * Use the `returnUrl` field when creating the instance of LiteCheckout or InlineCheckout.
100
+ */
101
+ returnUrl?: string;
102
+ }
103
+ export interface ICardFields {
104
+ card_number: string;
105
+ cvv: string;
106
+ expiration_month: string;
107
+ expiration_year: string;
108
+ cardholder_name: string;
109
+ }
@@ -1,3 +1,5 @@
1
+ import { ICustomer } from "./customer";
2
+ import { IStartCheckoutResponse } from "./checkout";
1
3
  export type Business = {
2
4
  business: {
3
5
  pk: number;
@@ -76,3 +78,43 @@ export type APM = {
76
78
  icon: string;
77
79
  label: string;
78
80
  };
81
+ export interface IConfigureCheckout {
82
+ customer: ICustomer | {
83
+ email: string;
84
+ };
85
+ }
86
+ export interface IInlineCheckoutBaseOptions {
87
+ mode?: "production" | "sandbox" | "stage" | "development";
88
+ /**
89
+ * @deprecated This property is deprecated and will be removed in a future release.
90
+ * `baseUrlTonder` is no longer required.
91
+ */
92
+ baseUrlTonder?: string;
93
+ /**
94
+ * @deprecated This property is deprecated and will be removed in a future release.
95
+ * Use `apiKey` instead, as `apiKeyTonder` is no longer required.
96
+ */
97
+ apiKeyTonder?: string;
98
+ /**
99
+ * @deprecated This property is deprecated and will be removed in a future release.
100
+ * `signal` is no longer required.
101
+ */
102
+ signal?: AbortSignal;
103
+ apiKey: string;
104
+ returnUrl?: string;
105
+ callBack?: (response: IStartCheckoutResponse | Record<string, any>) => void;
106
+ }
107
+ export interface IInlineLiteCheckoutOptions extends IInlineCheckoutBaseOptions {
108
+ }
109
+ export interface IApiError {
110
+ code: string;
111
+ body: Record<string, string> | string;
112
+ name: string;
113
+ message: string;
114
+ }
115
+ export interface IPublicError {
116
+ status: string;
117
+ code: number;
118
+ message: string;
119
+ detail: Record<string, any> | string;
120
+ }
@@ -0,0 +1,22 @@
1
+ export type ICustomer = {
2
+ /**
3
+ * @deprecated This property is deprecated and will be removed in a future release.
4
+ * Use `firstName` instead, as `name` is no longer required.
5
+ */
6
+ name?: string;
7
+ /**
8
+ * @deprecated This property is deprecated and will be removed in a future release.
9
+ * Use `lastName` instead, as `lastname` is no longer required.
10
+ */
11
+ lastname?: string;
12
+ firstName: string;
13
+ lastName: string;
14
+ country?: string;
15
+ street?: string;
16
+ city?: string;
17
+ state?: string;
18
+ postCode?: string;
19
+ email: string;
20
+ phone?: string;
21
+ address?: string;
22
+ };