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: add currency regarding the new API #2615

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ios/IapSerializationUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func serialize(_ p: Product) -> [String: Any?] {
"jsonRepresentation": serializeDebug(p.jsonRepresentation),
"price": p.price,
"subscription": serialize(p.subscription),
"type": serialize(p.type)
"type": serialize(p.type),
"currency": p.priceFormatStyle.currencyCode
]
}

Expand Down
4 changes: 0 additions & 4 deletions ios/RNIapIosSk2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ class RNIapIosSk2: RCTEventEmitter, Sk2Delegate {
delegate.stopObserving()
}

override func addListener(_ eventName: String?) {
super.addListener(eventName)
}

/**
"iap-transaction-updated" is unique to Sk2.
"iap-promoted-product" is only avaiable on Sk1
Expand Down
7 changes: 5 additions & 2 deletions src/types/appleSk2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type SubscriptionInfo = {
export type RefundRequestStatus = 'success' | 'userCancelled';

export type ProductSk2 = {
currency: string;
description: string;
displayName: string;
displayPrice: string;
Expand All @@ -51,6 +52,7 @@ export const productSk2Map = ({
description,
displayName,
price,
currency,
displayPrice,
}: ProductSk2): ProductIOS => {
const prod: ProductIOS = {
Expand All @@ -60,7 +62,7 @@ export const productSk2Map = ({
type: 'iap',
price: String(price),
localizedPrice: displayPrice,
currency: '', // Not available on new API, use localizedPrice instead
currency
};
return prod;
};
Expand All @@ -70,6 +72,7 @@ export const subscriptionSk2Map = ({
description,
displayName,
price,
currency,
displayPrice,
subscription,
}: ProductSk2): SubscriptionIOS => {
Expand All @@ -81,7 +84,7 @@ export const subscriptionSk2Map = ({
type: 'subs',
price: String(price),
localizedPrice: displayPrice,
currency: '', // Not available on new API, use localizedPrice instead
currency,
subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,
subscriptionPeriodUnitIOS:
subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,
Expand Down
Loading