Vaibhav Jhaveri
Vaibhav Jhaveri

Reputation: 1605

iOS - In-App Purchase - Invalid product Identifier

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))

    })
}

Upvotes: 9

Views: 14090

Answers (7)

Eray Hamurlu
Eray Hamurlu

Reputation: 783

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

Upvotes: 1

Vincent Sit
Vincent Sit

Reputation: 2354

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

Upvotes: 3

Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

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.

Upvotes: 1

Gabriel Pires
Gabriel Pires

Reputation: 966

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

Upvotes: 27

user4414149
user4414149

Reputation:

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

Upvotes: 4

Ryan Forte
Ryan Forte

Reputation: 589

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
}

Upvotes: 2

Evgeniy  Gushchin
Evgeniy Gushchin

Reputation: 681

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

Upvotes: 7

Related Questions