Skip to content

TrialOrIntroPriceEligibilityChecker: return .noIntroOfferExists if the product has no introductory offer#1859

Merged
NachoSoto merged 1 commit into
mainfrom
sk2-no-intro-offer-eligibility
Aug 23, 2022
Merged

TrialOrIntroPriceEligibilityChecker: return .noIntroOfferExists if the product has no introductory offer#1859
NachoSoto merged 1 commit into
mainfrom
sk2-no-intro-offer-eligibility

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Aug 22, 2022

Copy link
Copy Markdown
Contributor

Fixes CSDK-432.

The SK1 implementation was checking if the product actually had an intro offer.
However, the SK2 version only checked if Product had a SubscriptionInfo, and relied on isEligibleForIntroOffer. But we needed to verify that the SubscriptionOffer actually contained an introductoryOffer.

…f the product has no introductory offer

Fixes [CSDK-432].

The SK1 implementation [was checking](https://github.com/RevenueCat/purchases-ios/blob/39746c7e2a3f2ad3ba491cd1c5bbb3643e4aac89/Sources/Purchasing/TrialOrIntroPriceEligibilityChecker.swift#L161) if the product actually had an intro offer.
However, the SK2 version only checked if `Product` had a `SubscriptionInfo`, and relied on `isEligibleForIntroOffer`. But we needed to verify that the `SubscriptionOffer` actually contained an `introductoryOffer`.
@NachoSoto NachoSoto added the pr:fix A bug fix label Aug 22, 2022
@NachoSoto NachoSoto requested review from a team, aboedo and fire-at-will August 22, 2022 23:29
Comment on lines +104 to +105
var introDictionary: [String: IntroEligibility] = identifiers.dictionaryWithValues { _ in
.init(eligibilityStatus: .unknown)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Small refactor using the new Set.dictionaryWithValues

expect(eligibility) == .eligible
}

func testNoIntroOfferIfProductHasNoIntro() async throws {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed this test failed on SK2 only:
Screenshot 2022-08-22 at 16 30 33

@NachoSoto NachoSoto merged commit 95b0a6c into main Aug 23, 2022
@NachoSoto NachoSoto deleted the sk2-no-intro-offer-eligibility branch August 23, 2022 17:54
@aboedo

aboedo commented Aug 23, 2022

Copy link
Copy Markdown
Member

awesome!! 🎉

@aboedo

aboedo commented Aug 23, 2022

Copy link
Copy Markdown
Member

If I'm reading this correctly, we'll have an automatic release for this tomorrow, right? @vegaro

@vegaro

vegaro commented Aug 23, 2022

Copy link
Copy Markdown
Member

Yes. If everything works as expected lol. There will be an automatic PR. We just need to approve the approval job in CircleCI and the rest will be performed automatically

@aboedo

aboedo commented Aug 23, 2022

Copy link
Copy Markdown
Member

🎉

@vegaro vegaro mentioned this pull request Aug 26, 2022
kaushikpaperboat pushed a commit to Kiddopia/purchases-ios that referenced this pull request Sep 7, 2022
* rc-4.11.0: (964 commits)
  Update RevenueCat-Swift.h for version 4.11.0
  Version bump for 4.11.0
  skip if needed and adds automatic_release (RevenueCat#1870)
  Fixed crash on `async` SK1 cancelled purchase (RevenueCat#1869)
  Added `beginRefundRequest` overload with completion block (RevenueCat#1861)
  Release/4.10.3 (RevenueCat#1867)
  Update fastlane-plugin-revenuecat_internal and fix release-train job (RevenueCat#1866)
  fix typo in comment (RevenueCat#1863)
  Use Dangerfile repository (RevenueCat#1864)
  `CircleCI`: added job for building SDK with `SPM` (RevenueCat#1860)
  `TrialOrIntroPriceEligibilityChecker`: return `.noIntroOfferExists` if the product has no introductory offer (RevenueCat#1859)
  `Lock`: changed default implementation to use `NSLock` (RevenueCat#1819)
  `Offering: Sendable` conformance (RevenueCat#1826)
  `ReceiptParser: Sendable` conformance (RevenueCat#1825)
  `CustomerInfo: Sendable` conformance (RevenueCat#1824)
  Added `Collection.onlyElement` (RevenueCat#1857)
  README updates (RevenueCat#1856)
  `IntegrationTests`: actually fail test if tests aren't configured (RevenueCat#1855)
  `watchOS`: fixed crash on single-target apps (RevenueCat#1849)
  Prepare next version: 4.11.0-SNAPSHOT (RevenueCat#1854)
  ...

# Conflicts:
#	.circleci/config.yml
#	.jazzy.yaml
#	.version
#	CHANGELOG.latest.md
#	CHANGELOG.md
#	Gemfile.lock
#	Package.swift
#	Purchases/Attribution/RCAttributionFetcher.h
#	Purchases/Attribution/RCAttributionFetcher.m
#	Purchases/Attribution/RCAttributionPoster.m
#	Purchases/Attribution/RCAttributionTypeFactory.h
#	Purchases/Attribution/RCAttributionTypeFactory.m
#	Purchases/Caching/RCDeviceCache.m
#	Purchases/Misc/RCSystemInfo.m
#	Purchases/Networking/RCBackend.h
#	Purchases/Networking/RCBackend.m
#	Purchases/ProtectedExtensions/RCAttributionTypeFactory+Protected.h
#	Purchases/Public/RCPurchases.h
#	Purchases/Public/RCPurchases.m
#	Purchases/Public/RCPurchasesErrorUtils.h
#	Purchases/Public/RCPurchasesErrorUtils.m
#	Purchases/Purchasing/RCOfferingsFactory.m
#	Purchases/Purchasing/RCStoreKitRequestFetcher.h
#	Purchases/Purchasing/RCStoreKitRequestFetcher.m
#	Purchases/SubscriberAttributes/RCSubscriberAttributesManager.h
#	Purchases/SubscriberAttributes/RCSubscriberAttributesManager.m
#	PurchasesCoreSwift.podspec
#	PurchasesCoreSwift/Info.plist
#	PurchasesCoreSwift/Logging/Strings/AttributionStrings.swift
#	PurchasesCoreSwift/Logging/Strings/IdentityStrings.swift
#	PurchasesCoreSwift/Logging/Strings/OfferingStrings.swift
#	PurchasesCoreSwift/Misc/OperationDispatcher.swift
#	PurchasesCoreSwift/SubscriberAttributes/SpecialSubscriberAttributes.swift
#	PurchasesTests/Info.plist
#	PurchasesTests/Mocks/MockAttributionFetcher.swift
#	PurchasesTests/Mocks/MockAttributionTypeFactory.swift
#	PurchasesTests/Mocks/MockBackend.swift
#	PurchasesTests/Mocks/MockOfferingsFactory.swift
#	PurchasesTests/Mocks/MockRequestFetcher.swift
#	PurchasesTests/Networking/BackendTests.swift
#	PurchasesTests/Purchasing/OfferingsTests.swift
#	PurchasesTests/Purchasing/PurchasesTests.swift
#	PurchasesTests/SubscriberAttributes/PurchasesSubscriberAttributesTests.swift
#	RevenueCat.podspec
#	Sources/Info.plist
#	Tests/BackendIntegrationTestApp/Info.plist
#	Tests/BackendIntegrationTests/Info.plist
#	Tests/InstallationTests/CocoapodsInstallation/Gemfile.lock
#	Tests/InstallationTests/XcodeDirectInstallation/XcodeDirectInstallation.xcodeproj/project.pbxproj
#	Tests/UnitTests/Attribution/AttributionTypeFactoryTests.swift
#	Tests/UnitTests/Info.plist
#	Tests/UnitTests/Mocks/MockProductsRequest.swift
#	Tests/UnitTests/Mocks/MockSubscriberAttributesManager.swift
#	Tests/UnitTests/Purchasing/StoreKitRequestFetcherTests.swift
#	fastlane/Fastfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants