I'm starting an Apple Pay integration project and have been able to wire up a transaction on the device, and use Stripe to authorize the payment. The part I'm actually struggling with is the proper way for the device to test whether Apple Pay is supported? Thus, for older Iphone models I would choose to hide the Apple Pay features, even if they have ios8 or ios9 installed.
I can probably check for the device model, and ignore Apply Pay for < Iphone5S. However this gets complicated if I also need to start testing IPad versions, etc.
I was wondering if there is a single method somehow to test if ApplePay is supported?
I found this method online as one idea, however it claimed apple pay was supported in the Iphone5 simulator, which I imagine is not entirely true. I do not have an Iphone5 actual device to test with unfortunately.
- (BOOL) applePaySupported {
return [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}
EDIT/SOLUTION:
I now use this line and it is verified to work for Iphone5 (not supported) vs Iphone6 (supported); and I presume other devices. I'm not entirely sure it always works in Simulator but ApplePay is a little odd in there anyway and testing is best done on device.
- (BOOL) applePaySupported {
return [PKPaymentAuthorizationViewController canMakePayments] && [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}
Devices capable of using Apple Pay within iOS apps or on the web include the iPhone 6 and later, iPad Air 2 and later, iPad mini 3 and later, iPad Pro models, and Macs with Touch ID.
Adding a Test Card Number To get started, add a test card to Wallet: Make sure to sign out of iCloud and sign into your test device with your sandbox tester account. Go to Wallet and tap Add Credit or Debit Card. Using your test credential, follow the steps to add a new card using manual entry.
If you have an iPhone 6, 6 Plus, iPhone 6s, 6s Plus, iPhone SE, iPhone 7, 7 Plus, iPhone 8 or 8 Plus, then you have Apple Pay and it works through the Touch ID fingerprint sensor in the Home button.
canMakePayments
- Will return "YES" ( True / 1 ) irrespective of card configuration.
canMakePaymentsUsingNetworks
- Will return "NO" , if card NOT configured or NOT configured properly.
So,should check both... If both should be TRUE then only need to make Button "Apple Pay" visible.
Hope this helps.
In swift 3.0 you can check your device support apple pay or not via this funcation is its return true then your device support apple pay. Here are the list of device that support apple pay :
iPhone 5s only if you purchase latest peace
iPhone SE,
iPhone 6 or later,
iPad Pro,
iPad 5th generation,
iPad Air 2,
iPad mini 3 or later,
and Apple Watch.
func applePaySupported() -> Bool {
return PKPaymentAuthorizationViewController.canMakePayments() && PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [.amex, .visa, .masterCard])
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With