@tonder.io/ionic-full-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,19 @@
1
+ image: grupoapok/awscli:18
2
+
3
+ stages:
4
+ - deploy
5
+
6
+ deploy:
7
+ stage: deploy
8
+ only:
9
+ - tags
10
+ before_script:
11
+ - |
12
+ {
13
+ echo "@tonder.io:registry=https://registry.npmjs.org/"
14
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
15
+ } | tee -a .npmrc
16
+ script:
17
+ - npm install
18
+ - npm run build
19
+ - npm publish --access=public
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Tonder SDK
2
+
3
+ Tonder SDK helps to integrate the services Tonder offers in your own website
4
+
5
+ ## Installation
6
+
7
+ You can install using NPM
8
+ ```bash
9
+ npm i tonder-sdk-test
10
+ ```
11
+
12
+ or using an script tag
13
+ ```html
14
+ <script src="https://zplit-stage.s3.amazonaws.com/v1/bundle.min.js"></script>
15
+ ```
16
+
17
+ Add dependencies to the root of the app (index.html)
18
+ ```html
19
+ <script src="https://js.skyflow.com/v1/index.js"></script>
20
+ <script src="https://openpay.s3.amazonaws.com/openpay.v1.min.js"></script>
21
+ <script src="https://openpay.s3.amazonaws.com/openpay-data.v1.min.js"></script>
22
+ ```
23
+
24
+ ## Usage
25
+ HTML
26
+ ```html
27
+ <div>
28
+ <h1>Checkout</h1>
29
+ <!-- You have to add an entry point with the ID 'tonder-checkout' -->
30
+ <div id="tonder-checkout">
31
+ </div>
32
+ </div>
33
+ ```
34
+ ## Javascript Example
35
+ ```javascript
36
+ import { InlineCheckout } from "tonder-sdk-test" // Not required if using script tag
37
+ ```
38
+
39
+
40
+ ```javascript
41
+ const customStyles = {
42
+ inputStyles: {
43
+ base: {
44
+ border: "1px solid #e0e0e0",
45
+ padding: "10px 7px",
46
+ borderRadius: "5px",
47
+ color: "#1d1d1d",
48
+ marginTop: "2px",
49
+ backgroundColor: "white",
50
+ fontFamily: '"Inter", sans-serif',
51
+ fontSize: '16px',
52
+ '&::placeholder': {
53
+ color: "#ccc",
54
+ },
55
+ },
56
+ cardIcon: {
57
+ position: 'absolute',
58
+ left: '6px',
59
+ bottom: 'calc(50% - 12px)',
60
+ },
61
+ complete: {
62
+ color: "#4caf50",
63
+ },
64
+ empty: {},
65
+ focus: {},
66
+ invalid: {
67
+ border: "1px solid #f44336",
68
+ },
69
+ global: {
70
+ '@import': 'url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap")',
71
+ }
72
+ },
73
+ labelStyles: {
74
+ base: {
75
+ fontSize: '12px',
76
+ fontWeight: '500',
77
+ fontFamily: '"Inter", sans-serif'
78
+ },
79
+ },
80
+ errorTextStyles: {
81
+ base: {
82
+ fontSize: '12px',
83
+ fontWeight: '500',
84
+ color: "#f44336",
85
+ fontFamily: '"Inter", sans-serif'
86
+ },
87
+ },
88
+ labels: {
89
+ cardLabel: 'Número de Tarjeta Personalizado',
90
+ cvvLabel: 'Código de Seguridad',
91
+ expiryMonthLabel: 'Mes de Expiración',
92
+ expiryYearLabel: 'Año de Expiración'
93
+ },
94
+ placeholders: {
95
+ cardPlaceholder: '0000 0000 0000 0000',
96
+ cvvPlaceholder: '123',
97
+ expiryMonthPlaceholder: 'MM',
98
+ expiryYearPlaceholder: 'AA'
99
+ }
100
+ }
101
+
102
+ const checkoutData = {
103
+ customer: {
104
+ firstName: "Juan",
105
+ lastName: "Hernández",
106
+ country: "Mexico",
107
+ address: "Av. Revolución 356, Col. Roma",
108
+ city: "Monterrey",
109
+ state: "Nuevo León",
110
+ postCode: "64700",
111
+ email: "juan.hernandez@mail.com",
112
+ phone: "8187654321",
113
+ },
114
+ currency: 'mxn',
115
+ cart: {
116
+ total: 399,
117
+ items: [
118
+ {
119
+ description: "Black T-Shirt",
120
+ quantity: 1,
121
+ price_unit: 1,
122
+ discount: 0,
123
+ taxes: 0,
124
+ product_reference: 1,
125
+ name: "T-Shirt",
126
+ amount_total: 399,
127
+ },
128
+ ]
129
+ }
130
+ };
131
+
132
+ const apiKey = "4c87c36e697e65ddfe288be0afbe7967ea0ab865";
133
+ const returnUrl = "http://my-website:8080/checkout"
134
+ const successUrl = "http://my-website:8080/sucess"
135
+ // if using script tag, it should be initialized like this
136
+ // new TonderSdk.InlineCheckout
137
+ const inlineCheckout = new InlineCheckout({
138
+ apiKey,
139
+ returnUrl,
140
+ successUrl,
141
+ styles: customStyles
142
+ });
143
+
144
+ inlineCheckout.injectCheckout();
145
+
146
+ const response = await inlineCheckout.payment(checkoutData);
147
+ ```
148
+
149
+ ## React Example
150
+ ```javascript
151
+ ```
152
+
153
+ ## Configuration
154
+ | Property | Type | Description |
155
+ |:---------------:|:-------------:|:---------------------------------------------------:|
156
+ | apiKey | string | You can take this from you Tonder Dashboard |
157
+ | backgroundColor | string | Hex color #000000 |
158
+ | returnUrl | string | |
159
+ | successUrl | string | |
160
+ | backgroundColor | string | |
161
+
162
+ ## setPayment params
163
+ ### products
164
+ It will receive an array of objects that represent the products.
165
+ ```javascript
166
+ [
167
+ {
168
+ name: 'name of the product',
169
+ price_unit: 'valid float string with the price of the product',
170
+ quantity: 'valid integer strig with the quantity of this product',
171
+ }
172
+ ]
173
+ ```
174
+ ### shippingCost
175
+ It is a valid float string, that will be the shipping cost.
176
+
177
+ ### email
178
+ The email of the customer that is making the purchase.
179
+
180
+ ### apiKey
181
+ Your api key getted from Tonder Dashboard
182
+
183
+ ### customer
184
+ The data of the customer to be registered in the transaction
185
+
186
+ ### items
187
+ An array of items to be registered in the Tonder order.
188
+
189
+ ### Mount element
190
+ You need to have an element where the inline checkout will be mounted, this should be a DIV element with the ID "tonder-checkout"
191
+
192
+ ```html
193
+ <div id="tonder-checkout"></div>
194
+ ```
195
+ ## License
196
+
197
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,9 @@
1
+ const { defineConfig } = require("cypress");
2
+
3
+ module.exports = defineConfig({
4
+ e2e: {
5
+ setupNodeEvents(on, config) {
6
+ // implement node event listeners here
7
+ },
8
+ },
9
+ });
@@ -0,0 +1,20 @@
1
+ type ThreeDSHandlerContructor = {
2
+ payload?: any;
3
+ apiKey?: string;
4
+ baseUrl?: string;
5
+ successUrl?: Location | string;
6
+ };
7
+ export declare class ThreeDSHandler {
8
+ baseUrl?: string;
9
+ apiKey?: string;
10
+ payload?: any;
11
+ successUrl?: Location | string;
12
+ constructor({ payload, apiKey, baseUrl, successUrl }: ThreeDSHandlerContructor);
13
+ saveVerifyTransactionUrl(): void;
14
+ removeVerifyTransactionUrl(): void;
15
+ getVerifyTransactionUrl(): string | null;
16
+ redirectTo3DS(): boolean;
17
+ getURLParameters(): any;
18
+ verifyTransactionStatus(): Promise<unknown>;
19
+ }
20
+ export {};
@@ -0,0 +1,39 @@
1
+ type CheckoutType = {
2
+ apiKey?: string;
3
+ type: string;
4
+ backgroundColor: string;
5
+ color: string;
6
+ cb: (params?: any) => void;
7
+ url: string;
8
+ };
9
+ export declare class Checkout {
10
+ url: string;
11
+ apiKey?: string;
12
+ type: string;
13
+ backgroundColor: string;
14
+ color: string;
15
+ params: string;
16
+ order: any;
17
+ buttonText: string;
18
+ cb: (params: any) => void;
19
+ tonderButton: any;
20
+ constructor({ apiKey, type, backgroundColor, color, cb, url }: CheckoutType);
21
+ generateButton: (buttonText: string) => void;
22
+ getButton: ({ buttonText }: {
23
+ buttonText: string;
24
+ }) => any;
25
+ mountButton: ({ buttonText }: {
26
+ buttonText: string;
27
+ }) => void;
28
+ stylishButton: (element: HTMLElement) => void;
29
+ setOrder: ({ products, email, shippingCost }: {
30
+ products: any;
31
+ email: string;
32
+ shippingCost: string;
33
+ }) => any;
34
+ openTabListener: (tab: any, button: HTMLButtonElement) => void;
35
+ openCheckout: () => void;
36
+ getUrlParams: () => string;
37
+ receiveMessage(event: any): void;
38
+ }
39
+ export {};
@@ -0,0 +1,66 @@
1
+ import { Card, CollectorIds } from '../helpers/template';
2
+ import { LiteCheckout } from '@tonder.io/ionic-lite-sdk';
3
+ import { ThreeDSHandler } from './3dsHandler';
4
+ import { ErrorResponse } from '@tonder.io/ionic-lite-sdk/dist/classes/errorResponse';
5
+ import { Business, PaymentData, OrderItem } from '@tonder.io/ionic-lite-sdk/dist/types/commons';
6
+ import { CustomerRegisterResponse } from '@tonder.io/ionic-lite-sdk/dist/types/responses';
7
+ export type InlineCheckoutConstructor = {
8
+ returnUrl: string;
9
+ apiKey: string;
10
+ successUrl?: string;
11
+ renderPaymentButton: boolean;
12
+ callBack?: (params: any) => void;
13
+ styles?: any;
14
+ form?: any;
15
+ totalElement?: any;
16
+ containerId?: string;
17
+ collectorIds?: CollectorIds;
18
+ platforms?: string[];
19
+ };
20
+ export declare class InlineCheckout {
21
+ #private;
22
+ paymentData: {};
23
+ items: never[];
24
+ baseUrl: string;
25
+ collectContainer: any;
26
+ cartTotal?: string | null | number;
27
+ apiKeyTonder: string;
28
+ returnUrl?: string;
29
+ successUrl?: string;
30
+ renderPaymentButton: boolean;
31
+ callBack: (params: any) => void;
32
+ customStyles: any;
33
+ abortController: AbortController;
34
+ process3ds: ThreeDSHandler;
35
+ cb?: () => void;
36
+ firstName?: string;
37
+ lastName?: string;
38
+ country?: string;
39
+ address?: string;
40
+ city?: string;
41
+ state?: string;
42
+ postCode?: string;
43
+ email?: string;
44
+ phone?: string;
45
+ merchantData?: Business | ErrorResponse;
46
+ cartItems?: any;
47
+ injectInterval: any;
48
+ containerId: string;
49
+ injected: boolean;
50
+ cardsInjected: boolean;
51
+ collectorIds: CollectorIds;
52
+ platforms?: string[];
53
+ liteCheckout: LiteCheckout;
54
+ clientCards: Card[];
55
+ constructor({ apiKey, returnUrl, successUrl, renderPaymentButton, callBack, styles, containerId, collectorIds, platforms }: InlineCheckoutConstructor);
56
+ payment(data: any): Promise<unknown>;
57
+ setCartItems(items: OrderItem[]): void;
58
+ setCustomerEmail(email: string): void;
59
+ setPaymentData(data?: PaymentData): void;
60
+ setCartTotal(total: string | number): void;
61
+ setCallback(cb: any): void;
62
+ injectCheckout(): void;
63
+ loadCardsList(cards: Card[]): void;
64
+ getCustomer(email: string): Promise<ErrorResponse | CustomerRegisterResponse>;
65
+ removeCheckout(): void;
66
+ }
@@ -0,0 +1,18 @@
1
+ declare global {
2
+ interface Window {
3
+ OpenPay: any;
4
+ }
5
+ }
6
+ export declare function getOpenpayDeviceSessionID(merchant_id: string, public_key: string, signal: AbortSignal): Promise<any>;
7
+ export declare function getBusiness(baseUrlTonder: string, signal: AbortSignal, apiKeyTonder?: string): Promise<any>;
8
+ export declare function customerRegister(baseUrlTonder: string, email: string, signal: AbortSignal, apiKeyTonder?: string): Promise<any>;
9
+ export declare function createOrder(baseUrlTonder: string, orderItems: any, apiKeyTonder?: string): Promise<any>;
10
+ export declare function createPayment(baseUrlTonder: string, paymentItems: {
11
+ business_pk: string;
12
+ }, apiKeyTonder?: string): Promise<any>;
13
+ export declare function startCheckoutRouter(baseUrlTonder: string, routerItems: any, apiKeyTonder?: string): Promise<any>;
14
+ export declare function getVaultToken({ baseUrl, apiKey, signal }: {
15
+ baseUrl: string;
16
+ apiKey: string;
17
+ signal: AbortSignal;
18
+ }): Promise<any>;
@@ -0,0 +1,5 @@
1
+ import { CollectorIds } from "./template";
2
+ import CollectorContainer from "skyflow-js/types/core/external/collect/collect-container";
3
+ import ComposableContainer from "skyflow-js/types/core/external/collect/compose-collect-container";
4
+ import RevealContainer from "skyflow-js/types/core/external/reveal/reveal-container";
5
+ export declare function initSkyflow(vaultId: string, vaultUrl: string, baseUrl: string, signal: AbortSignal, customStyles: any, collectorIds: CollectorIds, apiKey: string): Promise<CollectorContainer | ComposableContainer | RevealContainer>;
@@ -0,0 +1 @@
1
+ export declare const defaultStyles: any;
@@ -0,0 +1,18 @@
1
+ export type CollectorIds = {
2
+ holderName: string;
3
+ cardNumber: string;
4
+ expirationMonth: string;
5
+ expirationYear: string;
6
+ cvv: string;
7
+ tonderPayButton: string;
8
+ msgError: string;
9
+ cardsListContainer: string;
10
+ };
11
+ export type Card = {
12
+ cardholder_name: string;
13
+ card_number: string;
14
+ expiration_month: string;
15
+ expiration_year: string;
16
+ };
17
+ export declare const cardTemplate: (external: boolean, collectorIds: CollectorIds) => string;
18
+ export declare const cardItemsTemplate: (external: boolean, cards: Card[]) => string;