@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.
@@ -0,0 +1,194 @@
1
+ import { getCardType } from './utils';
2
+
3
+ export type CollectorIds = {
4
+ holderName: string,
5
+ cardNumber: string,
6
+ expirationMonth: string,
7
+ expirationYear: string,
8
+ cvv: string,
9
+ tonderPayButton: string,
10
+ msgError: string,
11
+ cardsListContainer: string
12
+ }
13
+
14
+ export type Card = {
15
+ cardholder_name: string,
16
+ card_number: string,
17
+ expiration_month: string,
18
+ expiration_year: string
19
+ }
20
+
21
+ export const cardTemplate = (external: boolean, collectorIds: CollectorIds) => `
22
+ <div class="container-tonder">
23
+ <div id="${collectorIds.cardsListContainer}" class="cards-list-container"></div>
24
+ <div id="${collectorIds.holderName}" class="empty-div"></div>
25
+ <div id="${collectorIds.cardNumber}" class="empty-div"></div>
26
+ <div class="collect-row">
27
+ <div id="${collectorIds.expirationMonth}" class="empty-div"></div>
28
+ <div id="${collectorIds.expirationYear}" class="expiration-year"></div>
29
+ <div id="${collectorIds.cvv}" class="empty-div"></div>
30
+ </div>
31
+ <div class="checkbox"><input id="save-checkout-card" type="checkbox"><label for="save-checkout-card">Guardar tarjeta para futuros pagos</label></div>
32
+ <div id="${collectorIds.msgError}"></div>
33
+ <button id="${collectorIds.tonderPayButton}" class="pay-button">Pagar</button>
34
+ </div>
35
+
36
+ ${external ? `` : `<style>
37
+ .container-tonder {
38
+ background-color: #F9F9F9;
39
+ margin: 0 auto !important;
40
+ padding: 30px 10px 30px 10px;
41
+ overflow: hidden;
42
+ transition: max-height 0.5s ease-out;
43
+ max-width: 600px;
44
+ border: solid 1px #e3e3e3;
45
+ max-height: 100vh;
46
+ }
47
+
48
+ .collect-row {
49
+ display: flex !important;
50
+ justify-content: space-between !important;
51
+ width: 100% !important;
52
+ }
53
+
54
+ .collect-row > :first-child {
55
+ min-width: 120px; !important
56
+ }
57
+
58
+ .expiration-year {
59
+ padding-top: 25px !important;
60
+ }
61
+
62
+ .empty-div {
63
+ height: 80px !important;
64
+ margin-top: 2px;
65
+ margin-bottom: 4px;
66
+ margin-left: 10px !important;
67
+ margin-right: 10px !important;
68
+ }
69
+
70
+ .error-container{
71
+ color: red !important;
72
+ background-color: #FFDBDB !important;
73
+ margin-bottom: 13px !important;
74
+ font-size: 80% !important;
75
+ padding: 8px 10px !important;
76
+ border-radius: 10px !important;
77
+ text-align: left !important;
78
+ }
79
+
80
+ .pay-button {
81
+ font-size: 16px;
82
+ font-weight: bold;
83
+ min-height: 2.3rem;
84
+ border-radius: 0.5rem;
85
+ cursor: pointer;
86
+ width: 100%;
87
+ padding: 1rem;
88
+ text-align: center;
89
+ border: none;
90
+ background-color: #000;
91
+ color: #fff;
92
+ margin-bottom: 10px;
93
+ display: none;
94
+ }
95
+
96
+ .lds-dual-ring {
97
+ display: inline-block;
98
+ width: 14px;
99
+ height: 14px;
100
+ }
101
+
102
+ .lds-dual-ring:after {
103
+ content: " ";
104
+ display: block;
105
+ width: 14px;
106
+ height: 14px;
107
+ border-radius: 50%;
108
+ border: 6px solid #fff;
109
+ border-color: #fff transparent #fff transparent;
110
+ animation: lds-dual-ring 1.2s linear infinite;
111
+ }
112
+ @keyframes lds-dual-ring {
113
+ 0% {
114
+ transform: rotate(0deg);
115
+ }
116
+ 100% {
117
+ transform: rotate(360deg);
118
+ }
119
+ }
120
+
121
+ @media screen and (max-width: 600px) {
122
+ .payment_method_zplit {
123
+ font-size: 16px !important;
124
+ width: 100% !important;
125
+ }
126
+
127
+ .payment_method_zplit label img {
128
+ display: none !important;
129
+ }
130
+ }
131
+
132
+ .cards-list-container {
133
+ display: flex;
134
+ flex-direction: column
135
+ }
136
+
137
+ .checkbox label {
138
+ margin-left: 10px;
139
+ font-size: '12px';
140
+ font-weight: '500';
141
+ color: #1D1D1D;
142
+ font-family: "Inter", sans-serif;
143
+ }
144
+
145
+ @font-face {
146
+ font-family: Inter;
147
+ src: url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap");
148
+ }
149
+
150
+ .checkbox {
151
+ margin-top: 10px;
152
+ margin-bottom: 10px;
153
+ width: 100%;
154
+ text-align: left;
155
+ }
156
+
157
+ </style>
158
+ `}`
159
+
160
+ export const cardItemsTemplate = (external: boolean, cards: Card[]) => {
161
+
162
+ const cardItemsHTML = cards.reduce((total: string, card: Card) => {
163
+ return `${total}
164
+ <div class="card-item">
165
+ <img class="card-image" src="${getCardType(card.card_number)}" />
166
+ <div class="card-number">${card.card_number}</div>
167
+ <div class="card-expiration">${card.expiration_month}/${card.expiration_year}</div>
168
+ </div>`
169
+ }, ``);
170
+
171
+ const cardItemStyle = external ? '' : `
172
+ <style>
173
+
174
+ .card-item {
175
+ display: flex;
176
+ justify-content: space-between;
177
+ align-items: center;
178
+ color: #1D1D1D;
179
+ gap: 30px 20px;
180
+ }
181
+
182
+ .card-image {
183
+ width: 20px;
184
+ height: 20px;
185
+ }
186
+
187
+ </style>
188
+ `
189
+ const cardItem = `
190
+ ${cardItemsHTML}
191
+ ${cardItemStyle}
192
+ `
193
+ return cardItem;
194
+ }