ordering-ui-react-native 0.21.17-release → 0.21.18-release

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.21.17-release",
3
+ "version": "0.21.18-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -25,8 +25,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
25
25
  value: language?.code,
26
26
  label: language?.name,
27
27
  inputLabel: language?.code.toUpperCase(),
28
- countryCode: langCountries.find(item => item.value == language?.code)
29
- ?.countryCode,
28
+ countryCode: langCountries.find(item => item.value == language?.code)?.countryCode,
30
29
  };
31
30
  });
32
31
 
@@ -50,6 +49,9 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
50
49
  },
51
50
  });
52
51
 
52
+ console.log('_languages', _languages);
53
+
54
+
53
55
  return (
54
56
  <Container style={{ backgroundColor: theme.colors.inputChat }}>
55
57
  {languagesState?.languages && (
@@ -5,18 +5,6 @@
5
5
  "value": "en",
6
6
  "countryCode": "US"
7
7
  },
8
- {
9
- "inputLabel": "DE",
10
- "label": "German",
11
- "value": "de",
12
- "countryCode": "DE"
13
- },
14
- {
15
- "inputLabel": "ES",
16
- "label": "Spanish",
17
- "value": "es",
18
- "countryCode": "ES"
19
- },
20
8
  {
21
9
  "inputLabel": "MX",
22
10
  "label": "Spanish",
@@ -30,22 +18,70 @@
30
18
  "countryCode": "GT"
31
19
  },
32
20
  {
33
- "inputLabel": "DA",
34
- "label": "Danish",
35
- "value": "da",
36
- "countryCode": "DK"
21
+ "inputLabel": "AF",
22
+ "label": "Afghanistan",
23
+ "value": "af",
24
+ "countryCode": "AF"
37
25
  },
38
26
  {
39
- "inputLabel": "NL",
40
- "label": "Dutch",
41
- "value": "nl",
42
- "countryCode": "NL"
27
+ "inputLabel": "AL",
28
+ "label": "Albania",
29
+ "value": "sq",
30
+ "countryCode": "AL"
43
31
  },
44
32
  {
45
- "inputLabel": "PT",
46
- "label": "Portuguese",
47
- "value": "pt",
48
- "countryCode": "PT"
33
+ "inputLabel": "AD",
34
+ "label": "Andorra",
35
+ "value": "ca",
36
+ "countryCode": "AD"
37
+ },
38
+ {
39
+ "inputLabel": "AM",
40
+ "label": "Armenia",
41
+ "value": "hy",
42
+ "countryCode": "AM"
43
+ },
44
+ {
45
+ "inputLabel": "AZ",
46
+ "label": "Azerbaijan",
47
+ "value": "az",
48
+ "countryCode": "AZ"
49
+ },
50
+ {
51
+ "inputLabel": "BD",
52
+ "label": "Bangladesh",
53
+ "value": "bn",
54
+ "countryCode": "BD"
55
+ },
56
+ {
57
+ "inputLabel": "BY",
58
+ "label": "Belarus",
59
+ "value": "be",
60
+ "countryCode": "BY"
61
+ },
62
+ {
63
+ "inputLabel": "BT",
64
+ "label": "Bhutan",
65
+ "value": "dz",
66
+ "countryCode": "BT"
67
+ },
68
+ {
69
+ "inputLabel": "BA",
70
+ "label": "Bosnia and Herzegovina",
71
+ "value": "bs",
72
+ "countryCode": "BA"
73
+ },
74
+ {
75
+ "inputLabel": "BG",
76
+ "label": "Bulgaria",
77
+ "value": "bg",
78
+ "countryCode": "BG"
79
+ },
80
+ {
81
+ "inputLabel": "BI",
82
+ "label": "Burundi",
83
+ "value": "rn",
84
+ "countryCode": "BI"
49
85
  },
50
86
  {
51
87
  "inputLabel": "CA",
@@ -53,42 +89,174 @@
53
89
  "value": "ca",
54
90
  "countryCode": "ES"
55
91
  },
92
+ {
93
+ "inputLabel": "KH",
94
+ "label": "Cambodia",
95
+ "value": "km",
96
+ "countryCode": "KH"
97
+ },
98
+ {
99
+ "inputLabel": "CN",
100
+ "label": "China",
101
+ "value": "zh",
102
+ "countryCode": "CN"
103
+ },
104
+ {
105
+ "inputLabel": "HR",
106
+ "label": "Croatia",
107
+ "value": "hr",
108
+ "countryCode": "HR"
109
+ },
110
+ {
111
+ "inputLabel": "CZ",
112
+ "label": "Czechia",
113
+ "value": "cs",
114
+ "countryCode": "CZ"
115
+ },
116
+ {
117
+ "inputLabel": "DK",
118
+ "label": "Denmark",
119
+ "value": "da",
120
+ "countryCode": "DK"
121
+ },
122
+ {
123
+ "inputLabel": "DJ",
124
+ "label": "Djibouti",
125
+ "value": "aa",
126
+ "countryCode": "DJ"
127
+ },
128
+ {
129
+ "inputLabel": "EE",
130
+ "label": "Estonia",
131
+ "value": "et",
132
+ "countryCode": "EE"
133
+ },
134
+ {
135
+ "inputLabel": "SZ",
136
+ "label": "Eswatini",
137
+ "value": "ss",
138
+ "countryCode": "SZ"
139
+ },
140
+ {
141
+ "inputLabel": "ET",
142
+ "label": "Ethiopia",
143
+ "value": "am",
144
+ "countryCode": "ET"
145
+ },
146
+ {
147
+ "inputLabel": "FO",
148
+ "label": "Faroe Islands",
149
+ "value": "fo",
150
+ "countryCode": "FO"
151
+ },
152
+ {
153
+ "inputLabel": "FJ",
154
+ "label": "Fiji",
155
+ "value": "fj",
156
+ "countryCode": "FJ"
157
+ },
158
+ {
159
+ "inputLabel": "FI",
160
+ "label": "Finland",
161
+ "value": "fi",
162
+ "countryCode": "FI"
163
+ },
56
164
  {
57
165
  "inputLabel": "FR",
58
- "label": "French",
166
+ "label": "France",
59
167
  "value": "fr",
60
168
  "countryCode": "FR"
61
169
  },
62
170
  {
63
- "inputLabel": "TR",
64
- "label": "Turkish",
65
- "value": "tr",
66
- "countryCode": "TR"
171
+ "inputLabel": "GE",
172
+ "label": "Georgia",
173
+ "value": "ka",
174
+ "countryCode": "GE"
67
175
  },
68
176
  {
69
- "inputLabel": "KM",
70
- "label": "Cambodian",
71
- "value": "km",
72
- "countryCode": "KH"
177
+ "inputLabel": "DE",
178
+ "label": "Germany",
179
+ "value": "de",
180
+ "countryCode": "DE"
73
181
  },
74
182
  {
75
- "inputLabel": "ZH-CN",
76
- "label": "Chinese Simplified",
77
- "value": "zh-CN",
78
- "countryCode": "CN"
183
+ "inputLabel": "GH",
184
+ "label": "Ghana",
185
+ "value": "ak",
186
+ "countryCode": "GH"
187
+ },
188
+ {
189
+ "inputLabel": "GR",
190
+ "label": "Greece",
191
+ "value": "el",
192
+ "countryCode": "GR"
193
+ },
194
+ {
195
+ "inputLabel": "GL",
196
+ "label": "Greenland",
197
+ "value": "kl",
198
+ "countryCode": "GL"
199
+ },
200
+ {
201
+ "inputLabel": "HT",
202
+ "label": "Haiti",
203
+ "value": "ht",
204
+ "countryCode": "HT"
79
205
  },
80
206
  {
81
- "inputLabel": "HI",
82
- "label": "Hindi",
207
+ "inputLabel": "HU",
208
+ "label": "Hungary",
209
+ "value": "hu",
210
+ "countryCode": "HU"
211
+ },
212
+ {
213
+ "inputLabel": "IS",
214
+ "label": "Iceland",
215
+ "value": "is",
216
+ "countryCode": "IS"
217
+ },
218
+ {
219
+ "inputLabel": "IN",
220
+ "label": "India",
83
221
  "value": "hi",
84
222
  "countryCode": "IN"
85
223
  },
86
224
  {
87
225
  "inputLabel": "ID",
88
- "label": "Indonesian",
226
+ "label": "Indonesia",
89
227
  "value": "id",
90
228
  "countryCode": "ID"
91
229
  },
230
+ {
231
+ "inputLabel": "IR",
232
+ "label": "Iran",
233
+ "value": "fa",
234
+ "countryCode": "IR"
235
+ },
236
+ {
237
+ "inputLabel": "IE",
238
+ "label": "Ireland",
239
+ "value": "ga",
240
+ "countryCode": "IE"
241
+ },
242
+ {
243
+ "inputLabel": "IL",
244
+ "label": "Israel",
245
+ "value": "he",
246
+ "countryCode": "IL"
247
+ },
248
+ {
249
+ "inputLabel": "IT",
250
+ "label": "Italy",
251
+ "value": "it",
252
+ "countryCode": "IT"
253
+ },
254
+ {
255
+ "inputLabel": "JP",
256
+ "label": "Japan",
257
+ "value": "ja",
258
+ "countryCode": "JP"
259
+ },
92
260
  {
93
261
  "inputLabel": "KN",
94
262
  "label": "Kannad",
@@ -96,11 +264,222 @@
96
264
  "countryCode": "IN"
97
265
  },
98
266
  {
99
- "inputLabel": "MS",
100
- "label": "Malay",
267
+ "inputLabel": "KZ",
268
+ "label": "Kazakhstan",
269
+ "value": "kk",
270
+ "countryCode": "KZ"
271
+ },
272
+ {
273
+ "inputLabel": "KG",
274
+ "label": "Kyrgyzstan",
275
+ "value": "ky",
276
+ "countryCode": "KG"
277
+ },
278
+ {
279
+ "inputLabel": "LA",
280
+ "label": "Laos",
281
+ "value": "lo",
282
+ "countryCode": "LA"
283
+ },
284
+ {
285
+ "inputLabel": "LV",
286
+ "label": "Latvia",
287
+ "value": "lv",
288
+ "countryCode": "LV"
289
+ },
290
+ {
291
+ "inputLabel": "LT",
292
+ "label": "Lithuania",
293
+ "value": "lt",
294
+ "countryCode": "LT"
295
+ },
296
+ {
297
+ "inputLabel": "LU",
298
+ "label": "Luxembourg",
299
+ "value": "lb",
300
+ "countryCode": "LU"
301
+ },
302
+ {
303
+ "inputLabel": "MK",
304
+ "label": "North Macedonia",
305
+ "value": "mk",
306
+ "countryCode": "MK"
307
+ },
308
+ {
309
+ "inputLabel": "MG",
310
+ "label": "Madagascar",
311
+ "value": "mg",
312
+ "countryCode": "MG"
313
+ },
314
+ {
315
+ "inputLabel": "MW",
316
+ "label": "Malawi",
317
+ "value": "ny",
318
+ "countryCode": "MW"
319
+ },
320
+ {
321
+ "inputLabel": "MY",
322
+ "label": "Malaysia",
101
323
  "value": "ms",
102
324
  "countryCode": "MY"
103
325
  },
326
+ {
327
+ "inputLabel": "MV",
328
+ "label": "Maldives",
329
+ "value": "dv",
330
+ "countryCode": "MV"
331
+ },
332
+ {
333
+ "inputLabel": "ML",
334
+ "label": "Mali",
335
+ "value": "bm",
336
+ "countryCode": "ML"
337
+ },
338
+ {
339
+ "inputLabel": "MT",
340
+ "label": "Malta",
341
+ "value": "mt",
342
+ "countryCode": "MT"
343
+ },
344
+ {
345
+ "inputLabel": "MH",
346
+ "label": "Marshall Islands",
347
+ "value": "mh",
348
+ "countryCode": "MH"
349
+ },
350
+ {
351
+ "inputLabel": "MN",
352
+ "label": "Mongolia",
353
+ "value": "mn",
354
+ "countryCode": "MN"
355
+ },
356
+ {
357
+ "inputLabel": "NR",
358
+ "label": "Nauru",
359
+ "value": "na",
360
+ "countryCode": "NR"
361
+ },
362
+ {
363
+ "inputLabel": "NP",
364
+ "label": "Nepal",
365
+ "value": "ne",
366
+ "countryCode": "NP"
367
+ },
368
+ {
369
+ "inputLabel": "NL",
370
+ "label": "Netherlands",
371
+ "value": "nl",
372
+ "countryCode": "NL"
373
+ },
374
+
375
+ {
376
+ "inputLabel": "NU",
377
+ "label": "Niue",
378
+ "value": "ni",
379
+ "countryCode": "NU"
380
+ },
381
+ {
382
+ "inputLabel": "NO",
383
+ "label": "Norway",
384
+ "value": "no",
385
+ "countryCode": "NO"
386
+ },
387
+ {
388
+ "inputLabel": "PK",
389
+ "label": "Pakistan",
390
+ "value": "ur",
391
+ "countryCode": "PK"
392
+ },
393
+ {
394
+ "inputLabel": "PW",
395
+ "label": "Palau",
396
+ "value": "pau",
397
+ "countryCode": "PW"
398
+ },
399
+ {
400
+ "inputLabel": "PY",
401
+ "label": "Paraguay",
402
+ "value": "gn",
403
+ "countryCode": "PY"
404
+ },
405
+ {
406
+ "inputLabel": "PH",
407
+ "label": "Philippines",
408
+ "value": "tl",
409
+ "countryCode": "PH"
410
+ },
411
+ {
412
+ "inputLabel": "PL",
413
+ "label": "Poland",
414
+ "value": "pl",
415
+ "countryCode": "PL"
416
+ },
417
+ {
418
+ "inputLabel": "PT",
419
+ "label": "Portugal",
420
+ "value": "pt",
421
+ "countryCode": "PT"
422
+ },
423
+ {
424
+ "inputLabel": "RO",
425
+ "label": "Romania",
426
+ "value": "ro",
427
+ "countryCode": "RO"
428
+ },
429
+ {
430
+ "inputLabel": "RU",
431
+ "label": "Russia",
432
+ "value": "ru",
433
+ "countryCode": "RU"
434
+ },
435
+ {
436
+ "inputLabel": "RW",
437
+ "label": "Rwanda",
438
+ "value": "rw",
439
+ "countryCode": "RW"
440
+ },
441
+ {
442
+ "inputLabel": "WS",
443
+ "label": "Samoa",
444
+ "value": "sm",
445
+ "countryCode": "WS"
446
+ },
447
+ {
448
+ "inputLabel": "RS",
449
+ "label": "Serbia",
450
+ "value": "sr",
451
+ "countryCode": "RS"
452
+ },
453
+ {
454
+ "inputLabel": "SA",
455
+ "label": "Saudi Arabia",
456
+ "value": "ar",
457
+ "countryCode": "SA"
458
+ },
459
+ {
460
+ "inputLabel": "SC",
461
+ "label": "Seychelles",
462
+ "value": "crs",
463
+ "countryCode": "SC"
464
+ },
465
+ {
466
+ "inputLabel": "SK",
467
+ "label": "Slovakia",
468
+ "value": "sk",
469
+ "countryCode": "SK"
470
+ },
471
+ {
472
+ "inputLabel": "SI",
473
+ "label": "Slovenia",
474
+ "value": "sl",
475
+ "countryCode": "SI"
476
+ },
477
+ {
478
+ "inputLabel": "SO",
479
+ "label": "Somalia",
480
+ "value": "so",
481
+ "countryCode": "SO"
482
+ },
104
483
  {
105
484
  "inputLabel": "TA",
106
485
  "label": "Tamil",
@@ -108,45 +487,111 @@
108
487
  "countryCode": "IN"
109
488
  },
110
489
  {
111
- "inputLabel": "AR",
112
- "label": "Arabic",
113
- "value": "ar",
114
- "countryCode": "EG"
490
+ "inputLabel": "ZA",
491
+ "label": "South Africa",
492
+ "value": "zu",
493
+ "countryCode": "ZA"
115
494
  },
116
495
  {
117
- "inputLabel": "RU",
118
- "label": "Russian",
119
- "value": "ru",
120
- "countryCode": "RU"
496
+ "inputLabel": "KR",
497
+ "label": "South Korea",
498
+ "value": "ko",
499
+ "countryCode": "KR"
121
500
  },
122
501
  {
123
- "inputLabel": "JA",
124
- "label": "Japanese",
125
- "value": "ja",
126
- "countryCode": "JP"
502
+ "inputLabel": "ES",
503
+ "label": "Spain",
504
+ "value": "es",
505
+ "countryCode": "ES"
127
506
  },
128
507
  {
129
- "inputLabel": "BN",
130
- "label": "Bengali",
131
- "value": "bn",
132
- "countryCode": "BD"
508
+ "inputLabel": "LK",
509
+ "label": "Sri Lanka",
510
+ "value": "si",
511
+ "countryCode": "LK"
133
512
  },
134
513
  {
135
- "inputLabel": "IT",
136
- "label": "Italian",
137
- "value": "it",
138
- "countryCode": "IT"
514
+ "inputLabel": "SE",
515
+ "label": "Sweden",
516
+ "value": "sv",
517
+ "countryCode": "SE"
139
518
  },
140
519
  {
141
- "inputLabel": "EL",
142
- "label": "Greek",
143
- "value": "el",
144
- "countryCode": "GR"
520
+ "inputLabel": "TJ",
521
+ "label": "Tajikistan",
522
+ "value": "tg",
523
+ "countryCode": "TJ"
145
524
  },
146
525
  {
147
- "inputLabel": "BG",
148
- "label": "Bulgarian Translation",
149
- "value": "bg",
150
- "countryCode": "BG"
526
+ "inputLabel": "TZ",
527
+ "label": "Tanzania",
528
+ "value": "sw",
529
+ "countryCode": "TZ"
530
+ },
531
+ {
532
+ "inputLabel": "TH",
533
+ "label": "Thailand",
534
+ "value": "th",
535
+ "countryCode": "TH"
536
+ },
537
+ {
538
+ "inputLabel": "TK",
539
+ "label": "Tokelau",
540
+ "value": "tkl",
541
+ "countryCode": "TK"
542
+ },
543
+ {
544
+ "inputLabel": "TO",
545
+ "label": "Tonga",
546
+ "value": "to",
547
+ "countryCode": "TO"
548
+ },
549
+ {
550
+ "inputLabel": "TR",
551
+ "label": "Turkey",
552
+ "value": "tr",
553
+ "countryCode": "TR"
554
+ },
555
+ {
556
+ "inputLabel": "TM",
557
+ "label": "Turkmenistan",
558
+ "value": "tk",
559
+ "countryCode": "TM"
560
+ },
561
+ {
562
+ "inputLabel": "UA",
563
+ "label": "Ukraine",
564
+ "value": "uk",
565
+ "countryCode": "UA"
566
+ },
567
+ {
568
+ "inputLabel": "UZ",
569
+ "label": "Uzbekistan",
570
+ "value": "uz",
571
+ "countryCode": "UZ"
572
+ },
573
+ {
574
+ "inputLabel": "VU",
575
+ "label": "Vanuatu",
576
+ "value": "bi",
577
+ "countryCode": "VU"
578
+ },
579
+ {
580
+ "inputLabel": "VN",
581
+ "label": "Vietnam",
582
+ "value": "vi",
583
+ "countryCode": "VN"
584
+ },
585
+ {
586
+ "inputLabel": "ZW",
587
+ "label": "Zimbabwe",
588
+ "value": "sn",
589
+ "countryCode": "ZW"
590
+ },
591
+ {
592
+ "inputLabel": "ZH-CN",
593
+ "label": "Chinese Simplified",
594
+ "value": "zh-CN",
595
+ "countryCode": "CN"
151
596
  }
152
597
  ]
@@ -9,7 +9,7 @@ import {
9
9
  } from '@stripe/stripe-react-native';
10
10
  import { useTheme } from 'styled-components/native';
11
11
  import { ErrorMessage } from './styles';
12
-
12
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
13
13
  import { StripeElementsForm as StripeFormController } from './naked';
14
14
  import { OButton, OText } from '../shared';
15
15
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -17,7 +17,7 @@ import { StripeMethodForm } from '../../../../../src/components/StripeMethodForm
17
17
 
18
18
  const StripeElementsFormUI = (props: any) => {
19
19
  const {
20
- publicKey,
20
+ publicKeyState,
21
21
  handleSource,
22
22
  values,
23
23
  businessId,
@@ -55,7 +55,7 @@ const StripeElementsFormUI = (props: any) => {
55
55
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
56
56
  const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
57
57
  const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
58
- const isToSave = methodsPay?.includes(paymethod) ? publicKey : publicKeyAddCard
58
+ const isToSave = methodsPay?.includes(paymethod) ? publicKeyState?.key : (publicKeyAddCard || publicKeyState?.key)
59
59
  const styles = StyleSheet.create({
60
60
  container: {
61
61
  width: '100%',
@@ -201,70 +201,78 @@ const StripeElementsFormUI = (props: any) => {
201
201
 
202
202
  return (
203
203
  <View style={{ ...styles.container, height: methodsPay?.includes(paymethod) ? 'auto' : height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
204
- {publicKey ? (
205
- <View style={{ flex: 1 }}>
206
- <StripeProvider
207
- publishableKey={isToSave}
208
- merchantIdentifier={merchantId}
209
- urlScheme={`${urlScheme}://checkout/${cart?.uuid}`}
210
- >
211
- {methodsPay?.includes(paymethod) ? (
212
- <StripeMethodForm
213
- handleSource={handleSource}
214
- onCancel={onCancel}
215
- cart={cart}
216
- cartTotal={cartTotal}
217
- setErrors={setErrors}
218
- paymethod={paymethod}
219
- devMode={publicKey?.includes('test')}
220
- setMethodPaySupported={setMethodPaySupported}
221
- placeByMethodPay={placeByMethodPay}
222
- methodPaySupported={methodPaySupported}
223
- setPlaceByMethodPay={setPlaceByMethodPay}
224
- androidAppId={androidAppId}
225
- />
226
- ) : (
227
- <CardField
228
- postalCodeEnabled={zipCodeEnabled}
229
- cardStyle={{
230
- backgroundColor: '#FFFFFF',
231
- textColor: '#000000',
232
- borderWidth: 1,
233
- borderRadius: 8,
234
- borderColor: theme.colors.border
235
- }}
236
- style={{
237
- width: '100%',
238
- height: 50,
239
- marginVertical: 30,
240
- zIndex: 9999,
241
- }}
242
- onCardChange={(cardDetails: any) => setCard(cardDetails)}
243
- />
244
- )}
245
- </StripeProvider>
246
- {!!errors && (
204
+ {publicKeyState.loading ? (
205
+ <Placeholder Animation={Fade}>
206
+ <PlaceholderLine height={50} style={{ marginTop: 20 }} />
207
+ </Placeholder>
208
+ ) : (
209
+ <>
210
+ {publicKeyState?.key ? (
211
+ <View style={{ flex: 1 }}>
212
+ <StripeProvider
213
+ publishableKey={isToSave}
214
+ merchantIdentifier={merchantId}
215
+ urlScheme={`${urlScheme}://checkout/${cart?.uuid}`}
216
+ >
217
+ {methodsPay?.includes(paymethod) ? (
218
+ <StripeMethodForm
219
+ handleSource={handleSource}
220
+ onCancel={onCancel}
221
+ cart={cart}
222
+ cartTotal={cartTotal}
223
+ setErrors={setErrors}
224
+ paymethod={paymethod}
225
+ devMode={publicKeyState?.key?.includes('test')}
226
+ setMethodPaySupported={setMethodPaySupported}
227
+ placeByMethodPay={placeByMethodPay}
228
+ methodPaySupported={methodPaySupported}
229
+ setPlaceByMethodPay={setPlaceByMethodPay}
230
+ androidAppId={androidAppId}
231
+ />
232
+ ) : (
233
+ <CardField
234
+ postalCodeEnabled={zipCodeEnabled}
235
+ cardStyle={{
236
+ backgroundColor: '#FFFFFF',
237
+ textColor: '#000000',
238
+ borderWidth: 1,
239
+ borderRadius: 8,
240
+ borderColor: theme.colors.border
241
+ }}
242
+ style={{
243
+ width: '100%',
244
+ height: 50,
245
+ marginVertical: 30,
246
+ zIndex: 9999,
247
+ }}
248
+ onCardChange={(cardDetails: any) => setCard(cardDetails)}
249
+ />
250
+ )}
251
+ </StripeProvider>
252
+ {!!errors && (
253
+ <ErrorMessage>
254
+ <OText
255
+ size={20}
256
+ color={theme.colors.error}
257
+ style={{ marginTop: 20, textAlign: 'center' }}
258
+ >
259
+ {errors}
260
+ </OText>
261
+ </ErrorMessage>
262
+ )}
263
+ </View>
264
+ ) : (
247
265
  <ErrorMessage>
248
266
  <OText
249
267
  size={20}
250
268
  color={theme.colors.error}
251
- style={{ marginTop: 20, textAlign: 'center' }}
269
+ style={{ marginTop: 20 }}
252
270
  >
253
- {errors}
271
+ {t('SOMETHING_WRONG', 'Something is wrong!')}
254
272
  </OText>
255
273
  </ErrorMessage>
256
274
  )}
257
- </View>
258
- ) : (
259
- <ErrorMessage>
260
- <OText
261
- size={20}
262
- color={theme.colors.error}
263
- style={{ marginTop: 20 }}
264
- >
265
- {t('SOMETHING_WRONG', 'Something is wrong!')}
266
- </OText>
267
- </ErrorMessage>
275
+ </>
268
276
  )}
269
277
  {!methodsPay?.includes(paymethod) && (
270
278
  <OButton
@@ -13,6 +13,7 @@ export const StripeElementsForm = (props: any) => {
13
13
  const [ordering] = useApi();
14
14
  const [{ token }] = useSession();
15
15
  const [state, setState] = useState({ loading: false, loadingAdd: false, error: null, requirements: null });
16
+ const [publicKeyState, setPublicKeyState] = useState({ key: props.publicKey, loading: true, error: null })
16
17
 
17
18
  const getRequirements = async () => {
18
19
  try {
@@ -85,6 +86,51 @@ export const StripeElementsForm = (props: any) => {
85
86
  }
86
87
  }
87
88
 
89
+ /**
90
+ * Method to get stripe credentials from API
91
+ */
92
+ const getCredentials = async () => {
93
+ try {
94
+ setPublicKeyState({
95
+ ...publicKeyState,
96
+ loading: true
97
+ })
98
+ const { content: { result, error } } = await ordering.setAccessToken(token).paymentCards().getCredentials()
99
+ if (!error) {
100
+ setPublicKeyState({
101
+ loading: false,
102
+ key: result.publishable,
103
+ error: null
104
+ })
105
+ } else {
106
+ setPublicKeyState({
107
+ ...publicKeyState,
108
+ loading: false,
109
+ error: result
110
+ })
111
+ }
112
+ } catch (error) {
113
+ setPublicKeyState({
114
+ ...publicKeyState,
115
+ loading: false,
116
+ error: error.message
117
+ })
118
+ }
119
+ }
120
+
121
+ useEffect(() => {
122
+ if (!token) return
123
+ if (props.publicKey) {
124
+ setPublicKeyState({
125
+ loading: false,
126
+ key: props.publicKey,
127
+ error: null
128
+ })
129
+ } else {
130
+ getCredentials()
131
+ }
132
+ }, [token, props.publicKey])
133
+
88
134
  useEffect(() => {
89
135
  if (!token || state.requirements) return
90
136
  toSave && getRequirements()
@@ -96,6 +142,7 @@ export const StripeElementsForm = (props: any) => {
96
142
  values={state}
97
143
  requirements={state.requirements}
98
144
  stripeTokenHandler={stripeTokenHandler}
145
+ publicKeyState={publicKeyState}
99
146
  />
100
147
  )
101
148
  }