@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
@@ -0,0 +1,151 @@
1
+ import { IConfigureCheckout } from "./commons";
2
+ import { ICustomerCardsResponse, ISaveCardRequest, ISaveCardResponse } from "./card";
3
+ import { IPaymentMethod } from "./paymentMethod";
4
+ import { IProcessPaymentRequest, IStartCheckoutResponse } from "./checkout";
5
+ import { ITransaction } from "./transaction";
6
+ import { APM } from "./commons";
7
+ import { ErrorResponse } from "../classes/errorResponse";
8
+ import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutFullRequest, StartCheckoutIdRequest, StartCheckoutRequest, TokensRequest } from "./requests";
9
+ import { CreateOrderResponse, CreatePaymentResponse, CustomerRegisterResponse, GetBusinessResponse, RegisterCustomerCardResponse, StartCheckoutResponse } from "./responses";
10
+ export interface ILiteCheckout {
11
+ /**
12
+ * The configureCheckout function allows you to set initial information, such as the customer's email, which is used to retrieve a list of saved cards.
13
+ * @param {import("./index").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
14
+ * @returns {Promise<void>}.
15
+ * @public
16
+ */
17
+ configureCheckout(data: IConfigureCheckout): void;
18
+ /**
19
+ * Initializes and prepares the checkout for use.
20
+ * This method set up the initial environment.
21
+ * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
22
+ * @throws {Error} If there's any problem during the checkout initialization.
23
+ * @public
24
+ */
25
+ injectCheckout(): Promise<void>;
26
+ /**
27
+ * Processes a payment.
28
+ * @param {import("./index").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
29
+ * @returns {Promise<import("./index").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
30
+ *
31
+ * @throws {Error} Throws an error if the checkout process fails. The error object contains
32
+ * additional `details` property with the response from the server if available.
33
+ * @property {import("./index").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
34
+ *
35
+ * @public
36
+ */
37
+ payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
38
+ /**
39
+ * Verifies the 3DS transaction status.
40
+ * @returns {Promise<import("./index").ITransaction | import("./index").IStartCheckoutResponse | void>} The result of the 3DS verification and checkout resumption.
41
+ * @public
42
+ */
43
+ verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
44
+ /**
45
+ * Retrieves the list of cards associated with a customer.
46
+ * @returns {Promise<import("./index").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
47
+ *
48
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
49
+ *
50
+ * @public
51
+ */
52
+ getCustomerCards(): Promise<ICustomerCardsResponse>;
53
+ /**
54
+ * Saves a card to a customer's account. This method can be used to add a new card
55
+ * or update an existing one.
56
+ * @param {import("./index").ISaveCardRequest} card - The card information to be saved.
57
+ * @returns {Promise<import("./index").ISaveCardResponse>} A promise that resolves with the saved card data.
58
+ *
59
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
60
+ *
61
+ * @public
62
+ */
63
+ saveCustomerCard(secureToken: string, card: ISaveCardRequest): Promise<ISaveCardResponse>;
64
+ /**
65
+ * Removes a card from a customer's account.
66
+ * @param {string} skyflowId - The unique identifier of the card to be deleted.
67
+ * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
68
+ *
69
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
70
+ *
71
+ * @public
72
+ */
73
+ removeCustomerCard(skyflowId: string): Promise<string>;
74
+ /**
75
+ * Retrieves the list of available Alternative Payment Methods (APMs).
76
+ * @returns {Promise<import("./index").IPaymentMethod[]>} A promise that resolves with the list of APMs.
77
+ *
78
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
79
+ *
80
+ * @public
81
+ */
82
+ getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
83
+ /**
84
+ * @deprecated This method is deprecated and will be removed in a future release.
85
+ * It is no longer necessary to use this method, now automatically handled
86
+ * during the payment process or when using card management methods.
87
+ *
88
+ * Retrieves the business information.
89
+ * @returns {Promise<import("./index").GetBusinessResponse>} A promise that resolves with the business information.
90
+ *
91
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
92
+ *
93
+ * @public
94
+ */
95
+ getBusiness(): Promise<GetBusinessResponse>;
96
+ /**
97
+ * @deprecated This method is deprecated and will be removed in a future release.
98
+ * It is no longer necessary to use this method as customer registration is now automatically handled
99
+ * during the payment process or when using card management methods.
100
+ */
101
+ customerRegister(email: string): Promise<CustomerRegisterResponse | ErrorResponse>;
102
+ /**
103
+ * @deprecated This method is deprecated and will be removed in a future release.
104
+ * It is no longer necessary to use this method as order creation is now automatically
105
+ * handled when making a payment through the `payment` function.
106
+ */
107
+ createOrder(orderItems: CreateOrderRequest): Promise<CreateOrderResponse | ErrorResponse>;
108
+ /**
109
+ * @deprecated This method is deprecated and will be removed in a future release.
110
+ * It is no longer necessary to use this method as payment creation is now automatically
111
+ * handled when making a payment through the `payment` function.
112
+ */
113
+ createPayment(paymentItems: CreatePaymentRequest): Promise<CreatePaymentResponse | ErrorResponse>;
114
+ /**
115
+ * @deprecated This method is deprecated and will be removed in a future release.
116
+ * Use the {@link payment} method
117
+ */
118
+ startCheckoutRouter(routerData: StartCheckoutRequest | StartCheckoutIdRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
119
+ /**
120
+ * @deprecated This method is deprecated and will be removed in a future release.
121
+ * Use the {@link payment} method
122
+ */
123
+ startCheckoutRouterFull(routerFullData: StartCheckoutFullRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
124
+ /**
125
+ * @deprecated This method is deprecated and will be removed in a future release.
126
+ * Use the {@link saveCustomerCard} method
127
+ */
128
+ registerCustomerCard(secureToken: string, customerToken: string, data: RegisterCustomerCardRequest): Promise<RegisterCustomerCardResponse | ErrorResponse>;
129
+ /**
130
+ * @deprecated This method is deprecated and will be removed in a future release.
131
+ * Use the {@link removeCustomerCard} method
132
+ */
133
+ deleteCustomerCard(customerToken: string, skyflowId: string): Promise<Boolean | ErrorResponse>;
134
+ /**
135
+ * @deprecated This method is deprecated and will be removed in a future release.
136
+ * Use the {@link getCustomerPaymentMethods} method
137
+ */
138
+ getActiveAPMs(): Promise<APM[]>;
139
+ /**
140
+ * @deprecated This method is deprecated and will be removed in a future release.
141
+ * It is no longer necessary to use this method as card registration or as checkout is now automatically handled
142
+ * during the payment process or when using card management methods.
143
+ */
144
+ getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
145
+ /**
146
+ * @deprecated This method is deprecated and will be removed in a future release.
147
+ * It is no longer necessary to use this method is now automatically handled
148
+ * during the payment process.
149
+ */
150
+ getOpenpayDeviceSessionID(merchant_id: string, public_key: string, is_sandbox: boolean): Promise<string | ErrorResponse>;
151
+ }
@@ -0,0 +1,22 @@
1
+ export interface IPaymentMethodResponse {
2
+ count: number;
3
+ next: string | null;
4
+ previous: string | null;
5
+ results: ITonderPaymentMethod[];
6
+ }
7
+ export interface ITonderPaymentMethod {
8
+ pk: string;
9
+ payment_method: string;
10
+ priority: number;
11
+ category: string;
12
+ unavailable_countries: string[];
13
+ status: string;
14
+ }
15
+ export interface IPaymentMethod {
16
+ id: string;
17
+ payment_method: string;
18
+ priority: number;
19
+ category: string;
20
+ icon: string;
21
+ label: string;
22
+ }
@@ -1,5 +1,5 @@
1
- import { OrderItem } from "./commons";
2
1
  import { SkyflowRecord } from "./skyflow";
2
+ import { IItem } from "./checkout";
3
3
  export interface CreateOrderRequest {
4
4
  business: string;
5
5
  client: string;
@@ -9,7 +9,7 @@ export interface CreateOrderRequest {
9
9
  status?: string;
10
10
  reference: string | number;
11
11
  is_oneclick: boolean;
12
- items: OrderItem[];
12
+ items: IItem[];
13
13
  }
14
14
  export type CreatePaymentRequest = {
15
15
  business_pk?: string | number;
@@ -61,6 +61,15 @@ export interface VaultRequest extends SkyflowRecord {
61
61
  export type RegisterCustomerCardRequest = {
62
62
  skyflow_id: string;
63
63
  };
64
+ export type TokensSkyflowRequest = {
65
+ baseUrl: string;
66
+ apiKey: string;
67
+ vault_id: string;
68
+ vault_url: string;
69
+ data: {
70
+ [key: string]: any;
71
+ };
72
+ };
64
73
  export type TokensRequest = {
65
74
  vault_id: string;
66
75
  vault_url: string;
@@ -70,7 +79,7 @@ export type TokensRequest = {
70
79
  };
71
80
  export type StartCheckoutFullRequest = {
72
81
  order: {
73
- items: OrderItem[];
82
+ items: IItem[];
74
83
  };
75
84
  total: number;
76
85
  customer: {
@@ -0,0 +1,101 @@
1
+ export interface ITransaction {
2
+ id: number;
3
+ provider: string;
4
+ country: string;
5
+ currency_code: string;
6
+ transaction_status: string;
7
+ created: string;
8
+ modified: string;
9
+ operation_date: string;
10
+ transaction_reference: string;
11
+ transaction_type: string;
12
+ status: string;
13
+ amount: string;
14
+ related_transaction_reference?: null | string;
15
+ reason?: null | string;
16
+ is_refunded?: null | boolean;
17
+ is_disputed?: null | boolean;
18
+ number_of_payment_attempts: number;
19
+ card_brand?: null | string;
20
+ number_of_installments: number;
21
+ payment?: {
22
+ id: number;
23
+ created: string;
24
+ modified: string;
25
+ amount: string;
26
+ status: string;
27
+ date: string;
28
+ paid_date: null | string;
29
+ source: null | string;
30
+ customer_order_reference: null | string;
31
+ client: number;
32
+ business: number;
33
+ shipping_address?: null | string;
34
+ billing_address?: null | string;
35
+ order: number;
36
+ };
37
+ checkout: {
38
+ id: string;
39
+ created: string;
40
+ modified: string;
41
+ checkout_data: {
42
+ name: string;
43
+ amount: number;
44
+ source: string;
45
+ id_ship: string;
46
+ currency: string;
47
+ order_id: number;
48
+ token_id: string;
49
+ last_name: string;
50
+ id_product: string;
51
+ ip_address: string;
52
+ payment_id: number;
53
+ return_url: string;
54
+ title_ship: string;
55
+ business_id: number;
56
+ checkout_id: string;
57
+ description: string;
58
+ browser_info: {
59
+ language: string;
60
+ time_zone: number;
61
+ user_agent: string;
62
+ color_depth: number;
63
+ screen_width: number;
64
+ screen_height: number;
65
+ javascript_enabled: boolean;
66
+ };
67
+ email_client: string;
68
+ phone_number: string;
69
+ instance_id_ship: string;
70
+ quantity_product: number;
71
+ device_session_id: null | string;
72
+ number_of_payment_attempts: number;
73
+ };
74
+ number_of_payment_attempts: number;
75
+ tried_psps: string[];
76
+ rejected_transactions: string[];
77
+ routing_step: number;
78
+ route_length: number;
79
+ last_status: string;
80
+ ip_address: string;
81
+ is_dynamic_routing: boolean;
82
+ is_route_finished: boolean;
83
+ business: number;
84
+ payment: number;
85
+ };
86
+ currency: {
87
+ id: number;
88
+ name: string;
89
+ code: string;
90
+ symbol: string;
91
+ country: null | string;
92
+ };
93
+ payment_method?: null | {
94
+ id: number;
95
+ name: string;
96
+ display_name: string;
97
+ category: string;
98
+ is_apm: boolean;
99
+ };
100
+ issuing_country?: null | string;
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonder.io/ionic-lite-sdk",
3
- "version": "0.0.36-beta.1",
3
+ "version": "0.0.38-beta.1",
4
4
  "description": "Tonder ionic lite SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "author": "",
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
+ "lodash.get": "^4.4.2",
15
16
  "skyflow-js": "^1.34.1",
16
17
  "ts-node": "^10.9.2"
17
18
  },
@@ -24,6 +25,8 @@
24
25
  "@rollup/plugin-typescript": "11.1.6",
25
26
  "@types/crypto-js": "^4.2.2",
26
27
  "@types/jest": "^29.5.11",
28
+ "@types/lodash": "^4.17.10",
29
+ "@types/lodash.get": "^4.4.9",
27
30
  "@types/node": "^20.11.5",
28
31
  "jest": "^29.7.0",
29
32
  "jest-environment-jsdom": "^29.7.0",