0

I'm using the following code for receipt validation in appstore.If the receipt is not present the user is asked to login.This is the class i use.

ReceiptFetcher

import Foundation
import StoreKit

class ReceiptFetcher : NSObject {
    
    public var receiptRefreshRequest = SKReceiptRefreshRequest()
    
    override init() {
        super.init()
       // receiptRefreshRequest.delegate = self
    }
    
    func fetchReceipt() {
       
        let receiptPath = Bundle.main.appStoreReceiptURL?.path
     
        
        do {
             receiptRefreshRequest.start()
        }
        catch {
            print("Could not check for receipt presence for some reason... \(error.localizedDescription)")
            
        }
  
}
}

Checking if the receipt exists and if not trying to fetch receipt.For the current scenario there is no receipt and the debugger hits the fetchreceipt block.

 if !FileManager.default.fileExists(atPath: receiptPath!){
        receiptFetcher.receiptRefreshRequest.delegate=self
        receiptFetcher.fetchReceipt();
        }
        else
        {
            receiptValidation()
        }

func request(_ request: SKRequest, didFailWithError error: Error) {
        
         print("Something went wrong: \(error.localizedDescription)")
        DispatchQueue.main.async {
            if let presenter = self.presenting as? ViewController {
                                  presenter.showreceipterror()
                                  self.dismissViewController(self)
                                  NSApplication.shared.terminate(self)                                    
                              }
        }

This leads to the following error.Sandbox box capability is turned on with outgoing connections allowed.Earlier i was able to login as a sandbox user successfully,i think the issue started after i removed the user from appstore connect.I had cleared the existing receipt by taking a fresh build.

   0x600001c59ae0>: Finished refreshing receipt with error: Error Domain=ASDServerErrorDomain Code=500317 "Unhandled exception" UserInfo={NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}
techno
  • 6,100
  • 16
  • 86
  • 192
  • Where are you writing code? Where does a guy named 'receiptValidation' come from? If it's irelevant to your question, why do you need to show it? – El Tomato Aug 21 '21 at 05:39
  • @ElTomato What do you mean by `Where are you writing code?` – techno Aug 21 '21 at 14:05

0 Answers0