fairsure-checkout-sdk 1.0.0 → 1.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.
|
@@ -193,6 +193,14 @@ export function usePaymentCheckout(amount, requestId, customerEmail, customerNam
|
|
|
193
193
|
maximumFractionDigits: 2,
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
|
+
const convertExpiryForAPI = (expiry) => {
|
|
197
|
+
const clean = expiry.replace("/", ""); // 1326
|
|
198
|
+
if (clean.length !== 4)
|
|
199
|
+
return clean;
|
|
200
|
+
const mm = clean.slice(0, 2);
|
|
201
|
+
const yy = clean.slice(2, 4);
|
|
202
|
+
return `${yy}${mm}`; // 2613
|
|
203
|
+
};
|
|
196
204
|
const formatCardNumber = (value) => {
|
|
197
205
|
const v = value.replace(/\s+/g, "").replace(/[^0-9]/gi, "");
|
|
198
206
|
const matches = v.match(/\d{4,16}/g);
|
|
@@ -259,11 +267,12 @@ export function usePaymentCheckout(amount, requestId, customerEmail, customerNam
|
|
|
259
267
|
};
|
|
260
268
|
const handleCardPayment = async () => {
|
|
261
269
|
var _a, _b;
|
|
270
|
+
const formattedExpiry = convertExpiryForAPI(expiryDate.replace("/", ""));
|
|
262
271
|
setLoading(true);
|
|
263
272
|
try {
|
|
264
273
|
const payload = {
|
|
265
274
|
pan: cardNumber.replace(/\s/g, ""),
|
|
266
|
-
expiryDate:
|
|
275
|
+
expiryDate: formattedExpiry,
|
|
267
276
|
cvv,
|
|
268
277
|
pin,
|
|
269
278
|
};
|
package/package.json
CHANGED
|
@@ -225,6 +225,17 @@ export function usePaymentCheckout(
|
|
|
225
225
|
});
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
+
const convertExpiryForAPI = (expiry: string) => {
|
|
229
|
+
const clean = expiry.replace("/", ""); // 1326
|
|
230
|
+
|
|
231
|
+
if (clean.length !== 4) return clean;
|
|
232
|
+
|
|
233
|
+
const mm = clean.slice(0, 2);
|
|
234
|
+
const yy = clean.slice(2, 4);
|
|
235
|
+
|
|
236
|
+
return `${yy}${mm}`; // 2613
|
|
237
|
+
};
|
|
238
|
+
|
|
228
239
|
const formatCardNumber = (value: string) => {
|
|
229
240
|
const v = value.replace(/\s+/g, "").replace(/[^0-9]/gi, "");
|
|
230
241
|
const matches = v.match(/\d{4,16}/g);
|
|
@@ -243,6 +254,7 @@ export function usePaymentCheckout(
|
|
|
243
254
|
}
|
|
244
255
|
return v;
|
|
245
256
|
};
|
|
257
|
+
|
|
246
258
|
const completeCard = async (data: string) => {
|
|
247
259
|
setLoading(true);
|
|
248
260
|
try {
|
|
@@ -291,12 +303,14 @@ export function usePaymentCheckout(
|
|
|
291
303
|
}
|
|
292
304
|
}
|
|
293
305
|
};
|
|
306
|
+
|
|
294
307
|
const handleCardPayment = async () => {
|
|
308
|
+
const formattedExpiry = convertExpiryForAPI(expiryDate.replace("/", ""));
|
|
295
309
|
setLoading(true);
|
|
296
310
|
try {
|
|
297
311
|
const payload = {
|
|
298
312
|
pan: cardNumber.replace(/\s/g, ""),
|
|
299
|
-
expiryDate:
|
|
313
|
+
expiryDate: formattedExpiry,
|
|
300
314
|
cvv,
|
|
301
315
|
pin,
|
|
302
316
|
};
|