@tagadapay/plugin-sdk 3.1.9 → 3.1.10

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TagadaPay SDK v3.1.9
2
+ * TagadaPay SDK v3.1.10
3
3
  * CDN Bundle - Full standalone SDK for external/vanilla pages (Debug Build)
4
4
  * @license MIT
5
5
  */
@@ -1603,6 +1603,7 @@ var TagadaSDKBundle = (() => {
1603
1603
  createRawPluginConfig: () => createRawPluginConfig,
1604
1604
  createTagadaClient: () => createTagadaClient,
1605
1605
  debounceConfigUpdate: () => debounceConfigUpdate,
1606
+ formatMoney: () => formatMoney,
1606
1607
  funnelQueryKeys: () => funnelQueryKeys,
1607
1608
  getFunnelSessionCookie: () => getFunnelSessionCookie,
1608
1609
  getFunnelVariantId: () => getFunnelVariantId,
@@ -9411,6 +9412,26 @@ var TagadaSDKBundle = (() => {
9411
9412
  };
9412
9413
 
9413
9414
  // src/v2/core/utils/currency.ts
9415
+ function formatMoney(amountMinorUnits, currencyCode = "USD", locale = "en-US") {
9416
+ const decimalPlaces = CurrencyUtils.getDecimalPlaces(currencyCode);
9417
+ let value;
9418
+ if (decimalPlaces === 0) {
9419
+ value = amountMinorUnits / 100;
9420
+ } else {
9421
+ value = amountMinorUnits / Math.pow(10, decimalPlaces);
9422
+ }
9423
+ try {
9424
+ return new Intl.NumberFormat(locale, {
9425
+ style: "currency",
9426
+ currency: currencyCode,
9427
+ minimumFractionDigits: decimalPlaces,
9428
+ maximumFractionDigits: decimalPlaces
9429
+ }).format(value);
9430
+ } catch (e) {
9431
+ const symbol = CurrencyUtils.getCurrencySymbol(currencyCode);
9432
+ return "".concat(symbol).concat(value.toFixed(decimalPlaces));
9433
+ }
9434
+ }
9414
9435
  var CurrencyUtils = class {
9415
9436
  /**
9416
9437
  * Get currency from context or fallback to default
@@ -10139,4 +10160,5 @@ if (typeof window !== 'undefined' && TagadaSDKBundle) {
10139
10160
  window.onConfigUpdate = TagadaSDKBundle.onConfigUpdate;
10140
10161
  window.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate;
10141
10162
  window.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
10163
+ window.formatMoney = TagadaSDKBundle.formatMoney;
10142
10164
  }