@nuskin/ns-shop 5.11.21 → 5.11.24
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 +1 -1
- package/src/payment/Payment.js +25 -1
- package/src/payment/PaymentAdapter.js +1 -1
- package/src/payment/paymentDto.js +4 -0
- package/src/receiver.js +46 -52
package/package.json
CHANGED
package/src/payment/Payment.js
CHANGED
|
@@ -44,6 +44,10 @@ newShop.Payment = function(paymentData){
|
|
|
44
44
|
this.installmentSelectedNumber = paymentData.installmentSelectedNumber;
|
|
45
45
|
this.availableInstallmentPeriods = paymentData.availableInstallmentPeriods;
|
|
46
46
|
this.mandateType = paymentData.mandateType;
|
|
47
|
+
this.storedCredentialsAgreementDate = paymentData.storedCredentialsAgreementDate;
|
|
48
|
+
this.storedCredentialsNetworkTransactionId = paymentData.storedCredentialsNetworkTransactionId;
|
|
49
|
+
this.storedCredentialsNetworkDateStr = paymentData.storedCredentialsNetworkDateStr;
|
|
50
|
+
|
|
47
51
|
|
|
48
52
|
// Columbia Fields
|
|
49
53
|
this.extTerm = paymentData.extTerm;
|
|
@@ -141,6 +145,10 @@ newShop.Payment = function(paymentData){
|
|
|
141
145
|
payment.availableInstallmentPeriods = this.availableInstallmentPeriods;
|
|
142
146
|
payment.countryCode = this.countryCode;
|
|
143
147
|
payment.mandateType = this.mandateType;
|
|
148
|
+
payment.storedCredentialsAgreementDate = this.storedCredentialsAgreementDate;
|
|
149
|
+
payment.storedCredentialsNetworkTransactionId = this.storedCredentialsNetworkTransactionId;
|
|
150
|
+
payment.storedCredentialsNetworkDateStr = this.storedCredentialsNetworkDateStr;
|
|
151
|
+
|
|
144
152
|
|
|
145
153
|
// Columbia Fields
|
|
146
154
|
payment.extTerm = this.extTerm;
|
|
@@ -274,6 +282,16 @@ newShop.Payment = function(paymentData){
|
|
|
274
282
|
this.setMandateType = function(newMandateType) {
|
|
275
283
|
this.mandateType = newMandateType;
|
|
276
284
|
};
|
|
285
|
+
this.setStoredCredentialsAgreementDate = function(newStoredCredentialsAgreementDate) {
|
|
286
|
+
this.storedCredentialsAgreementDate = newStoredCredentialsAgreementDate;
|
|
287
|
+
};
|
|
288
|
+
this.setStoredCredentialsNetworkTransactionId = function(newStoredCredentialsNetworkTransactionId) {
|
|
289
|
+
this.storedCredentialsNetworkTransactionId = newStoredCredentialsNetworkTransactionId;
|
|
290
|
+
};
|
|
291
|
+
this.setStoredCredentialsNetworkDateStr = function(newStoredCredentialsNetworkDateStr) {
|
|
292
|
+
this.storedCredentialsNetworkDateStr = newStoredCredentialsNetworkDateStr;
|
|
293
|
+
};
|
|
294
|
+
|
|
277
295
|
|
|
278
296
|
// ---------------------------------------------
|
|
279
297
|
//
|
|
@@ -330,7 +348,13 @@ newShop.Payment = function(paymentData){
|
|
|
330
348
|
};
|
|
331
349
|
this.getStoredCredentialsAgreementDate = function() {
|
|
332
350
|
return this.storedCredentialsAgreementDate;
|
|
333
|
-
}
|
|
351
|
+
};
|
|
352
|
+
this.getStoredCredentialsNetworkTransactionId = function() {
|
|
353
|
+
return this.storedCredentialsNetworkTransactionId;
|
|
354
|
+
};
|
|
355
|
+
this.getStoredCredentialsNetworkDateStr = function() {
|
|
356
|
+
return this.storedCredentialsNetworkDateStr;
|
|
357
|
+
};
|
|
334
358
|
this.getDefaultPayment = function() {
|
|
335
359
|
return this.defaultPayment;
|
|
336
360
|
};
|
|
@@ -169,8 +169,8 @@ function populatePayment(order, salesOrder) {
|
|
|
169
169
|
paymentToSend.CreditCard.TrackOne = "";
|
|
170
170
|
if (order.selectedPayment.storedCredentialsAgreementDate) {
|
|
171
171
|
paymentToSend.storedCredentialsAgreementDate = order.selectedPayment.storedCredentialsAgreementDate;
|
|
172
|
-
paymentToSend.storedCredentialsNetworkTransactionId = order.selectedPayment.storedCredentialsNetworkTransactionId;
|
|
173
172
|
paymentToSend.storedCredentialsNetworkDateStr = order.selectedPayment.storedCredentialsNetworkDateStr;
|
|
173
|
+
paymentToSend.storedCredentialsNetworkTransactionId = order.selectedPayment.storedCredentialsNetworkTransactionId;
|
|
174
174
|
}
|
|
175
175
|
if(cx8_380_accertify) {
|
|
176
176
|
if (AccertifyFraudService.accertifyInMarketConfig(ConfigService.getMarketConfig())) {
|
|
@@ -40,6 +40,8 @@ class PaymentDto {
|
|
|
40
40
|
* countryCode?: string,
|
|
41
41
|
* ccToken?: string,
|
|
42
42
|
* email?: string,
|
|
43
|
+
* storedCredentialsAgreementDate?: string,
|
|
44
|
+
* storedCredentialsAgreementDate?: string,
|
|
43
45
|
* storedCredentialsAgreementDate?: string
|
|
44
46
|
* }} [data]
|
|
45
47
|
*/
|
|
@@ -62,6 +64,8 @@ class PaymentDto {
|
|
|
62
64
|
this.countryCode = data.countryCode;
|
|
63
65
|
this.email = data.email;
|
|
64
66
|
this.storedCredentialsAgreementDate = data.storedCredentialsAgreementDate;
|
|
67
|
+
this.storedCredentialsNetworkTransactionId = data.storedCredentialsNetworkTransactionId;
|
|
68
|
+
this.storedCredentialsNetworkDateStr = data.storedCredentialsNetworkDateStr;
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
|
package/src/receiver.js
CHANGED
|
@@ -294,61 +294,57 @@ const addItemsToCart = async () => {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
try {
|
|
315
|
-
CartService.clearCart();
|
|
316
|
-
promises.push(AccountManager.authenticateWithEid(data.eid, true));
|
|
317
|
-
} catch (err) {
|
|
318
|
-
console.error('Unable to log in mobile user!');
|
|
319
|
-
}
|
|
297
|
+
const eventListener = async (message) => {
|
|
298
|
+
const promises = [];
|
|
299
|
+
const runConfig = RunConfigService.getRunConfig();
|
|
300
|
+
const user = UserService.getUser();
|
|
301
|
+
let data = JSON.parse(message.data);
|
|
302
|
+
|
|
303
|
+
if (data.eid && data.products) {
|
|
304
|
+
if (data.eid) {
|
|
305
|
+
if (user && Base64.decode(data.eid).indexOf(user.id) >= 0) {
|
|
306
|
+
user.eid = data.eid;
|
|
307
|
+
UserService.setUser(user);
|
|
308
|
+
} else {
|
|
309
|
+
try {
|
|
310
|
+
CartService.clearCart();
|
|
311
|
+
promises.push(AccountManager.authenticateWithEid(data.eid, true));
|
|
312
|
+
} catch (err) {
|
|
313
|
+
console.error('Unable to log in mobile user!');
|
|
320
314
|
}
|
|
321
315
|
}
|
|
316
|
+
}
|
|
322
317
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
318
|
+
if (data.shoppingContext && ShoppingContext[data.shoppingContext]) {
|
|
319
|
+
ShoppingContext.setShoppingContext(ShoppingContext[data.shoppingContext]);
|
|
320
|
+
}
|
|
326
321
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
322
|
+
if (Array.isArray(data.products)) {
|
|
323
|
+
data.products.forEach(product => {
|
|
324
|
+
promises.push(CartService.addSkuToCart({
|
|
325
|
+
sku: product.sku,
|
|
326
|
+
cntryCd: runConfig.country,
|
|
327
|
+
language: runConfig.language,
|
|
328
|
+
qty: product.qty,
|
|
329
|
+
isAdr: product.oneTime === false
|
|
330
|
+
}));
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
await Promise.allSettled(promises);
|
|
334
|
+
// the user is being authenticated synchronously so let's make sure
|
|
335
|
+
// the products reflect the correct price.
|
|
336
|
+
CartService.updateItemPrices();
|
|
337
|
+
events.setValue(events.mobile.NATIVE_INITIALIZING, [false]);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const initalizeForMobile = () => {
|
|
342
|
+
ShoppingContext.setShoppingContext(ShoppingContext.MOBILE_CONSUMER);
|
|
345
343
|
|
|
346
|
-
|
|
344
|
+
window.addEventListener("message", eventListener)
|
|
345
|
+
document.addEventListener("message", eventListener);
|
|
347
346
|
|
|
348
|
-
|
|
349
|
-
resolve();
|
|
350
|
-
}, 8000)
|
|
351
|
-
});
|
|
347
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({name: 'ready_to_receive', payload: {}}));
|
|
352
348
|
};
|
|
353
349
|
|
|
354
350
|
const receiveUrlParams = () => {
|
|
@@ -412,9 +408,7 @@ const receiveUrlParams = () => {
|
|
|
412
408
|
const receive = () => {
|
|
413
409
|
if (window.ReactNativeWebView) {
|
|
414
410
|
events.setValue(events.mobile.NATIVE_INITIALIZING, [true]);
|
|
415
|
-
initalizeForMobile()
|
|
416
|
-
events.setValue(events.mobile.NATIVE_INITIALIZING, [false]);
|
|
417
|
-
});
|
|
411
|
+
initalizeForMobile();
|
|
418
412
|
} else {
|
|
419
413
|
receiveUrlParams();
|
|
420
414
|
}
|