@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "5.11.21",
3
+ "version": "5.11.24",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
@@ -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 initalizeForMobile = async () => {
298
- return new Promise((resolve) => {
299
- let timer = null;
300
- const promises = [];
301
- const runConfig = RunConfigService.getRunConfig();
302
- const user = UserService.getUser();
303
-
304
- ShoppingContext.setShoppingContext(ShoppingContext.MOBILE_CONSUMER);
305
-
306
- window.addEventListener("message", async message => {
307
- let data = JSON.parse(message.data);
308
-
309
- if (data.eid) {
310
- if (user && Base64.decode(data.eid).indexOf(user.id) >= 0) {
311
- user.eid = data.eid;
312
- UserService.setUser(user);
313
- } else {
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
- if (data.shoppingContext && ShoppingContext[data.shoppingContext]) {
324
- ShoppingContext.setShoppingContext(ShoppingContext[data.shoppingContext]);
325
- }
318
+ if (data.shoppingContext && ShoppingContext[data.shoppingContext]) {
319
+ ShoppingContext.setShoppingContext(ShoppingContext[data.shoppingContext]);
320
+ }
326
321
 
327
- if (Array.isArray(data.products)) {
328
- data.products.forEach(product => {
329
- promises.push(CartService.addSkuToCart({
330
- sku: product.sku,
331
- cntryCd: runConfig.country,
332
- language: runConfig.language,
333
- qty: product.qty,
334
- isAdr: product.oneTime === false
335
- }));
336
- })
337
- }
338
- await Promise.allSettled(promises);
339
- // the user is being authenticated synchronously so let's make sure
340
- // the products reflect the correct price.
341
- CartService.updateItemPrices();
342
- clearTimeout(timer);
343
- resolve();
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
- window.ReactNativeWebView.postMessage(JSON.stringify({name: 'ready_to_receive', payload: {}}));
344
+ window.addEventListener("message", eventListener)
345
+ document.addEventListener("message", eventListener);
347
346
 
348
- timer = setTimeout(() => {
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().then(() => {
416
- events.setValue(events.mobile.NATIVE_INITIALIZING, [false]);
417
- });
411
+ initalizeForMobile();
418
412
  } else {
419
413
  receiveUrlParams();
420
414
  }