Zim
Zim

Reputation: 722

Swift In-App purchases sandbox tester error

I am implementing the In-App purchases function today, and I just followed the tutorial step by step, created sandbox testers, wrote the code, and it says

<SKPaymentQueue: 0x282e50860>: Payment completed with error: Error Domain=ASDServerErrorDomain Code=3502 "This item is not available." UserInfo={NSLocalizedDescription=This item is not available.

Why is "This item is not available."? I searched the relevant information online, but there is no answer for it.

Here is my code

@IBAction func purchaseButtonPressed(_ sender: UIButton) {
       print("PRESSED")
       purchaseApp()
   }
   
   func purchaseApp() {
       let productID = "com.crazycat.Reborn.FullFuctionalities"
       if SKPaymentQueue.canMakePayments() {
           let paymentRequest = SKMutablePayment()
           paymentRequest.productIdentifier = productID
           SKPaymentQueue.default().add(paymentRequest)
       } else {
           print("Can't make payments")
       }
   }

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
       for transaction in transactions {
           if transaction.transactionState == .purchased {
               print("Thanks for shopping")
           } else if transaction.transactionState == .failed {
               print("purchase Failed")
           }
       }
   }

Upvotes: 0

Views: 2089

Answers (2)

Stephy
Stephy

Reputation: 56

I had the same issue. Please make sure your paid application agreement in Appstore connect is Active and not Expired. Check if there are any warnings in the App Store connect. Complete all of the bank, tax, and contact information on your App Store Connect Paid Apps Agreements.

Then relaunch the app from Xcode on your physical device.

The transaction should be successful then.

Upvotes: 2

iOS_Dev
iOS_Dev

Reputation: 66

Check below points

  • Use the same test account you specified in developer console.
  • Make sure the In-App product shows a status of Ready to Submit on the developer console.
  • Make sure the In-App product id matches what your using in your app.

Upvotes: 0

Related Questions