@akinon/pz-saved-card 1.101.0-rc.74 → 1.101.0-rc.75
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ export interface CardFormSectionProps {
|
|
|
14
14
|
expiryDate?: string;
|
|
15
15
|
cvv?: string;
|
|
16
16
|
cvvTooltip?: string;
|
|
17
|
+
saveCardForFuture?: string;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -23,24 +24,14 @@ export const CardFormSection = ({
|
|
|
23
24
|
errors,
|
|
24
25
|
months,
|
|
25
26
|
years,
|
|
26
|
-
translations = {}
|
|
27
|
+
translations = {},
|
|
27
28
|
}: CardFormSectionProps) => {
|
|
28
|
-
const defaultTranslations = {
|
|
29
|
-
cardHolder: 'Cardholder Name',
|
|
30
|
-
cardNumber: 'Card Number',
|
|
31
|
-
expiryDate: 'Expiration Date',
|
|
32
|
-
cvv: 'CVV',
|
|
33
|
-
cvvTooltip: 'CVV'
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const mergedTranslations = { ...defaultTranslations, ...translations };
|
|
37
|
-
|
|
38
29
|
return (
|
|
39
30
|
<div className="w-full bg-white">
|
|
40
31
|
<div className="px-4 my-2 w-full flex justify-between flex-wrap">
|
|
41
32
|
<div className="my-2 w-full sm:px-4">
|
|
42
33
|
<Input
|
|
43
|
-
label={
|
|
34
|
+
label={translations.cardHolder}
|
|
44
35
|
{...register('card_holder')}
|
|
45
36
|
error={errors.card_holder}
|
|
46
37
|
/>
|
|
@@ -48,7 +39,7 @@ export const CardFormSection = ({
|
|
|
48
39
|
|
|
49
40
|
<div className="my-2 w-full flex flex-col sm:px-4">
|
|
50
41
|
<div className="text-xs text-gray-800 mb-2 w-full flex justify-between items-center">
|
|
51
|
-
<span>{
|
|
42
|
+
<span>{translations.cardNumber}</span>
|
|
52
43
|
</div>
|
|
53
44
|
|
|
54
45
|
<Input
|
|
@@ -67,7 +58,7 @@ export const CardFormSection = ({
|
|
|
67
58
|
className="flex w-full text-xs text-start text-black-400 mb-1.5"
|
|
68
59
|
htmlFor="card_month"
|
|
69
60
|
>
|
|
70
|
-
{
|
|
61
|
+
{translations.expiryDate}
|
|
71
62
|
</label>
|
|
72
63
|
|
|
73
64
|
<div className="flex w-full h-10 space-x-2.5">
|
|
@@ -96,7 +87,7 @@ export const CardFormSection = ({
|
|
|
96
87
|
className="flex w-full text-xs text-start text-black-400 mb-1.5"
|
|
97
88
|
htmlFor="card_cvv"
|
|
98
89
|
>
|
|
99
|
-
{
|
|
90
|
+
{translations.cvv}
|
|
100
91
|
</label>
|
|
101
92
|
<Input
|
|
102
93
|
format="###"
|
|
@@ -108,7 +99,7 @@ export const CardFormSection = ({
|
|
|
108
99
|
/>
|
|
109
100
|
<div className="group relative flex items-center justify-start text-gray-600 cursor-pointer mt-2 transition-all hover:text-secondary">
|
|
110
101
|
<span className="text-xs underline">
|
|
111
|
-
{
|
|
102
|
+
{translations.cvv}
|
|
112
103
|
</span>
|
|
113
104
|
<Icon name="cvc" size={16} className="leading-none ml-2" />
|
|
114
105
|
<div className="hidden group-hover:block absolute right-0 bottom-5 w-[11rem] lg:w-[21rem] lg:left-auto lg:right-auto border-2">
|
|
@@ -118,7 +109,18 @@ export const CardFormSection = ({
|
|
|
118
109
|
</div>
|
|
119
110
|
</div>
|
|
120
111
|
|
|
121
|
-
<div
|
|
112
|
+
<div className="my-2 w-full flex flex-col sm:px-4">
|
|
113
|
+
<label className="flex items-center space-x-2">
|
|
114
|
+
<input
|
|
115
|
+
type="checkbox"
|
|
116
|
+
{...register('register_consumer_card')}
|
|
117
|
+
className="h-4 w-4 text-primary focus:ring-primary border-gray-300 rounded"
|
|
118
|
+
/>
|
|
119
|
+
<span className="text-sm text-gray-700">
|
|
120
|
+
{translations.saveCardForFuture}
|
|
121
|
+
</span>
|
|
122
|
+
</label>
|
|
123
|
+
</div>
|
|
122
124
|
</div>
|
|
123
125
|
</div>
|
|
124
126
|
);
|
package/src/types/index.ts
CHANGED
|
@@ -69,7 +69,8 @@ const defaultTranslations: IyzicoSavedCardOptionTexts = {
|
|
|
69
69
|
cardHolder: 'Cardholder Name',
|
|
70
70
|
cardNumber: 'Card Number',
|
|
71
71
|
expiryDate: 'Expiration Date',
|
|
72
|
-
cvv: 'CVV'
|
|
72
|
+
cvv: 'CVV',
|
|
73
|
+
saveCardForFuture: 'Save this card for future payments',
|
|
73
74
|
},
|
|
74
75
|
placeholder: {
|
|
75
76
|
cardHolder: 'Name on Card',
|
|
@@ -113,7 +114,8 @@ const createFormSchema = (
|
|
|
113
114
|
const baseSchema = {
|
|
114
115
|
agreement: yup
|
|
115
116
|
.boolean()
|
|
116
|
-
.oneOf([true], errors?.required ?? defaultTranslations.errors.required)
|
|
117
|
+
.oneOf([true], errors?.required ?? defaultTranslations.errors.required),
|
|
118
|
+
register_consumer_card: yup.boolean().default(false)
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
if (type === 'new-card') {
|
|
@@ -179,6 +181,7 @@ const IyzicoSavedCardOption = ({
|
|
|
179
181
|
const [months, setMonths] = useState([]);
|
|
180
182
|
const [years, setYears] = useState([]);
|
|
181
183
|
const [formError, setFormError] = useState(null);
|
|
184
|
+
const [showCardForm, setShowCardForm] = useState(true);
|
|
182
185
|
|
|
183
186
|
const getFormSchema = () => {
|
|
184
187
|
if (customFormSchema?.[type]) {
|
|
@@ -208,23 +211,15 @@ const IyzicoSavedCardOption = ({
|
|
|
208
211
|
if (type === 'existing-card') {
|
|
209
212
|
const res = await completeSavedCard({
|
|
210
213
|
agreement: data.agreement,
|
|
211
|
-
register_consumer_card:
|
|
212
|
-
window.universalCardStorage.registerConsumerCard,
|
|
213
214
|
consumer_token: window.universalCardStorage.consumerToken,
|
|
214
|
-
card_token: window.universalCardStorage.cardToken
|
|
215
|
+
card_token: window.universalCardStorage.cardToken,
|
|
216
|
+
register_consumer_card: true
|
|
215
217
|
});
|
|
216
218
|
|
|
217
219
|
if ('data' in res && res.data?.errors) {
|
|
218
220
|
setFormError(res.data.errors);
|
|
219
221
|
}
|
|
220
222
|
} else {
|
|
221
|
-
if (!window.universalCardStorage?.registerConsumerCard) {
|
|
222
|
-
setFormError({
|
|
223
|
-
register_consumer_card: mergedTexts.errors?.saveCardRequired
|
|
224
|
-
});
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
223
|
const res = await completeSavedCard({
|
|
229
224
|
agreement: data.agreement,
|
|
230
225
|
card_holder: data.card_holder,
|
|
@@ -232,8 +227,7 @@ const IyzicoSavedCardOption = ({
|
|
|
232
227
|
card_month: data.card_month,
|
|
233
228
|
card_year: data.card_year,
|
|
234
229
|
card_cvv: data.card_cvv,
|
|
235
|
-
register_consumer_card:
|
|
236
|
-
window.universalCardStorage.registerConsumerCard
|
|
230
|
+
register_consumer_card: data.register_consumer_card || false
|
|
237
231
|
});
|
|
238
232
|
|
|
239
233
|
if ('data' in res && res.data?.errors) {
|
|
@@ -301,7 +295,6 @@ const IyzicoSavedCardOption = ({
|
|
|
301
295
|
useEffect(() => {
|
|
302
296
|
if (window.iyziUcsInit?.scriptType === 'CONSUMER_WITH_CARD_EXIST') {
|
|
303
297
|
if (
|
|
304
|
-
!window.universalCardStorage?.consumerToken ||
|
|
305
298
|
window.universalCardStorage?.cardToken
|
|
306
299
|
) {
|
|
307
300
|
setType('existing-card');
|
|
@@ -328,6 +321,18 @@ const IyzicoSavedCardOption = ({
|
|
|
328
321
|
return () => clearInterval(checkInterval);
|
|
329
322
|
}, [type]);
|
|
330
323
|
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
const checkboxInterval = setInterval(() => {
|
|
326
|
+
if (window.universalCardStorage?.cardToken !== undefined) {
|
|
327
|
+
setShowCardForm(false);
|
|
328
|
+
} else {
|
|
329
|
+
setShowCardForm(true);
|
|
330
|
+
}
|
|
331
|
+
}, 100);
|
|
332
|
+
|
|
333
|
+
return () => clearInterval(checkboxInterval);
|
|
334
|
+
}, [type, setFormValue]);
|
|
335
|
+
|
|
331
336
|
return (
|
|
332
337
|
<>
|
|
333
338
|
<form
|
|
@@ -364,7 +369,7 @@ const IyzicoSavedCardOption = ({
|
|
|
364
369
|
</>
|
|
365
370
|
)}
|
|
366
371
|
|
|
367
|
-
{
|
|
372
|
+
{showCardForm && (
|
|
368
373
|
<>
|
|
369
374
|
{customRender?.cardFormSection ? (
|
|
370
375
|
customRender.cardFormSection({
|