ios – SwiftyStoreKit ReceiptItem – Getting a singular transaction id for subscription


I’m utilizing the In App Purchases library SwiftyStoreKit and I’ve some questions in thoughts. I’m validating my subscription receipt regionally which isn’t the very best resolution however I haven’t got the time to create a brand new server for one of these activity.

I’ve the next capabilities that are used to confirm the IAP subscription. And I used to be questioning if there’s a method to get a singular receipt id for every subscribed consumer.

func verifySubscriptions(_ purchases: Set<RegisteredPurchase>) {
    verifyReceipt { lead to
        
        change consequence {
        case .success(let receipt):
            let productIds = Set(purchases.map { self.subscriptionsBundleId + "." + $0.rawValue })
            let purchaseResult = SwiftyStoreKit.verifySubscriptions(productIds: productIds, inReceipt: receipt)
            change purchaseResult {
            case .bought(let expiryDate, let objects):
                print("(productIds) is legitimate till (expiryDate)n(objects)n")
                UserDefaults.commonplace.set(true, forKey: "PREMIUM")
            case .expired(let expiryDate, let objects):
                print("(productIds) is expired since (expiryDate)n(purchaseResult)n")
                UserDefaults.commonplace.set(false, forKey: "PREMIUM")
            case .notPurchased:
                print("The consumer has by no means bought (productIds)")
                UserDefaults.commonplace.set(false, forKey: "PREMIUM")
            }
            
            self.checkIfProOrNot()
            self.wasCheckIfProOrNotCalledOnStart = false
            
        case .error: break
        }
    }
}

func verifyReceipt(completion: @escaping (VerifyReceiptResult) -> Void) {
    let appleValidator = AppleReceiptValidator(service: .manufacturing, sharedSecret: MyConstants.SHARED_SECRET)
    SwiftyStoreKit.verifyReceipt(utilizing: appleValidator, completion: completion)
}

As you may see from the above code, I’m printing all of the objects contained in the .bought case. This prints the next:

[SwiftyStoreKit.ReceiptItem(productId: "com.example.app.premium", quantity: 1, transactionId: "2000000XXXXXXX06", originalTransactionId: "2000000XXXXXXX71", purchaseDate: 2022-07-29 01:49:37 +0000, originalPurchaseDate: 2022-07-29 01:42:38 +0000, webOrderLineItemId: Optional("200000000XXXXX02"), subscriptionExpirationDate: Optional(2022-07-29 01:54:37 +0000), cancellationDate: nil, isTrialPeriod: false, isInIntroOfferPeriod: false), SwiftyStoreKit.ReceiptItem(productId: "com.example.app.premium", quantity: 1, transactionId: "2000000XXXXXXX88", originalTransactionId: "2000000XXXXXXX71", purchaseDate: 2022-07-29 01:44:37 +0000, originalPurchaseDate: 2022-07-29 01:42:38 +0000, webOrderLineItemId: Optional("200000000XXXXX77"), subscriptionExpirationDate: Optional(2022-07-29 01:49:37 +0000), cancellationDate: nil, isTrialPeriod: false, isInIntroOfferPeriod: false), SwiftyStoreKit.ReceiptItem(productId: "com.example.app.premium", quantity: 1, transactionId: "2000000XXXXXXX71", originalTransactionId: "2000000XXXXXXX71", purchaseDate: 2022-07-29 01:42:37 +0000, originalPurchaseDate: 2022-07-29 01:42:38 +0000, webOrderLineItemId: Optional("200000000XXXXX76"), subscriptionExpirationDate: Optional(2022-07-29 01:44:37 +0000), cancellationDate: nil, isTrialPeriod: true, isInIntroOfferPeriod: false)]

As you may see there may be two issues which are in concern, transactionId & originalTransactionId. Can I depend on transactionId and originalTransactionId to be at all times distinctive for every gadget and subscription? Additionally, I see that transactionId at all times modifications when ever verifySubscriptions() will get known as. The receipt merchandise isn’t documented within the SwiftyStoreKit library and any suggestions (detailed) on this might be appreciated.

Thanks for taking the time!