@tonder.io/ionic-lite-sdk 0.0.3

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 (36) hide show
  1. package/.gitlab-ci.yml +29 -0
  2. package/README.md +496 -0
  3. package/dist/classes/errorResponse.d.ts +9 -0
  4. package/dist/classes/liteCheckout.d.ts +34 -0
  5. package/dist/helpers/utils.d.ts +3 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +1 -0
  8. package/dist/types/commons.d.ts +58 -0
  9. package/dist/types/requests.d.ts +55 -0
  10. package/dist/types/responses.d.ts +177 -0
  11. package/dist/types/skyflow.d.ts +17 -0
  12. package/jest.config.ts +15 -0
  13. package/package.json +34 -0
  14. package/rollup.config.js +17 -0
  15. package/src/classes/errorResponse.ts +17 -0
  16. package/src/classes/liteCheckout.ts +301 -0
  17. package/src/helpers/utils.ts +37 -0
  18. package/src/index.ts +5 -0
  19. package/src/types/commons.ts +61 -0
  20. package/src/types/requests.ts +61 -0
  21. package/src/types/responses.ts +186 -0
  22. package/src/types/skyflow.ts +17 -0
  23. package/tests/classes/liteCheckout.test.ts +57 -0
  24. package/tests/methods/createOrder.test.ts +106 -0
  25. package/tests/methods/createPayment.test.ts +109 -0
  26. package/tests/methods/customerRegister.test.ts +106 -0
  27. package/tests/methods/getBusiness.test.ts +102 -0
  28. package/tests/methods/getCustomerCards.test.ts +105 -0
  29. package/tests/methods/getOpenpayDeviceSessionID.test.ts +95 -0
  30. package/tests/methods/getSkyflowToken.test.ts +137 -0
  31. package/tests/methods/getVaultToken.test.ts +107 -0
  32. package/tests/methods/registerCustomerCard.test.ts +105 -0
  33. package/tests/methods/startCheckoutRouter.test.ts +107 -0
  34. package/tests/utils/defaultMock.ts +21 -0
  35. package/tests/utils/mockClasses.ts +540 -0
  36. package/tsconfig.json +19 -0
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,29 @@
1
+ image: grupoapok/awscli:18
2
+
3
+ stages:
4
+ - test
5
+ - deploy
6
+
7
+ test:
8
+ stage: test
9
+ only:
10
+ - development
11
+ before_script:
12
+ - npm install
13
+ script:
14
+ - npm run test
15
+
16
+ deploy:
17
+ stage: deploy
18
+ only:
19
+ - tags
20
+ before_script:
21
+ - |
22
+ {
23
+ echo "@tonder.io:https://registry=//registry.npmjs.org/"
24
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
25
+ } | tee -a .npmrc
26
+ script:
27
+ - npm install
28
+ - npm run build
29
+ - npm publish
package/README.md ADDED
@@ -0,0 +1,496 @@
1
+ # Tonder SDK
2
+
3
+ Tonder SDK Lite to integrate REST service
4
+
5
+ ## Installation
6
+
7
+ You can install using NPM
8
+ ```bash
9
+ npm i @tonder/ionic-lite-sdk
10
+ ```
11
+
12
+ or using an script tag
13
+ ```html
14
+ // TO DO
15
+ ```
16
+
17
+ Add dependencies to the root of the app (index.html)
18
+ ```html
19
+ <script src=https://openpay.s3.amazonaws.com/openpay.v1.min.js></script>
20
+ <script src=https://openpay.s3.amazonaws.com/openpay-data.v1.min.js></script>
21
+ ```
22
+
23
+ ## Usage
24
+ ## Import LiteCheckout class
25
+ ```javascript
26
+ import { LiteCheckout } from "@tonder/ionic-lite-sdk"
27
+ ```
28
+ ## Create instance
29
+
30
+ ```javascript
31
+ const liteCheckout = new LiteCheckout({
32
+ signal,
33
+ baseUrlTonder,
34
+ apiKeyTonder
35
+ })
36
+ ```
37
+
38
+ | Property | Type | Description |
39
+ |:---------------:|:-------------:|:-----------------------------------------------------------------------:|
40
+ | signal | AborSignal | Signal from AbortController instance if it need cancel request |
41
+ | baseUrlTonder | string | Live server: http://stage.tonder.io |
42
+ | | | Mock Server: https://stoplight.io/mocks/tonder/tonder-api-v1-2/3152148 |
43
+ | apiKeyTonder | string | You can take this from you Tonder Dashboard |
44
+
45
+ # Class methods
46
+
47
+ # Business
48
+
49
+ ## Get business
50
+
51
+ ```javascript
52
+ const merchantData = await liteCheckout.getBusiness();
53
+ ```
54
+
55
+ ## Return business data
56
+
57
+ ```typescript
58
+ {
59
+ business: {
60
+ pk: number,
61
+ name: string,
62
+ categories: [
63
+ {
64
+ pk: number,
65
+ name: string
66
+ }
67
+ ],
68
+ web: string,
69
+ logo: string,
70
+ full_logo_url: string,
71
+ background_color: string,
72
+ primary_color: string,
73
+ checkout_mode: boolean,
74
+ textCheckoutColor: string,
75
+ textDetailsColor: string,
76
+ checkout_logo: string
77
+ },
78
+ openpay_keys: {
79
+ merchant_id: string,
80
+ public_key: string
81
+ },
82
+ fintoc_keys: {
83
+ public_key: string
84
+ },
85
+ vault_id: string,
86
+ vault_url: string,
87
+ reference: number,
88
+ is_installments_available: boolean
89
+ }
90
+ ```
91
+
92
+ # OpenPay
93
+
94
+ ## Get OpenPay session id
95
+
96
+ ```javascript
97
+ const { openpay_keys } = merchantData;
98
+
99
+ const deviceSessionIdTonder = await liteCheckout.getOpenpayDeviceSessionID(
100
+ openpay_keys.merchant_id,
101
+ openpay_keys.public_key
102
+ );
103
+ ```
104
+
105
+ ## Return OpenPay device session id
106
+
107
+ string
108
+
109
+ # Customer
110
+
111
+ ## Get customer authorization token
112
+
113
+ ```javascript
114
+ const customerEmail = "john.c.calhoun@examplepetstore.com";
115
+
116
+ const { auth_token } = await liteCheckout.customerRegister(customerEmail);
117
+ ```
118
+
119
+ ## Return customer data
120
+
121
+ ```typescript
122
+ {
123
+ id: number,
124
+ email: string,
125
+ auth_token: string
126
+ }
127
+ ```
128
+
129
+ # Order
130
+
131
+ ## Create order
132
+
133
+ ```typescript
134
+ const cartItems = [
135
+ {
136
+ description: "Test product description",
137
+ quantity: 1,
138
+ price_unit: 25,
139
+ discount: 0,
140
+ taxes: 12,
141
+ product_reference: 65421,
142
+ name: "Test product",
143
+ amount_total: 25
144
+ }
145
+ ]
146
+
147
+ const { reference } = merchantData;
148
+
149
+ const orderData = {
150
+ business: apiKeyTonder,
151
+ client: auth_token,
152
+ billing_address_id: null,
153
+ shipping_address_id: null,
154
+ amount: total,
155
+ status: "A",
156
+ reference: reference,
157
+ is_oneclick: true,
158
+ items: cartItems,
159
+ };
160
+
161
+ const jsonResponseOrder = await liteCheckout.createOrder(
162
+ orderData
163
+ );
164
+ ```
165
+
166
+ ## Return order data
167
+ ```typescript
168
+ {
169
+ id: number,
170
+ created: string,
171
+ amount: string,
172
+ status: string,
173
+ payment_method?: string,
174
+ reference?: string,
175
+ is_oneclick: boolean,
176
+ items: [
177
+ {
178
+ description: string,
179
+ product_reference: string,
180
+ quantity: string,
181
+ price_unit: string,
182
+ discount: string,
183
+ taxes: string,
184
+ amount_total: string
185
+ }
186
+ ],
187
+ billing_address?: string,
188
+ shipping_address?: string,
189
+ client: {
190
+ email: string,
191
+ name: string,
192
+ first_name: string,
193
+ last_name: string,
194
+ client_profile: {
195
+ gender: string,
196
+ date_birth?: string,
197
+ terms: boolean,
198
+ phone: string
199
+ }
200
+ }
201
+ }
202
+ ```
203
+
204
+ # Payment
205
+
206
+ ## Create payment
207
+ ```javascript
208
+ const now = new Date();
209
+ const dateString = now.toISOString();
210
+
211
+ const paymentData = {
212
+ business_pk: business.pk,
213
+ amount: total,
214
+ date: dateString,
215
+ order: jsonResponseOrder.id,
216
+ };
217
+
218
+ const jsonResponsePayment = await liteCheckout.createPayment(
219
+ paymentData
220
+ );
221
+ ```
222
+
223
+ ## Return payment data
224
+ ```javascript
225
+ {
226
+ pk: number,
227
+ order?: string,
228
+ amount: string,
229
+ status: string,
230
+ date: string,
231
+ paid_date?: string,
232
+ shipping_address: {
233
+ street: string,
234
+ number: string,
235
+ suburb: string,
236
+ city: {
237
+ name: string
238
+ },
239
+ state: {
240
+ name: string,
241
+ country: {
242
+ name: string
243
+ }
244
+ },
245
+ zip_code: string
246
+ },
247
+ shipping_address_id?: string,
248
+ billing_address: {
249
+ street: string,
250
+ number: string,
251
+ suburb: string,
252
+ city: {
253
+ name: string
254
+ },
255
+ state: {
256
+ name: string,
257
+ country: {
258
+ name: string
259
+ }
260
+ },
261
+ zip_code: string
262
+ },
263
+ billing_address_id?: string,
264
+ client?: string,
265
+ customer_order_reference?: string
266
+ }
267
+ ```
268
+
269
+ # Skyflow tokens
270
+
271
+ ## Get skyflow payment form tokenized values
272
+
273
+ The values of the variable skyflowTokens come from your html form
274
+
275
+ ```javascript
276
+
277
+ const skyflowFields = {
278
+ card_number: this.paymentForm.value.cardNumber,
279
+ cvv: this.paymentForm.value.cvv,
280
+ expiration_month: this.paymentForm.value.month,
281
+ expiration_year: this.paymentForm.value.expirationYear,
282
+ cardholder_name: this.paymentForm.value.name
283
+ }
284
+
285
+ const { vault_id, vault_url } = merchantData;
286
+
287
+
288
+ const skyflowTokens = await liteCheckout.getSkyflowTokens({
289
+ vault_id: vault_id,
290
+ vault_url: vault_url,
291
+ data: skyflowFields
292
+ })
293
+
294
+ ```
295
+
296
+ ## Return skyflow tokenized data
297
+ ```typescript
298
+ {
299
+ vaultID: string,
300
+ responses: [
301
+ {
302
+ records: [
303
+ {
304
+ skyflow_id: string
305
+ }
306
+ ]
307
+ },
308
+ {
309
+ fields: {
310
+ card_number: string,
311
+ cardholder_name: string,
312
+ cvv: string,
313
+ expiration_month: string,
314
+ expiration_year: string,
315
+ skyflow_id: string
316
+ }
317
+ }
318
+ ]
319
+ }
320
+ ```
321
+
322
+ # Checkout router
323
+
324
+ ## Get checkout router data
325
+
326
+ ```javascript
327
+
328
+ const customerPhone = "+11111111";
329
+ const returnUrl = "http://localhost:8100/payment/success";
330
+
331
+ const routerData = {
332
+ card: skyflowTokens,
333
+ name: skyflowTokens.cardholder_name,
334
+ last_name: "",
335
+ email_client: customerEmail,
336
+ phone_number: customerPhone,
337
+ return_url: returnUrl,
338
+ id_product: "no_id",
339
+ quantity_product: 1,
340
+ id_ship: "0",
341
+ instance_id_ship: "0",
342
+ amount: total,
343
+ title_ship: "shipping",
344
+ description: "Transaction from the lite SDK",
345
+ device_session_id: deviceSessionIdTonder,
346
+ token_id: "",
347
+ order_id: jsonResponseOrder.id,
348
+ business_id: business.pk,
349
+ payment_id: jsonResponsePayment.pk,
350
+ source: 'ionic-lite-sdk',
351
+ };
352
+
353
+ const jsonResponseRouter = await liteCheckout.startCheckoutRouter(
354
+ routerData
355
+ );
356
+
357
+ ```
358
+
359
+ ## Return checkout router data
360
+
361
+ ```typescript
362
+ {
363
+ status: 200,
364
+ message: "Success",
365
+ psp_response: {
366
+ id: string,
367
+ authorization: number,
368
+ operation_type: string,
369
+ transaction_type: string,
370
+ status: string,
371
+ conciliated: boolean,
372
+ creation_date: string,
373
+ operation_date: string,
374
+ description: string,
375
+ error_message?: string,
376
+ order_id?: string,
377
+ card: {
378
+ type: string,
379
+ brand: string,
380
+ address?: string,
381
+ card_number: string,
382
+ holder_name: string,
383
+ expiration_year: string,
384
+ expiration_month: string,
385
+ allows_charges: boolean,
386
+ allows_payouts: boolean,
387
+ bank_name: string,
388
+ points_type: string,
389
+ points_card: boolean,
390
+ bank_code: number
391
+ },
392
+ customer_id: string,
393
+ gateway_card_present: string,
394
+ amount: number,
395
+ fee: {
396
+ amount: number,
397
+ tax: number,
398
+ currency: string
399
+ },
400
+ payment_method: {
401
+ type: string,
402
+ url: string
403
+ },
404
+ currency: string,
405
+ method: string,
406
+ object: string
407
+ },
408
+ transaction_status: string,
409
+ transaction_id: number,
410
+ payment_id: number,
411
+ provider: string,
412
+ next_action: {
413
+ redirect_to_url: {
414
+ url: string,
415
+ return_url: string,
416
+ verify_transaction_status_url: string
417
+ }
418
+ },
419
+ actions: [
420
+ {
421
+ name: string,
422
+ url: string,
423
+ method: string
424
+ }
425
+ ]
426
+ }
427
+ ```
428
+
429
+ ## Take actions on base to the checkout router response
430
+
431
+ # Customer Cards(Register)
432
+
433
+ ## Register customer card
434
+
435
+ ```typescript
436
+
437
+ aut_token: string;
438
+
439
+ data: {
440
+ skyflow_id: string;
441
+ };
442
+
443
+ const jsonResponseOrder = await liteCheckout.registerCustomerCard(
444
+ aut_token,
445
+ data
446
+ );
447
+ ```
448
+
449
+ ## Return register customer card
450
+ ```typescript
451
+ {
452
+ skyflow_id: string;
453
+ user_id: number;
454
+ }
455
+ ```
456
+
457
+ # Customer Cards(Get)
458
+
459
+ ## Get customer cards
460
+
461
+ ```typescript
462
+
463
+ aut_token: string;
464
+
465
+ query: string = "?ordering=<string>&search=<string>";
466
+
467
+ const jsonResponseOrder = await liteCheckout.getCustomerCards(
468
+ aut_token,
469
+ query
470
+ );
471
+ ```
472
+
473
+ ## Return get customer card
474
+ ```typescript
475
+ {
476
+ user_id: number,
477
+ cards: {
478
+ records: [
479
+ {
480
+ fields: {
481
+ card_number: string,
482
+ cardholder_name: string,
483
+ cvv: string,
484
+ expiration_month: string,
485
+ expiration_year: string,
486
+ skyflow_id: string
487
+ }
488
+ }
489
+ ]
490
+ }
491
+ }
492
+ ```
493
+
494
+ ## License
495
+
496
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,9 @@
1
+ import { IErrorResponse } from "../types/responses";
2
+ export declare class ErrorResponse implements IErrorResponse {
3
+ code?: string | undefined;
4
+ body?: string | undefined;
5
+ name: string;
6
+ message: string;
7
+ stack?: string | undefined;
8
+ constructor({ code, body, name, message, stack }: IErrorResponse);
9
+ }
@@ -0,0 +1,34 @@
1
+ import CollectContainer from "skyflow-js/types/core/external/collect/collect-container";
2
+ import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutRequest, TokensRequest } from "../types/requests";
3
+ import { GetBusinessResponse, CustomerRegisterResponse, CreateOrderResponse, CreatePaymentResponse, StartCheckoutResponse, GetCustomerCardsResponse, RegisterCustomerCardResponse } from "../types/responses";
4
+ import { ErrorResponse } from "./errorResponse";
5
+ declare global {
6
+ interface Window {
7
+ OpenPay: any;
8
+ }
9
+ }
10
+ export type LiteCheckoutConstructor = {
11
+ signal: AbortSignal;
12
+ baseUrlTonder: string;
13
+ apiKeyTonder: string;
14
+ };
15
+ export declare class LiteCheckout implements LiteCheckoutConstructor {
16
+ signal: AbortSignal;
17
+ baseUrlTonder: string;
18
+ apiKeyTonder: string;
19
+ constructor({ signal, baseUrlTonder, apiKeyTonder, }: LiteCheckoutConstructor);
20
+ getOpenpayDeviceSessionID(merchant_id: string, public_key: string): Promise<string | ErrorResponse>;
21
+ getBusiness(): Promise<GetBusinessResponse | ErrorResponse>;
22
+ customerRegister(email: string): Promise<CustomerRegisterResponse | ErrorResponse>;
23
+ createOrder(orderItems: CreateOrderRequest): Promise<CreateOrderResponse | ErrorResponse>;
24
+ createPayment(paymentItems: CreatePaymentRequest): Promise<CreatePaymentResponse | ErrorResponse>;
25
+ startCheckoutRouter(routerData: StartCheckoutRequest): Promise<StartCheckoutResponse | ErrorResponse>;
26
+ getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
27
+ getVaultToken(): Promise<string>;
28
+ getFieldsPromise(data: any, collectContainer: CollectContainer): Promise<Promise<boolean>[]>;
29
+ registerCustomerCard(customerToken: string, data: RegisterCustomerCardRequest): Promise<RegisterCustomerCardResponse | ErrorResponse>;
30
+ getCustomerCards(customerToken: string, query?: string): Promise<GetCustomerCardsResponse | ErrorResponse>;
31
+ private buildErrorResponseFromCatch;
32
+ private buildErrorResponse;
33
+ private getFields;
34
+ }
@@ -0,0 +1,3 @@
1
+ export declare const createObserver: ({ target }: {
2
+ target: string;
3
+ }) => Promise<any>;
@@ -0,0 +1,2 @@
1
+ import { LiteCheckout } from './classes/liteCheckout';
2
+ export { LiteCheckout };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import e from"skyflow-js";function t(e,t,o,i){return new(o||(o=Promise))((function(r,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function d(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,d)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class o{constructor({code:e,body:t,name:o,message:i,stack:r}){this.code=e,this.body=t,this.name=o,this.message=i,this.stack=r}}class i{constructor({signal:e,baseUrlTonder:t,apiKeyTonder:o}){this.baseUrlTonder=t,this.signal=e,this.apiKeyTonder=o}getOpenpayDeviceSessionID(e,o){return t(this,void 0,void 0,(function*(){try{let t=yield window.OpenPay;return t.setId(e),t.setApiKey(o),t.setSandboxMode(!0),yield t.deviceData.setup({signal:this.signal})}catch(e){throw this.buildErrorResponseFromCatch(e)}}))}getBusiness(){return t(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.baseUrlTonder}/api/v1/payments/business/${this.apiKeyTonder}`,{headers:{Authorization:`Token ${this.apiKeyTonder}`},signal:this.signal});return e.ok?yield e.json():yield this.buildErrorResponse(e)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}customerRegister(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/customer/`,o={email:e},i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},signal:this.signal,body:JSON.stringify(o)});return i.ok?yield i.json():yield this.buildErrorResponse(i)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}createOrder(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/orders/`,o=e,i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});return i.ok?yield i.json():yield this.buildErrorResponse(i)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}createPayment(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/business/${e.business_pk}/payments/`,o=e,i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});return i.ok?yield i.json():yield this.buildErrorResponse(i)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}startCheckoutRouter(e){return t(this,void 0,void 0,(function*(){try{const t=`${this.baseUrlTonder}/api/v1/checkout-router/`,o=e,i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${this.apiKeyTonder}`},body:JSON.stringify(o)});return i.ok?yield i.json():yield this.buildErrorResponse(i)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}getSkyflowTokens({vault_id:o,vault_url:i,data:r}){return t(this,void 0,void 0,(function*(){const n=e.init({vaultID:o,vaultURL:i,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),s=yield this.getFieldsPromise(r,n);if((yield Promise.all(s)).some((e=>!e)))return this.buildErrorResponseFromCatch(Error("Ocurrió un error al montar los campos de la tarjeta"));try{const e=yield n.collect();return e?e.records[0].fields:this.buildErrorResponseFromCatch(Error("Por favor, verifica todos los campos de tu tarjeta"))}catch(e){return this.buildErrorResponseFromCatch(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.apiKeyTonder}`},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,o){return t(this,void 0,void 0,(function*(){const t=yield this.getFields(e,o);return t?t.map((t=>new Promise((o=>{var i;const r=document.createElement("div");r.hidden=!0,r.id=`id-${t.key}`,null===(i=document.querySelector("body"))||void 0===i||i.appendChild(r),setTimeout((()=>{t.element.mount(`#id-${t.key}`),setInterval((()=>{if(t.element.isMounted()){const i=e[t.key];return t.element.update({value:i}),o(t.element.isMounted())}}),120)}),120)})))):[]}))}registerCustomerCard(e,o){return t(this,void 0,void 0,(function*(){try{const t=yield fetch(`${this.baseUrlTonder}/api/v1/cards/`,{method:"POST",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:this.signal,body:JSON.stringify(o)});return t.ok?yield t.json():yield this.buildErrorResponse(t)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}getCustomerCards(e,o=""){return t(this,void 0,void 0,(function*(){try{const t=yield fetch(`${this.baseUrlTonder}/api/v1/cards/${o}`,{method:"GET",headers:{Authorization:`Token ${e}`,"Content-Type":"application/json"},signal:this.signal});return t.ok?yield t.json():yield this.buildErrorResponse(t)}catch(e){return this.buildErrorResponseFromCatch(e)}}))}buildErrorResponseFromCatch(e){return new o({code:void 0,body:void 0,name:"string"==typeof e?"catch":e.name,message:"string"==typeof e?e:e.message,stack:"string"==typeof e?void 0:e.stack})}buildErrorResponse(e,i=void 0){var r,n,s,d,a,l;return t(this,void 0,void 0,(function*(){return new o({code:null===(n=null===(r=e.status)||void 0===r?void 0:r.toString)||void 0===n?void 0:n.call(r),body:yield null===(s=null==e?void 0:e.json)||void 0===s?void 0:s.call(e),name:null===(a=null===(d=e.status)||void 0===d?void 0:d.toString)||void 0===a?void 0:a.call(d),message:yield null===(l=null==e?void 0:e.text)||void 0===l?void 0:l.call(e),stack:i})}))}getFields(o,i){return t(this,void 0,void 0,(function*(){return yield Promise.all(Object.keys(o).map((o=>t(this,void 0,void 0,(function*(){return{element:yield i.create({table:"cards",column:o,type:e.ElementType.INPUT_FIELD}),key:o}})))))}))}}export{i as LiteCheckout};
@@ -0,0 +1,58 @@
1
+ export type Business = {
2
+ business: {
3
+ pk: number;
4
+ name: string;
5
+ categories: {
6
+ pk: number;
7
+ name: string;
8
+ }[];
9
+ web: string;
10
+ logo: string;
11
+ full_logo_url: string;
12
+ background_color: string;
13
+ primary_color: string;
14
+ checkout_mode: boolean;
15
+ textCheckoutColor: string;
16
+ textDetailsColor: string;
17
+ checkout_logo: string;
18
+ };
19
+ openpay_keys: {
20
+ merchant_id: string;
21
+ public_key: string;
22
+ };
23
+ fintoc_keys: {
24
+ public_key: string;
25
+ };
26
+ vault_id: string;
27
+ vault_url: string;
28
+ reference: number;
29
+ is_installments_available: boolean;
30
+ };
31
+ export type Customer = {
32
+ firstName: string;
33
+ lastName: string;
34
+ country: string;
35
+ street: string;
36
+ city: string;
37
+ state: string;
38
+ postCode: string;
39
+ email: string;
40
+ phone: string;
41
+ };
42
+ export type OrderItem = {
43
+ description: string;
44
+ quantity: number;
45
+ price_unit: number;
46
+ discount: number;
47
+ taxes: number;
48
+ product_reference: number;
49
+ name: string;
50
+ amount_total: number;
51
+ };
52
+ export type PaymentData = {
53
+ customer: Customer;
54
+ cart: {
55
+ total: string | number;
56
+ items: OrderItem[];
57
+ };
58
+ };
@@ -0,0 +1,55 @@
1
+ import { OrderItem } from "./commons";
2
+ import { SkyflowRecord } from "./skyflow";
3
+ export interface CreateOrderRequest {
4
+ business: string;
5
+ client: string;
6
+ billing_address_id?: string | null;
7
+ shipping_address_id?: string | null;
8
+ amount: number;
9
+ status: string;
10
+ reference: string | number;
11
+ is_oneclick: boolean;
12
+ items: OrderItem[];
13
+ }
14
+ export type CreatePaymentRequest = {
15
+ business_pk: string | number;
16
+ amount: number;
17
+ date: string;
18
+ order: string | number;
19
+ };
20
+ export type StartCheckoutRequest = {
21
+ card: any;
22
+ name: any;
23
+ last_name: string;
24
+ email_client: any;
25
+ phone_number: any;
26
+ return_url?: string;
27
+ id_product: string;
28
+ quantity_product: number;
29
+ id_ship: string;
30
+ instance_id_ship: string;
31
+ amount: any;
32
+ title_ship: string;
33
+ description: string;
34
+ device_session_id: any;
35
+ token_id: string;
36
+ order_id: any;
37
+ business_id: any;
38
+ payment_id: any;
39
+ source: string;
40
+ };
41
+ export interface VaultRequest extends SkyflowRecord {
42
+ records: SkyflowRecord[];
43
+ continueOnError?: boolean;
44
+ byot?: "DISABLE" | "ENABLE" | "ENABLE_STRICT";
45
+ }
46
+ export type RegisterCustomerCardRequest = {
47
+ skyflow_id: string;
48
+ };
49
+ export type TokensRequest = {
50
+ vault_id: string;
51
+ vault_url: string;
52
+ data: {
53
+ [key: string]: any;
54
+ };
55
+ };