danielsaidi / StoreKitPlus

StoreKitPlus is a Swift SDK that adds extra functionality for working with StoreKit 2, like extensions, observable state, services, etc.
MIT License
84 stars 3 forks source link

hello,Can the user id be added to the transaction information when purchasing goods #4

Open tzgd opened 2 months ago

danielsaidi commented 2 months ago

I can take a look, or will happily merge any PR that adds this feature 👍

tzgd commented 2 months ago

`open func purchase( _ product: Product, uid: String ) async throws -> Product.PurchaseResult {

if os(visionOS)

        throw StoreServiceError.unsupportedPlatform("This purchase operation is not supported in visionOS: Use @Environment(\\.purchase) instead.")
        #else

        let uuid = Product.PurchaseOption.appAccountToken(UUID.init(uuidString: uid)!)
        let result = try await product.purchase(options: [uuid])
        switch result {
        case .success(let result): try await handleTransaction(result)
        case .pending: break
        case .userCancelled: break
        @unknown default: break
        }
        return result
        #endif
    }`

You can add a method to add uid, the code is only for reference, and you can improve it when you are free

danielsaidi commented 2 months ago

That's perfect, I'll make it happen.