Discussions

Ask a Question
Back to All

Not clear how to verify purchase using Adapty

Hi Adapty team,

I am trying to implement a subscription mechanism in my Flutter app (target platform: iOS).
I've done all the setup on the App Store Connect side (all the required subscriptions are in place)
and now I am trying to implement the client-side logic.

I am also using the StoreKit test environment (sandbox) for testing. Also, I completed the setup for iOS app in the Adapty console with all the required data.

When I am trying to purchase a subscription, I get the following error:

try {
  final product = _adaptyProducts.first;
  final result = await Adapty().makePurchase(product: product);
  debugPrint('result: $result');
  // successful purchase
} on AdaptyError catch (adaptyError) {
  debugPrint('error: $adaptyError');
} catch (e) {
  debugPrint('error: $e');
}

This code throws AdaptyError with the following message:

HTTPError.backend(POST /sdk/in-apps/apple/receipt/validate/, [2.4.5]: Adapty/Backend.Validator.swift#21,
 statusCode: 400, body: {"errors":[{"detail":"21002: The data in the receipt-data property was malformed.","status":"400","source":{"pointer":"/data"},"code":"APPLE_RECEIPT_VALIDATION_ERROR"}]})

Can you please help me to understand what is wrong with my setup?
And I figured out that I need to do some receipt verification (unfortunately, I can't find any documentation about the process of purchase with verification). Still, I don't know how to do it.