Search code examples
swifttestingin-app-purchasesandbox

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


Solution

  • 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.