2

Trying to do in‐app purchase server receipt validation using AppsFlyer’s SDK. Called the validateAndTrackInAppPurchase method inside the SKStoreKit’s completeTransaction: callback. However it fails and always returns following response.

{
    environment = Sandbox;

    status = 21004;

}

21004 response says The shared secret you provided does not match the shared secret on file for your account.

But I don't have much idea about this shared secret

[[AppsFlyerTracker sharedTracker] validateAndTrackInAppPurchase:productId price:priceString
                                                           currency:@"USD"
                                                      transactionId:transaction.transactionIdentifier
                                               additionalParameters:@{@"test": @"val" , @"test1" : @"val 1"}
                                                            success:^(NSDictionary *result){
                                                                NSLog(@"Purchase succeeded And verified!!! response: %@", result[@"receipt"]);
                                                            } failure:^(NSError *error, id response) {
                                                                NSLog(@"response = %@", response);
                                                                if([response isKindOfClass:[NSDictionary class]]) {
                                                                    if([response[@"status"] isEqualToString:@"in_app_arr_empty"]){
                                                                        // retry with 'SKReceiptRefreshRequest' because
                                                                        // Apple has returned an empty response
                                                                        // <YOUR CODE HERE>
                                                                    }

                                                                } else {
                                                                    //handle other errors
                                                                    return;
                                                                }
                                                            }];
Hichem BOUSSETTA
  • 1,791
  • 1
  • 21
  • 27
isuru
  • 3,385
  • 4
  • 27
  • 62

1 Answers1

3

As you know Auto-Renewable Subscription demands App-Specific Shared Secret,

See appstoreconnect.apple.com -> My Apps -> Features tab -> In-App Purchases -> Auto-Renewable Subscription Item section:

enter image description here

Shared secret looks like: e21e428f20db4d6d90c9192b9b7b2a75

1) 21004 means you try to test Auto-Renewable Subscription and AppsFlyer doesn't have the Shared Secret key.

Please contact the support@appsflyer.com to get more details.


What happens if you do not use Auto-Renewable Subscription but still get this error: 21004:

Apple has some issues with testing in sandbox mode. Try to create a new tester account and do your test again. In the past, once you used account A for testing Auto-Renewable Subscription, all other attempts to test other types of purchase such Consumable, Non-Consumable, Non-Renewing Subscription with account A - Apple returns the same error 21004.

Hope it can help you,

Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
  • Thanks for your response. However appsflyer support team says they cannot add a secret key for iOS automatic subscription renewal. Does appsflyer actually provide the receipt validation for iOS automatic subscription? – isuru May 28 '19 at 07:06