adaptyteam / AdaptySDK-React-Native

React Native SDK for growing in-app subscriptions
https://docs.adapty.io/docs/quickstart
MIT License
122 stars 12 forks source link

AdaptyPrice localizedString removes 2nd decimal if it is `0` in `.getPaywallProducts` #123

Open pkiler opened 2 months ago

pkiler commented 2 months ago

Description

Currently, requesting paywall products that have prices with their 2nd decimal as 0 seems to truncate this decimal.

Example response from fetch/get-paywall-products (calling Adapty.getPaywallProducts):

{
    "data": [
        {
            [...],
            "price": {
                "currency_code": "PEN",
                "amount": 19.9,
                "localized_string": "S/ 19.9",
                "currency_symbol": "S/"
            },
            "region_code": "PE",
        },
        {
            [...],
            "price": {
                "currency_symbol": "S/",
                "currency_code": "PEN",
                "amount": 39.9,
                "localized_string": "S/ 39.9"
            },
            "region_code": "PE"
        }
    ],
    "type": "Array<AdaptyPaywallProduct>"
}

But calling Adapty.makePurchase opens the native purchase window, with the price displayed with its 2 decimals as expected:

image

Currency in the screenshot is PEN, but might be a general issue with other currencies.

Version

2.10.1

What platforms are you seeing the problem on?

iOS

System info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M3
  Memory: 153.58 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2024.06.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
efstathiosntonas commented 1 month ago

I've chatted with support about this, they had no clue what is going on.

I used Intl and react-native-localize to solve this:

import * as RNLocalize from 'react-native-localize';

export function normalizePrice(amount: number, currencyCode: string) {
  const locale = RNLocalize.getLocales()[0].languageTag;
  return new Intl.NumberFormat(locale, {
    style: 'currency',
    currency: currencyCode,
    minimumFractionDigits: 2
  }).format(amount);
}

usage:

 normalizePrice(
     product?.price?.amount as number,
     product?.price?.currencyCode as string
   )
efstathiosntonas commented 1 month ago

Is anyone home? It's been 3 weeks since the issue was raised and the Intl method is prone to issues. You know we're paying (tons of) money for your product right? We expect support to be optimal at least.

I've opened a ticket through Adapty's dashboard Help but the operators had no clue about this and they didn't even tried to forward this to your technical team. 👎

efstathiosntonas commented 1 month ago

Day 35 and noone from adapty team has replied. Terrible support.

pkiler commented 1 month ago

Yes just a timeline or at least a response on this could be great 😕

vladd-g commented 1 month ago

@pkiler @efstathiosntonas hey, we sincerely apologize for the inconvenience

we're investigating the issue now and will update you as soon as we have more information

efstathiosntonas commented 3 weeks ago

@vladd-g any update on this, it's been 1.5 months.....

vladd-g commented 3 weeks ago

@efstathiosntonas, sorry for the wait. We'll let you know as soon as it's resolved

efstathiosntonas commented 1 week ago

@vladd-g any updates on this one? I hope you guys realize how IMPORTANT price formatting is for the buyers, right?

vladd-g commented 1 week ago

@efstathiosntonas expecting to release it within 2 weeks