apps-sdk 1.0.181 → 1.0.182

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": "apps-sdk",
3
- "version": "1.0.181",
3
+ "version": "1.0.182",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -239,12 +239,19 @@ class PayWallLogic {
239
239
  let currencySymbol = '';
240
240
  let symbolPositionStart = false;
241
241
  let localizedPrice = '';
242
+ let decimalChar = '.';
242
243
 
243
244
  if (product.subscriptionPeriodUnitIOS) {
244
245
  price = product.price;
245
246
  currencySymbol = product.localizedPrice.replace(/[0-9,.\s]/g, '').trim();
246
247
  localizedPrice = product.localizedPrice;
247
248
  symbolPositionStart = product.localizedPrice.trim().startsWith(currencySymbol);
249
+
250
+ const match = product.localizedPrice.match(/(\d+)([^\d\s])/);
251
+ if (match) {
252
+ decimalChar = match[2];
253
+ }
254
+
248
255
  if (product.subscriptionPeriodUnitIOS === 'DAY' && product.subscriptionPeriodNumberIOS == 7) {
249
256
  period = 'WEEK';
250
257
  yearPrice = parseFloat(product.localizedPrice.replace(/[^\d,.-]/g, '').replace(',', '.')) * 52;
@@ -268,6 +275,11 @@ class PayWallLogic {
268
275
  currencySymbol = phase.formattedPrice.replace(/[0-9,.\s]/g, '').trim();
269
276
  symbolPositionStart = phase.formattedPrice.trim().startsWith(currencySymbol);
270
277
 
278
+ const match = phase.formattedPrice.match(/(\d+)([^\d\s])/);
279
+ if (match) {
280
+ decimalChar = match[2];
281
+ }
282
+
271
283
  switch (periodicity) {
272
284
  case 'P1W':
273
285
  period = 'WEEK';
@@ -313,10 +325,12 @@ class PayWallLogic {
313
325
  weekPrice = parseFloat(weekPrice.toFixed(2));
314
326
  dayPrice = parseFloat(dayPrice.toFixed(2));
315
327
 
316
- const localizedPriceYear = symbolPositionStart ? `${currencySymbol} ${yearPrice}` : `${yearPrice} ${currencySymbol}`.trim();
317
- const localizedPriceMonth = symbolPositionStart ? `${currencySymbol} ${monthPrice}` : `${monthPrice} ${currencySymbol}`.trim();
318
- const localizedPriceWeek = symbolPositionStart ? `${currencySymbol} ${weekPrice}` : `${weekPrice} ${currencySymbol}`.trim();
319
- const localizedPriceDay = symbolPositionStart ? `${currencySymbol} ${dayPrice}` : `${dayPrice} ${currencySymbol}`.trim();
328
+ const formatPrice = (price) => price.toString().replace('.', decimalChar);
329
+
330
+ const localizedPriceYear = symbolPositionStart ? `${currencySymbol} ${formatPrice(yearPrice)}` : `${formatPrice(yearPrice)} ${currencySymbol}`.trim();
331
+ const localizedPriceMonth = symbolPositionStart ? `${currencySymbol} ${formatPrice(monthPrice)}` : `${formatPrice(monthPrice)} ${currencySymbol}`.trim();
332
+ const localizedPriceWeek = symbolPositionStart ? `${currencySymbol} ${formatPrice(weekPrice)}` : `${formatPrice(weekPrice)} ${currencySymbol}`.trim();
333
+ const localizedPriceDay = symbolPositionStart ? `${currencySymbol} ${formatPrice(dayPrice)}` : `${formatPrice(dayPrice)} ${currencySymbol}`.trim();
320
334
 
321
335
  payWallInfo[product.productId] = {
322
336
  productIdentifier: product.productId,