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

Support Fetching and Redeeming Win-Back Offers on Custom Paywall #1134 #1218

Merged
merged 9 commits into from
Dec 4, 2024

Conversation

fire-at-will
Copy link
Contributor

@fire-at-will fire-at-will commented Dec 2, 2024

This PR exposes four new functions to allow developers to fetch & redeem win-back offers that a subscriber is eligible for in their custom paywalls. These functions only function on iOS 18.0+ and require StoreKit 2 to be used.

Fetching Eligible Win-Back Offers

  static Future<List<WinBackOffer>> getEligibleWinBackOffersForProduct(
    StoreProduct product,
  ) async

static Future<List<WinBackOffer>> getEligibleWinBackOffersForPackage(
    Package package,
  ) async

Redeeming Win-Back Offers

static Future<CustomerInfo> purchaseProductWithWinBackOffer(
    StoreProduct product,
    WinBackOffer winBackOffer,
  ) async

 static Future<CustomerInfo> purchasePackageWithWinBackOffer(
    Package package,
    WinBackOffer winBackOffer,
  ) async

Other Changes

The PurchaseTester app was updated with a new screen to support testing these flows

Docs

Code snippets for these functions are added to the public docs in this PR: https://github.com/RevenueCat/docusaurus/pull/526

Testing

All flows were tested manually through the new screen in the PurchaseTester app, and the API tester has been updated with the new functions.

@fire-at-will fire-at-will requested review from a team and MarkVillacampa December 3, 2024 15:09
static Future<List<WinBackOffer>> getEligibleWinBackOffersForPackage(
Package package,
) async =>
getEligibleWinBackOffersForProduct(package.storeProduct);
Copy link
Contributor Author

@fire-at-will fire-at-will Dec 3, 2024

Choose a reason for hiding this comment

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

We intentionally use the getEligibleWinBackOffersForProduct function here so that the offer caching logic only needs to be implemented once in the PHC layer

Copy link
Member

@MarkVillacampa MarkVillacampa left a comment

Choose a reason for hiding this comment

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

Looks good 🚀

@fire-at-will fire-at-will merged commit 552d2c2 into main Dec 4, 2024
8 checks passed
@fire-at-will fire-at-will deleted the support-fetching-and-redeeming-winbacks branch December 4, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants