Before moving on to PKPaymentAuthorizationViewController , you must properly configure Apple Payp on your iPhone. If you have not configured Apple Pay on your device, you will receive a nil value for PKPaymentAuthorizationViewController . You can even find an exception on the console by specifying " This device cannot make payment. "
To set up Apple Pay on your device, follow these steps:
- Go to Settings .
- Select the Passbook and Apple Pay option (if this parameter does not appear in the settings, go to General → Language and region , change your region to the USA or Great Britain, after that you can see the Passbook and Apple Pay option in Settings )
- Open the Passbook app on your home screen and set up a valid credit / debit card (only on cards in the US and UK).
- After checking the added card, run the application, you will receive a valid instance of
PKPaymentAuthorizationViewController .
Hope this helps.
source share