Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Handle planId parameter in startIap url, pass language code to Cloudery and improve IAP #1131

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Jan 16, 2024

This is the last PR for IAP before merging everything


feat: Handle planId parameter in startIap url
In previous implementation the cloudery did pass only a productId
parameter that would contain a planId on Android platform

With the new implementation, the cloudery passes the planId in a new
parameter in addition to the productId that now always contains the
real productId on both platforms

This simplifies the getSubscriptionOffers method that does not
require a nested map anymore in order to retrieve the missing
productId


feat: Add device's language code to Cloudery url when displaying offers
The stores require us to display localized prices and descriptions to
the user when displaying IAP options

Our understanding is that descriptions and prices should displayed
using the phone's language (vs the cozy's language)

So we want to provide the phone's language code to the Cloudery using
the lang query parameter

Base automatically changed from feat/iap_part2 to master January 16, 2024 17:02
In previous implementation the cloudery did pass only a `productId`
parameter that would contain a `planId` on Android platform

With the new implementation, the cloudery passes the `planId` in a new
parameter in addition to the `productId` that now always contains the
real `productId` on both platforms

This simplifies the `getSubscriptionOffers` method that does not
require a nested map anymore in order to retrieve the missing
`productId`
The stores require us to display localized prices and descriptions to
the user when displaying IAP options

Our understanding is that descriptions and prices should displayed
using the phone's language (vs the cozy's language)

So we want to provide the phone's language code to the Cloudery using
the `lang` query parameter
@@ -116,9 +117,12 @@ export const useClouderyOffer = (): ClouderyOfferState => {
setPopupUrl(null)
} else {
const offersParam = formatOffers(subscriptions)
const lang = getLocales()[0].languageCode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have getDeviceLanguage that does the same job in our wrapper src/locales/i18n.ts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep but it is not exported, so after talking with @acezard we chose to directly call getLocales() here instead of exporting the other method.

await getSubscriptions({ skus: SKUS })
setPartialPopupUrl(current => current ?? href)
} catch (error: unknown) {
const errorMessage = getErrorMessage(error)
Copy link
Contributor

@zatteo zatteo Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:o I finally understood the purpose of getErrorMessage. I will use it in backup feature...

@Ldoppea Ldoppea merged commit b3506bc into master Jan 16, 2024
1 check passed
@Ldoppea Ldoppea deleted the feat/iap_part3 branch January 16, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants