Skip to content

Commit

Permalink
Paywalls: log warning when attempting to purchase already-subscribe…
Browse files Browse the repository at this point in the history
…d product (#3366)

Until we improve the presentation of already-subscribed products this is
just a no-op. This will at least help developers know why nothing is
happening.
  • Loading branch information
NachoSoto authored Oct 31, 2023
1 parent 0f2e31a commit 822bebc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions RevenueCatUI/Data/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ enum Strings {
case found_multiple_packages_of_same_identifier(String)
case unrecognized_variable_name(variableName: String)

case product_already_subscribed

case determining_whether_to_display_paywall
case displaying_paywall
case not_displaying_paywall
Expand All @@ -46,6 +48,9 @@ extension Strings: CustomStringConvertible {
return "Found an unrecognized variable '\(variableName)'. It will be replaced with an empty string.\n" +
"See the docs for more information: https://www.revenuecat.com/docs/paywalls#variables"

case .product_already_subscribed:
return "User is already subscribed to this product. Ignoring."

case .determining_whether_to_display_paywall:
return "Determining whether to display paywall"

Expand Down
5 changes: 4 additions & 1 deletion RevenueCatUI/Views/PurchaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ struct PurchaseButton: View {
private var button: some View {
AsyncButton {
guard !self.purchaseHandler.actionInProgress else { return }
guard !self.selectedPackage.currentlySubscribed else { return }
guard !self.selectedPackage.currentlySubscribed else {
Logger.warning(Strings.product_already_subscribed)
return
}

_ = try await self.purchaseHandler.purchase(package: self.selectedPackage.content)
} label: {
Expand Down

0 comments on commit 822bebc

Please sign in to comment.