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

Introductory Offers Not Returning For Subscriptions With StoreKit2 #2471

Closed
Shaw-Signaturize opened this issue Jun 26, 2023 · 12 comments
Closed

Comments

@Shaw-Signaturize
Copy link
Contributor

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description

When using Ios Storekit1 for retrieving subscriptions, information on the associated introductory offers populates onto the properties

  • introductoryPriceAsAmountIOS
  • introductoryPricePaymentModeIOS
  • introductoryPriceNumberOfPeriodsIOS
  • introductoryPriceSubscriptionPeriodIOS

This however does not seem to be the case when using Storekit2 and the properties do not seem to be exposed on any other interface

Expected Behavior

If backwards compatibility is being maintained the properties should populate with the same information

Environment:

  • react-native-iap: 12.10.5
  • react-native: multiple versions
  • Platforms (iOS: simulator & device):

To Reproduce
Steps to reproduce the behavior:

  1. Create new or modify existing app with IAP configured
  2. Create subscriptions and associated introductory offers in app store connect
  3. Confirm that when using storekit1 the offers return on the correct properties after calling getSubscriptions
  4. Alter setup to use storekit2
  5. No introductory information is returned

[Optional] Additional Context

After debugging it would appear that the issue seems to stem from the function subscriptionSk2Map as it is missing property mapping for the introductory properties.

Suggested change would be the following if it is to maintain backwards compatibility with SubscriptionIOS type

export const subscriptionSk2Map = ({
  id,
  description,
  displayName,
  price,
  displayPrice,
  subscription,
}: ProductSk2): SubscriptionIOS => {
  const prod: SubscriptionIOS = {
    platform: SubscriptionPlatform.ios,
    title: displayName,
    productId: String(id),
    description,
    type: 'subs',
    price: String(price),
    localizedPrice: displayPrice,
    currency: '', // Not available on new API, use localizedPrice instead
    subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,
    subscriptionPeriodUnitIOS:
      subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,
    introductoryPriceAsAmountIOS:
      subscription?.introductoryOffer?.displayPrice,
    introductoryPricePaymentModeIOS:
      subscription?.introductoryOffer?.paymentMode.toUpperCase() as SubscriptionPeriod,
    introductoryPriceNumberOfPeriodsIOS: 
      subscription?.introductoryOffer?.period?.value,
    introductoryPriceSubscriptionPeriodIOS: 
      subscription?.introductoryOffer?.period?.unit as SubscriptionIosPeriod,
  };
  return prod;
};

Im happy to create a PR for this but looking to confirm the intent in terms of structure if it is remaining backwards compatible or if it is to follow more closely with the new IOS structure

@usmanabid94
Copy link

check this link:
https://usmanabid477.medium.com/in-app-purchase-integration-in-react-native-app-96c0acd13649

@Shaw-Signaturize
Copy link
Contributor Author

@usmanabid94
Sorry I think there might be a misunderstanding. The article linked only showed a basic setup of IAP.

The issue relates specifically to the introductory offers returning in the JS.
In store kit 1 this all returns correctly and is mapped to the JS correctly.
In store kit 2 the native object also gets the information but is never mapped to the JS.
All my proposed modification does is add the properties to the mapping function in line with the current typescript.

My main query here is one of clarification from the maintainers as the two IOS implementations for introductory offers have quite a significant interface difference.

@caoyongfeng0214
Copy link

same here.
where is subscriptionSk2Map ? how to fix it ?

@Shaw-Signaturize
Copy link
Contributor Author

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue.
If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working.

As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

@RashVenkat6795
Copy link

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue. If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working.

As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

I tried to add this and check
It works on the debug mode, but when tried to push the app on TestFlight to test...
the free trial details doesn't show up on the pop up.

Any idea on this?
@Shaw-Signaturize @andresesfm

@Shaw-Signaturize
Copy link
Contributor Author

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue. If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working.
As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

I tried to add this and check It works on the debug mode, but when tried to push the app on TestFlight to test... the free trial details doesn't show up on the pop up.

Any idea on this? @Shaw-Signaturize @andresesfm

I had a similar issue as our build process runs the npm install and pod install before bundling to testflight. My best guess would be to check your node_modules and check that the version being used is your custom version and it hasnt pulled the one off the public npm.

I think as this problem seems to be hitting a few people I will try and get the change bundled into a PR and get feedback that way

@RashVenkat6795
Copy link

@Shaw-Signaturize Sure, that would really help
Since it's the most high priority use case that anyone would want to get it implemented and working.

Looking forward to your PR

@Shaw-Signaturize
Copy link
Contributor Author

@Shaw-Signaturize Sure, that would really help Since it's the most high priority use case that anyone would want to get it implemented and working.

Looking forward to your PR

Cool ill see if i can get to it early next week

@RashVenkat6795
Copy link

@Shaw-Signaturize Were you able to create PR for this ?

@RashVenkat6795
Copy link

@Shaw-Signaturize any update on this ?
Looking forward to this PR

@Shaw-Signaturize
Copy link
Contributor Author

@RashVenkat6795 Sorry about the delay.
Thought i was going to have availability that week and then other things got in the way.
PR should be up now

PR: #2630

@RashVenkat6795
Copy link

@Shaw-Signaturize thanks for this PR
Also I have one more question....
I submitted my first version of app... was able to see the introductory offer with trial periods as configured properly, now when i'm trying to submit the next version of app with some loaded features... but with this new version, I'm not able to see the free trial details in payment sheet.

Any possible issues you can think of ?

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

No branches or pull requests

4 participants