8

I am trying to integrate In-App Purchases in my project. I have used a third party library, SwiftyStoreKit, as IAP helper.

I'm trying to fetch the information of my In-App products, but always get a response that Invalid Product Identifiers

All my agreements are in Effect (Paid and Free). Also, My In-App Product status shows Waiting for Upload. My App is yet to be release, so I'm testing it in Sandbox Mode.

Following in my code:

import UIKit
import StoreKit
import SwiftyStoreKit

override func viewDidLoad() {
    super.viewDidLoad()
}

override func viewDidAppear(_ _animated: Bool) {
    super.viewDidAppear(_animated)

    if dataModel.lists.count >= 2 {
        getInfo()
    }
}

func getInfo() {

    NetworkActivityIndicatorManager.NetworkOperationStarted()

    SwiftyStoreKit.retrieveProductsInfo([productIdentifier], completion: { result in

        NetworkActivityIndicatorManager.networkOperationFinished()

        self.showAlert(alert: self.alertForProductRetrievalInfo(result: result))

    })
}
Vaibhav Jhaveri
  • 1,579
  • 3
  • 28
  • 53

7 Answers7

23

I had the same exact problem, but the solutions above did not work for me.

This is what did:

It turns out I hadn't filled out the proper payments and W9 form on AppStoreConnect.

Go to AppStoreConnect > Agreements, Tax, and Banking...

Fill out the "Paid Apps" contract if it hadn't already been filled out

AppstoreConnect Contract

Gabriel Pires
  • 926
  • 9
  • 12
7

Check your productIdentifier! It should be the same string as registered in iTunes Connect. E.g "com.myapp.myPurchase"

4

This is what worked for me:

I was confusing the reference name ( left side ) with the Product ID ( right side )

So make sure that you're using iTunes Connect's Product ID in your code.

enter image description here

2

I had the exact same error and running this code in the app delegate seemed to fix my problem because by adding your app's observer at launch ensures that it will persist during all launches of your app, thus allowing your app to receive all the payment queue notifications.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
 // see notes below for the meaning of Atomic / Non-Atomic
 SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
     for purchase in purchases {
         switch purchase.transaction.transactionState {
         case .purchased, .restored:
             if purchase.needsFinishTransaction {
                 // Deliver content from server, then:
                 SwiftyStoreKit.finishTransaction(purchase.transaction)
             }
             // Unlock content
         case .failed, .purchasing, .deferred:
             break // do nothing
         }
     }
 }
    return true
}
Ryan Forte
  • 499
  • 5
  • 6
2

Make sure you add the "In-App Purchase" to your project from Xcode - Target - Signing & Capabilities.

Vincent Sit
  • 2,214
  • 1
  • 24
  • 27
1

Remember to make your In-App Ready To Submit status.

enter image description here

If your In-App has different status, then it always return invalid product identifier.

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
1

Try use productid instead of com.yourname.projectname.productid

Eray Hamurlu
  • 657
  • 7
  • 9