stripe / stripe-terminal-ios

Stripe Terminal iOS SDK
https://stripe.com/docs/terminal/sdk/ios
Other
105 stars 65 forks source link

Expose `isAccountLinked` api for Tap to Pay #274

Closed koenpunt closed 1 year ago

koenpunt commented 1 year ago

Summary

To be able to present a "Setup Tap to Tap" flow to users in our app we need to know whether they already linked their account.

Apple has a method for this, but it isn't available through the Stripe Terminal SDK;

https://developer.apple.com/documentation/proximityreader/paymentcardreader/isaccountlinked(using:)

Code to reproduce

iOS version

Any

Installation method

SPM

SDK version

3.2.0

Other information

A workaround is to connect tosAcceptancePermitted set to false, and then check the error code to determine whether it's because the terms haven't been accepted.

Something like this:

func tosAccepted(locationId: String, onBehalfOf: String? = nil) async -> Bool {
    do {
        let connectionConfig = try LocalMobileConnectionConfigurationBuilder(locationId: locationId)
            .setTosAcceptancePermitted(false)
            .setOnBehalfOf(onBehalfOf)
            .build()

        let session = ConnectReaderSession(connectionConfig: connectionConfig, paymentServiceDelegate: delegate)

        try await session.connect()
        return true
    } catch {
        if (error as NSError).code == ErrorCode.appleBuiltInReaderTOSNotYetAccepted.rawValue {
            return false
        }

        throw error
    }
}

But this is convoluted for a feature that is provided by the platform, and using this workaround also invokes the location request, which isn't desired when only checking whether the terms have been accepted.

bric-stripe commented 1 year ago

Hi, we have an open issue tracking this request: https://github.com/stripe/stripe-terminal-ios/issues/252

I'm going to close this one out. We don't have any timelines but we'll update #252 when we have any info to share for this.

koenpunt commented 1 year ago

Oh by bad, I searched for open issues but missed that one.