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

StoreKit 2 - Promotional Offers - .invalidOfferSignature error. Can't purchase any offer. #2114

Closed
roboqo opened this issue Dec 4, 2022 · 4 comments · Fixed by #2020
Closed

Comments

@roboqo
Copy link

roboqo commented Dec 4, 2022

Describe the bug
Our RevenueCat SDK is configured like this and usesStoreKit2IfAvailable is set to false

Purchases.configure(
    with: Configuration.Builder(withAPIKey: "MY_KEY")
        .with(usesStoreKit2IfAvailable: false)
        .build()
)

Then we did implemented Promotional Offers feature following steps described in RC: iOS Subscription Offers

Basically:

let product = somePackage.storeProduct
guard let discount = product.discounts.first else {
    throw PurchaseError.promotionalOfferNotFound
}

let promotionalOffer = try await Purchases.shared.promotionalOffer(forProductDiscount: discount, product: product)

// All good here, presenting offer UI

// Purchasing using code below:

Purchases.shared.purchase(
    product: product,
    promotionalOffer: promotionalOffer,
    completion: responseHandler
)

All worked fine, we have this in production app and all is good there. But, we want to move to StoreKit 2 and by just changing our SDK configuration code to:

Purchases.configure(
    with: Configuration.Builder(withAPIKey: "MY_KEY")
        .with(usesStoreKit2IfAvailable: true)
        .build()
)

That is setting usesStoreKit2IfAvailable to true - we can't purchase ANY promotional offer, always getting the same error:

[Purchases] - ERROR: 😿‼️ The information associated with this PromotionalOffer is not valid. See https://rev.cat/ios-subscription-offers for more info.
[Purchases] - ERROR: 💰 Product purchase for 'PRODUCT_IDENTIFIER_HERE' failed with error: PurchasesError(error: The information associated with this PromotionalOffer is not valid.
See https://rev.cat/ios-subscription-offers for more info., userInfo: ["readable_error_code": "INVALID_PROMOTIONAL_OFFER_ERROR", "source_function": "invalidPromotionalOfferError(error:fileName:functionName:line:)", "NSUnderlyingError": StoreKit.Product.PurchaseError.invalidOfferSignature, "source_file": "RevenueCat/ErrorUtils.swift:413", "NSLocalizedDescription": "The information associated with this PromotionalOffer is not valid.\nSee https://rev.cat/ios-subscription-offers for more info."])

App sheet 1

Error

  1. Environment
    1. Platform: iOS
    2. SDK version: 4.15.0
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): Y
    4. OS version: 16.1.1
    5. Xcode version: 14.1
    6. How widespread is the issue. Percentage of devices affected.
  2. The same problem is with older SDK version - Promotional Offers works fine with SK1, but we always get the same error after enabling SK2
@roboqo roboqo added the bug label Dec 4, 2022
@RCGitBot
Copy link
Contributor

RCGitBot commented Dec 4, 2022

👀 SDKONCALL-182 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@NachoSoto
Copy link
Contributor

Thanks for the report!
Good news: we've identified the issue and a fix will come out shortly (see #2020)

@NachoSoto NachoSoto self-assigned this Dec 6, 2022
@NachoSoto NachoSoto linked a pull request Dec 6, 2022 that will close this issue
NachoSoto added a commit that referenced this issue Dec 9, 2022
Fixes [SDKONCALL-160], [SDKONCALL-182], #2114, and
RevenueCat/react-native-purchases#455.
Depends on #2118 and https://github.com/RevenueCat/khepri/pull/4843 /
https://github.com/RevenueCat/khepri/pull/4852.

## Changes:
- Base64decode `signature`
- Fixed signature on backend for SK2:
https://github.com/RevenueCat/khepri/pull/4843 /
https://github.com/RevenueCat/khepri/pull/4852
- Added tests
- Added specific error if signature can't be decoded:
> [Purchases] - ERROR: 😿‼️ The information associated with this
PromotionalOffer is not valid.
See https://rev.cat/ios-subscription-offers for more info. The signature
generated by RevenueCat could not be decoded: signature 914

[SDKONCALL-160]:
https://revenuecats.atlassian.net/browse/SDKONCALL-160?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

[SDKONCALL-182]:
https://revenuecats.atlassian.net/browse/SDKONCALL-182?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
@NachoSoto
Copy link
Contributor

The fix for this is out on the latest release 🎉

@github-actions
Copy link

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants