-
Notifications
You must be signed in to change notification settings - Fork 51
Add custom store product support #454
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
Open
yusuftor
wants to merge
14
commits into
develop
Choose a base branch
from
yusuf/custom-store-product
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aa839af
Merge pull request #439 from superwall/develop
yusuftor 280fd1a
Merge pull request #447 from superwall/develop
yusuftor d9f7e50
Add custom store product support for external purchase controllers
yusuftor 4bfce3b
Always regenerate custom transaction ID on each purchase attempt
yusuftor fba87e8
Move .custom case after .other in ProductStore to preserve raw values
yusuftor 9bcf13a
Fix tests
yusuftor 6e55786
Correct free trial behaviour, add formUnion override
yusuftor 20c2015
Update version, add to changelog
yusuftor 0c919a1
Merge branch 'develop' into yusuf/custom-store-product
yusuftor 9ebc779
small fixes
yusuftor 4978f36
Update CustomProductTests.swift
yusuftor 273a9db
Add trial period price to test/custom products
yusuftor 7844038
test fixes
yusuftor 6eb8fd1
Update AddPaywallProducts.swift
yusuftor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,5 +18,5 @@ let sdkVersion = """ | |
| */ | ||
|
|
||
| let sdkVersion = """ | ||
| 4.14.2 | ||
| 4.15.0 | ||
| """ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Sources/SuperwallKit/Models/Product/CustomStoreProduct.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // | ||
| // CustomStoreProduct.swift | ||
| // SuperwallKit | ||
| // | ||
| // Created by Yusuf Tör on 2026-03-12. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// A custom product for use with an external purchase controller. | ||
| @objc(SWKCustomStoreProduct) | ||
| @objcMembers | ||
| public final class CustomStoreProduct: NSObject, Codable, Sendable { | ||
| /// The product identifier. | ||
| public let id: String | ||
|
|
||
| /// The product's store. | ||
| private let store: String | ||
|
|
||
| enum CodingKeys: String, CodingKey { | ||
| case id = "productIdentifier" | ||
| case store | ||
| } | ||
|
|
||
| init( | ||
| id: String, | ||
| store: String = "CUSTOM" | ||
| ) { | ||
| self.id = id | ||
| self.store = store | ||
| } | ||
|
|
||
| public func encode(to encoder: any Encoder) throws { | ||
| var container = encoder.container(keyedBy: CodingKeys.self) | ||
| try container.encode(id, forKey: .id) | ||
| try container.encode(store, forKey: .store) | ||
| } | ||
|
|
||
| public init(from decoder: any Decoder) throws { | ||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
| id = try container.decode(String.self, forKey: .id) | ||
| store = try container.decode(String.self, forKey: .store) | ||
| if store != "CUSTOM" { | ||
| throw DecodingError.dataCorrupted( | ||
| DecodingError.Context( | ||
| codingPath: decoder.codingPath, | ||
| debugDescription: "Not a Custom product \(store)" | ||
| ) | ||
| ) | ||
| } | ||
| super.init() | ||
| } | ||
|
|
||
| public override func isEqual(_ object: Any?) -> Bool { | ||
| guard let other = object as? CustomStoreProduct else { | ||
| return false | ||
| } | ||
| return id == other.id | ||
| && store == other.store | ||
| } | ||
|
|
||
| public override var hash: Int { | ||
| var hasher = Hasher() | ||
| hasher.combine(id) | ||
| hasher.combine(store) | ||
| return hasher.finalize() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.