Question

Simple non consumable fails to complete purchase with Flutter on iOS

  • 6 December 2023
  • 2 replies
  • 125 views

Badge +1

Contacted support already about this issue and received a response asking me to try enabling debugging but I replied back to say that the code snippet I provided included this line

Purchases.setLogLevel(LogLevel.debug);

Which as far as I know enables debugging so it was already on. Two days on I never received another reply from support so I’m trying here.

I'm using the code below with revenue cat testing with a sandbox user in my flutter app. The apple in app purchase window appears, I purchase, input the password and it goes to the next screen to finish the purchase but I never actually see "Purchase successful. Ads removed!" printed. The public_sdk_key must be correct since the correct offerings are found. Of course the keys and IDs below are not the ones I'm using for testing, I am using the correct ones. I have created a non consumable in app purchase in app store connect and it's status is 'ready to submit'.

 

pubspec.yaml import = purchases_flutter: ^6.4.0

 

Offering? _offering;

 

@override

void initState() {

super.initState();

initPlatformState();

}

 

Future<void> initPlatformState() async {

Purchases.setLogLevel(LogLevel.debug);

Purchases.configure(PurchasesConfiguration("public_sdk_key")); //public_sdk_key = public API key

Offerings offerings = await Purchases.getOfferings();

if (offerings.current != null) {

setState(() {

_offering = offerings.current;

});

}

}

 

void makePurchase(Package package) async {

try {

print('try purchase');

CustomerInfo customerInfo = await Purchases.purchasePackage(package);

print("cannot reach here");

var isPro = customerInfo.entitlements.all["pro_entitlement_id"]?.isActive ?? false; //pro_entitlement_id

if (isPro) {

print("Purchase successful. Ads removed!");

}

} on PlatformException catch (e) {

print("Purchase failed with error code: ${e.code}");

}

}

 

In the makePurchase function we see "try purchase" printed but we never see "cannot reach here" even and the popup to purchase simply re-appears asking us to try to purchase again. No error messages or debug messages are printed. I'm purchasing with this:

 

makePurchase(_offering!.lifetime!);

 

if I print print(_offering!.lifetime!); I get:

 

Package(identifier: $rc_lifetime, packageType: PackageType.lifetime, storeProduct: StoreProduct(identifier: rmv_ads, description: Remove permanently all ads from the app, title: Remove ads, price: 0.99, priceString: £0.99, currencyCode: GBP, introductoryPrice: null, discounts: [], productCategory: ProductCategory.nonSubscription, defaultOption: null, subscriptionOptions: null, presentedOfferingIdentifier: null, subscriptionPeriod: null), offeringIdentifier: rmv_ads)


2 replies

Userlevel 4
Badge +8

Solving internally via support ticket, will update with resolution here. 

Badge +1

Getting this error when opening the app in sandbox mode:
 

Error enumerating unfinished transactions: Error Domain=ASDErrorDomain Code=500 "(null)" UserInfo={NSUnderlyingError=0x600000cc4930 {Error Domain=AMSErrorDomain Code=2 "Finance Authentication Error" UserInfo={NSLocalizedDescription=Finance Authentication Error, AMSURL=https://mzstorekit-sb.itunes.apple.com/inApps/v1/history?guid=7666DF87F208&reason=initial, AMSStatusCode=401, NSLocalizedFailureReason=No delegate to perform authentication: <AMSAuthenticateRequest: 0x600000c867f0> {

  account = jerichomiles6@gmail.com (78985344-F6FD-42AD-BCEB-DF36B39D9837),

  logKey = 1379CD2F,

  options = <AMSAuthenticateOptions: 0x600003b402a0> {

  AMSAuthenticateOptionsAllowPasswordGeneration = 0,

  AMSAuthenticateOptionsAllowSecondaryCredentialSource = 0,

  AMSAuthenticateOptionsAllowServerDialogs = 0,

  AMSAuthenticateOptionsAuthenticationTypeKey = 1,

  AMSAuthenticateOptionsCanMakeAccountActiveKey = 0,

  AMSAuthenticateOptionsClientInfo = {length = 983, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 0000033d },

  AMSAuthenticateOptionsCredentialSourceKey = 0,

  AMSAuthenticateOptionsDebugReason = no dialogResponse in AMSFinanceAuthenticateResponse,

  AMSAuthenticateOptionsDelegateAuthEnabledKey = 0,

  AMSAuthenticateOptionsEnableAccountCreationKey = 0,

  AMSAuthenticateOptionsEphemeralKey = 0,

  AMSAuthenticateOptionsForceSyncToPairedWatchKey = 0,

  AMSAuthenticateOptionsIgnoreAccountConversion = 0,

  AMSAuthenticateOptionsLogKeyKey = 1379CD2F,

  AMSAuthenticateOptionsRemoteProxyAuthenticationKey = 0,

  AMSAuthenticateOptionsServiceType = 2,

},

}}}, storefront-country-code=GBR, client-environment-type=Sandbox}

Reply