adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
96 stars 18 forks source link

Sandbox testing failes #25

Closed Horum-dev closed 2 years ago

Horum-dev commented 3 years ago

Apple review team throws an issue like this: When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead.

In code I use final MakePurchaseResult makePurchaseResult = await Adapty.makePurchase(product); and then grant access if the user has 'premium' level. However, in Sandbox this works only the first time. The second time I want to buy a subscription, Adapty doesn't throw any errors and just skip my make purchase method with no feedback: [Adapty v1.12.7(1)] - INFO. -Calling now: makePurchase(product:offerId:completion:) [Adapty v1.12.7(1)] - INFO. Calling now: extendedValidateReceipt(_:variationId:vendorProductId:transactionId:originalPrice:discountPrice:currencyCode:regionCode:promotionalOfferId:unit:numberOfUnits:paymentMode:completion:) [Adapty v1.12.7(1)] - INFO. Updating local purchaserInfo: Optional(nonSubscriptions: [:], subscriptions: ["subscription_m": vendorProductId: subscription_m, unsubscribedAt: 2021-07-27 15:42:25 +0000, isRefund: false, expiresAt: 2021-07-27 15:42:25 +0000, willRenew: false, isInGracePeriod: false, store: app_store, activatedAt: 2021-07-27 15:15:27 +0000, isSandbox: true, cancellationReason: voluntarily_cancelled, billingIssueDetectedAt: 2021-07-27 15:42:25 +0000, vendorOriginalTransactionId: 1000000849031977, renewedAt: 2021-07-27 15:37:25 +0000, vendorTransactionId: 1000000849044325, isActive: false, isLifetime: false], accessLevels: ["premium": vendorProductId: subscription_m, unsubscribedAt: 2021-07-27 15:42:25 +0000, isRefund: false, expiresAt: 2021-07-27 15:42:25 +0000, willRenew: false, isInGracePeriod: false, store: app_store, id: premium, activatedAt: 2021-07-27 15:15:27 +0000, renewedAt: 2021-07-27 15:37:25 +0000, cancellationReason: voluntarily_cancelled, billingIssueDetectedAt: 2021-07-27 15:42:25 +0000, isActive: false, isLifetime: false]), with profileId: Optional("13bd0222-f6eb-437a-817e-d38d66bd124e"), customerUserId: nil [Adapty v1.12.7(1)] - INFO. Successfully purchased product: subscription_m

Then checking 'premium' level - active premium? false

How to deal with this trouble?? we need to sent to AppStore an app, but purchases don't work

AKyashkin commented 3 years ago

Hey, Can you provide your device info, like OS version, model version, etc.

Horum-dev commented 3 years ago

Hey, Can you provide your device info, like OS version, model version, etc.

iphone 8,11,12 iOS 14.6/14.7

I've dealed with this issue by setting getUserInfo(forseUpdate: true);

And now came with another one - the prompt for buy shows two times, however, 1 button tap and 1-time method calling...

AKyashkin commented 3 years ago

You supposed to retrieve updated purchaserInfo in makePurchase callback without any additional getUserInfo(forseUpdate: true) call. We'll take a look on that.

The second issue is possible in sandbox. Sometimes it happens, but only for sandbox purchases – StoreKit is the one who's responsible for that and we can't affect it.