A Public API for checking if Apply Pay has cards

Hi, I need to retrieve the following information: check if the iPhone has an Apple Pay configuration that contains at least 1 card

The App I'm working on doesn't need IAP or any other payment configuration, it only needs to know if the user has enabled his iPhone to make payments

currently I've tried:

PKPaymentAuthorizationViewController.canMakePayments() this method returns "true" on iPhone 13 with card and on another iPhone 13 without card. Not what I need.

PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.masterCard]) this method returns "false" on both iPhones with or without card enabled Apple Pay.

I need any solution possible, any but request the information to the user, because the check must be sw-based

Thanks, Daniele

it only needs to know if the user has enabled his iPhone to make payments

The API for canMakePayments is the right approach here. I would recommend that you target all of the supported payment networks. Possibly the .masterCard network was not configured on the device but another is. For example, see the code in Offering Apple Pay in Your App for an approach on how this is done:


class PaymentHandler: NSObject {

	static let supportedNetworks: [PKPaymentNetwork] = [
		.amex,
		.discover,
		.masterCard,
		.visa
	]

	class func applePayStatus() -> (canMakePayments: Bool, canSetupCards: Bool) {
		return (PKPaymentAuthorizationController.canMakePayments(),
				PKPaymentAuthorizationController.canMakePayments(usingNetworks: supportedNetworks))
	}

}

// Usage:

let result = PaymentHandler.applePayStatus()
// Handle the return of the result accordingly here.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

I'm testing the following code The result of "payment_allowed" is "false" for both an iPhone 13 with credit card activated in Apple Pay, and another iPhone 13 without it because the cardTypes dict contains only "false" values. Am I missing something here? The expected result is to obtain "true" for the iPhone 13 with credit card activated.

var cardTypes = [

            "amex": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.amex]),

            "cartesBancaires": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.cartesBancaires]),

            "chinaUnionPay": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.chinaUnionPay]),

            "discover": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.discover]),

            "eftpos": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.eftpos]),

            "electron": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.electron]),

            "elo": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.elo]),

            "idCredit": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.idCredit]),

            "interac": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.interac]),

            "JCB": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.JCB]),

            "mada": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.mada]),

            "maestro": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.maestro]),

            "masterCard": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.masterCard]),

            "privateLabel": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.privateLabel]),

            "quicPay": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.quicPay]),

            "suica": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.suica]),

            "visa": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.visa]),

            "vPay": PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.vPay])

        ]

        

        if #available(iOS 14.5, *) {

            cardTypes["mir"] = PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.mir])

        }

        

        if #available(iOS 15.0, *) {

            cardTypes["barcode"] = PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.barcode])

            cardTypes["girocard"] = PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.girocard])

            cardTypes["waon"] = PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.waon])

            cardTypes["nanaco"] = PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [PKPaymentNetwork.nanaco])

        } else {

            // Fallback on earlier versions

        }

        

        let available_cards = cardTypes

            .filter { $0.value == true }

            .map { $0.key }

            .joined(separator: ",")

        let payment_allowed = available_cards.count > 0
A Public API for checking if Apply Pay has cards
 
 
Q