Device selection on Apple Pay in-app provisioning

Hi,

I work in a fintech company that offers support to Apple Pay in our cards, i.e. our users have the option add their cards to Apple Pay using our app (in-app provisioning). Our company already got the proper In-App provisioning entitlements from Apple and the entire in-app provisioning process is working as expected.

When an user taps on the button "Add to Apple Wallet" in our app to provision his card, we call the following code below:

Code Block
let config = PKAddPaymentPassRequestConfiguration()
config.cardholderName = "\(firstName) \(lastName)"
config.localizedDescription = "MyApp Card"
config.primaryAccountSuffix = String(cardSuffix)
config.paymentNetwork = .visa
/* Present the Apple Pay ViewController */
let controller = PKAddPaymentPassViewController(requestConfiguration: config, delegate: self)
UIApplication.shared.delegate?.window??.rootViewController?.present(controller!, animated: true)


If the user has an Apple Watch paired, he is greeted with a screen asking him to select on which device he wants to add the card: on his iPhone or on the Apple Watch (please see the following screenshot: imgur.com/a/MSQPnt8 - After the user selects the device, the provisioning process continues successfully as expected.

However, if the user taps on the "Add to Apple Wallet" button and he already has the card added to one of the devices (the Apple Watch, for example), then the code above is called again, but he is once again greeted with the same screen asking him to select on which devices he wants to add the card, on his iPhone or on his Apple Watch, even though the card is already added on the Apple Watch.

The way I understand it, since the card is already added on the Apple Watch, only iPhone should appear as a valid option to have the card added.

Is there anything else that I need to do in the code above to make sure only the available devices (I mean, only the devices that don't have the card added on Apple Pay yet) are listed in the device selection?

Thanks

Replies

Hi! Could you solve somehow this problem?

Any solution? I have same problem

Hi,

please use config.primaryAccountIdentifier = self.getCardFPAN(panNumberSuffix)

use below method to get FPAN ID.

   func getCardFPAN(_ cardSuffix: String?) -> String? {

        let passLibrary = PKPassLibrary()

        var paymentPasses = passLibrary.passes(of: .payment)

        for pass in paymentPasses {

            let paymentPass = pass.paymentPass

            if paymentPass?.primaryAccountNumberSuffix == cardSuffix {

                return paymentPass?.primaryAccountIdentifier

            }         }

        if WCSession.isSupported() {

            // check if the device support to handle an Apple Watch

            let session = WCSession.default             session.activate()             if session.isPaired {

                // Check if the iPhone is paired with the Apple Watch

                paymentPasses = passLibrary.remotePaymentPasses()

                for pass in paymentPasses {

                    let paymentPass = pass.paymentPass

                    if paymentPass?.primaryAccountNumberSuffix == cardSuffix {

                        return paymentPass?.primaryAccountIdentifier

                    }

                }

            }

        }

        return nil

    }

Anybody solution? I still have this issue.

I'm still facing this issue.. Any luck ???